diff options
Diffstat (limited to 'contrib/texinfo/info/makedoc.c')
-rw-r--r-- | contrib/texinfo/info/makedoc.c | 263 |
1 files changed, 124 insertions, 139 deletions
diff --git a/contrib/texinfo/info/makedoc.c b/contrib/texinfo/info/makedoc.c index c0c4587..c88663f 100644 --- a/contrib/texinfo/info/makedoc.c +++ b/contrib/texinfo/info/makedoc.c @@ -1,9 +1,10 @@ -/* makedoc.c -- Make DOC.C and FUNS.H from input files. */ +/* makedoc.c -- Make doc.c and funs.h from input files. + $Id: makedoc.c,v 1.4 1997/07/15 18:35:59 karl Exp $ -/* This file is part of GNU Info, a program for reading online documentation + This file is part of GNU Info, a program for reading online documentation stored in Info format. - Copyright (C) 1993 Free Software Foundation, Inc. + Copyright (C) 1993, 97 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -26,24 +27,8 @@ a header file which describes the contents. This only does the functions declared with DECLARE_INFO_COMMAND. */ -#include <stdio.h> -#include <ctype.h> -#include <sys/types.h> -#if defined (HAVE_SYS_FILE_H) -#include <sys/file.h> -#endif /* HAVE_SYS_FILE_H */ -#include <sys/stat.h> -#include "general.h" - -#if !defined (O_RDONLY) -#if defined (HAVE_SYS_FCNTL_H) -#include <sys/fcntl.h> -#else /* !HAVE_SYS_FCNTL_H */ -#include <fcntl.h> -#endif /* !HAVE_SYS_FCNTL_H */ -#endif /* !O_RDONLY */ - -extern void *xmalloc (), *xrealloc (); +#include "info.h" + static void fatal_file_error (); /* Name of the header file which receives the declarations of functions. */ @@ -79,15 +64,15 @@ static char *doc_header_1[] = { /* How to remember the locations of the functions found so that Emacs can use the information in a tag table. */ typedef struct { - char *name; /* Name of the tag. */ - int line; /* Line number at which it appears. */ - long char_offset; /* Character offset at which it appears. */ + char *name; /* Name of the tag. */ + int line; /* Line number at which it appears. */ + long char_offset; /* Character offset at which it appears. */ } EMACS_TAG; typedef struct { - char *filename; /* Name of the file containing entries. */ - long entrylen; /* Total number of characters in tag block. */ - EMACS_TAG **entries; /* Entries found in FILENAME. */ + char *filename; /* Name of the file containing entries. */ + long entrylen; /* Total number of characters in tag block. */ + EMACS_TAG **entries; /* Entries found in FILENAME. */ int entries_index; int entries_slots; } EMACS_TAG_BLOCK; @@ -114,8 +99,8 @@ main (argc, argv) for (i = 1; i < argc; i++) if (strcmp (argv[i], "-tags") == 0) { - tags_only++; - break; + tags_only++; + break; } if (tags_only) @@ -128,8 +113,8 @@ main (argc, argv) doc_stream = must_fopen (doc_filename, "w"); fprintf (funs_stream, - "/* %s -- Generated declarations for Info commands. */\n", - funs_filename); + "/* %s -- Generated declarations for Info commands. */\n", + funs_filename); for (i = 0; doc_header[i]; i++) { @@ -138,7 +123,7 @@ main (argc, argv) } fprintf (doc_stream, - " Source files groveled to make this file include:\n\n"); + _(" Source files groveled to make this file include:\n\n")); for (i = 1; i < argc; i++) fprintf (doc_stream, "\t%s\n", argv[i]); @@ -155,17 +140,17 @@ main (argc, argv) curfile = argv[i]; if (*curfile == '-') - continue; + continue; fprintf (doc_stream, "/* Commands found in \"%s\". */\n", curfile); fprintf (funs_stream, "\n/* Functions declared in \"%s\". */\n", - curfile); + curfile); process_one_file (curfile, doc_stream, funs_stream); } fprintf (doc_stream, - " { (VFunction *)NULL, (char *)NULL, (char *)NULL }\n};\n"); + " { (VFunction *)NULL, (char *)NULL, (char *)NULL }\n};\n"); fclose (funs_stream); fclose (doc_stream); @@ -195,25 +180,25 @@ maybe_dump_tags (stream) /* Calculate the length of the dumped block first. */ for (j = 0; j < block->entries_index; j++) - { - char digits[30]; - etag = block->entries[j]; - block_len += 3 + strlen (etag->name); - sprintf (digits, "%d,%d", etag->line, etag->char_offset); - block_len += strlen (digits); - } + { + char digits[30]; + etag = block->entries[j]; + block_len += 3 + strlen (etag->name); + sprintf (digits, "%d,%ld", etag->line, etag->char_offset); + block_len += strlen (digits); + } /* Print out the defining line. */ - fprintf (stream, "\f\n%s,%d\n", block->filename, block_len); + fprintf (stream, "\f\n%s,%ld\n", block->filename, block_len); /* Print out the individual tags. */ for (j = 0; j < block->entries_index; j++) - { - etag = block->entries[j]; + { + etag = block->entries[j]; - fprintf (stream, "%s,\177%d,%d\n", - etag->name, etag->line, etag->char_offset); - } + fprintf (stream, "%s,\177%d,%ld\n", + etag->name, etag->line, etag->char_offset); + } } } @@ -226,7 +211,7 @@ make_emacs_tag_block (filename) EMACS_TAG_BLOCK *block; block = (EMACS_TAG_BLOCK *)xmalloc (sizeof (EMACS_TAG_BLOCK)); - block->filename = strdup (filename); + block->filename = xstrdup (filename); block->entrylen = 0; block->entries = (EMACS_TAG **)NULL; block->entries_index = 0; @@ -248,7 +233,7 @@ add_tag_to_block (block, name, line, char_offset) tag->line = line; tag->char_offset = char_offset; add_pointer_to_array (tag, block->entries_index, block->entries, - block->entries_slots, 50, EMACS_TAG *); + block->entries_slots, 50, EMACS_TAG *); } /* Read the file represented by FILENAME into core, and search it for Info @@ -297,51 +282,51 @@ process_one_file (filename, doc_stream, funs_stream) #endif /* NAMED_FUNCTIONS */ for (; offset < (file_size - decl_len); offset++) - { - if (buffer[offset] == '\n') - { - line_number++; - line_start = offset + 1; - } - - if (strncmp (buffer + offset, decl_str, decl_len) == 0) - { - offset += decl_len; - point = offset; - break; - } - } + { + if (buffer[offset] == '\n') + { + line_number++; + line_start = offset + 1; + } + + if (strncmp (buffer + offset, decl_str, decl_len) == 0) + { + offset += decl_len; + point = offset; + break; + } + } if (!point) - break; + break; /* Skip forward until we find the open paren. */ while (point < file_size) - { - if (buffer[point] == '\n') - { - line_number++; - line_start = point + 1; - } - else if (buffer[point] == '(') - break; - - point++; - } + { + if (buffer[point] == '\n') + { + line_number++; + line_start = point + 1; + } + else if (buffer[point] == '(') + break; + + point++; + } while (point++ < file_size) - { - if (!whitespace_or_newline (buffer[point])) - break; - else if (buffer[point] == '\n') - { - line_number++; - line_start = point + 1; - } - } + { + if (!whitespace_or_newline (buffer[point])) + break; + else if (buffer[point] == '\n') + { + line_number++; + line_start = point + 1; + } + } if (point >= file_size) - break; + break; /* Now looking at name of function. Get it. */ for (offset = point; buffer[offset] != ','; offset++); @@ -351,42 +336,42 @@ process_one_file (filename, doc_stream, funs_stream) /* Remember this tag in the current block. */ { - char *tag_name; + char *tag_name; - tag_name = (char *)xmalloc (1 + (offset - line_start)); - strncpy (tag_name, buffer + line_start, offset - line_start); - tag_name[offset - line_start] = '\0'; - add_tag_to_block (block, tag_name, line_number, point); + tag_name = (char *)xmalloc (1 + (offset - line_start)); + strncpy (tag_name, buffer + line_start, offset - line_start); + tag_name[offset - line_start] = '\0'; + add_tag_to_block (block, tag_name, line_number, point); } #if defined (NAMED_FUNCTIONS) /* Generate the user-visible function name from the function's name. */ { - register int i; - char *name_start; + register int i; + char *name_start; - name_start = func; + name_start = func; - if (strncmp (name_start, "info_", 5) == 0) - name_start += 5; + if (strncmp (name_start, "info_", 5) == 0) + name_start += 5; - func_name = strdup (name_start); + func_name = xstrdup (name_start); - /* Fix up "ea" commands. */ - if (strncmp (func_name, "ea_", 3) == 0) - { - char *temp_func_name; + /* Fix up "ea" commands. */ + if (strncmp (func_name, "ea_", 3) == 0) + { + char *temp_func_name; - temp_func_name = (char *)xmalloc (10 + strlen (func_name)); - strcpy (temp_func_name, "echo_area_"); - strcat (temp_func_name, func_name + 3); - free (func_name); - func_name = temp_func_name; - } + temp_func_name = (char *)xmalloc (10 + strlen (func_name)); + strcpy (temp_func_name, "echo_area_"); + strcat (temp_func_name, func_name + 3); + free (func_name); + func_name = temp_func_name; + } - for (i = 0; func_name[i]; i++) - if (func_name[i] == '_') - func_name[i] = '-'; + for (i = 0; func_name[i]; i++) + if (func_name[i] == '_') + func_name[i] = '-'; } #endif /* NAMED_FUNCTIONS */ @@ -394,40 +379,40 @@ process_one_file (filename, doc_stream, funs_stream) point = offset + 1; while (point < file_size) - { - if (buffer[point] == '\n') - { - line_number++; - line_start = point + 1; - } - - if (buffer[point] == '"') - break; - else - point++; - } + { + if (buffer[point] == '\n') + { + line_number++; + line_start = point + 1; + } + + if (buffer[point] == '"') + break; + else + point++; + } offset = point + 1; while (offset < file_size) - { - if (buffer[offset] == '\n') - { - line_number++; - line_start = offset + 1; - } - - if (buffer[offset] == '\\') - offset += 2; - else if (buffer[offset] == '"') - break; - else - offset++; - } + { + if (buffer[offset] == '\n') + { + line_number++; + line_start = offset + 1; + } + + if (buffer[offset] == '\\') + offset += 2; + else if (buffer[offset] == '"') + break; + else + offset++; + } offset++; if (offset >= file_size) - break; + break; doc = (char *)xmalloc (1 + (offset - point)); strncpy (doc, buffer + point, offset - point); @@ -450,7 +435,7 @@ process_one_file (filename, doc_stream, funs_stream) free the memory already allocated to it. */ if (block->entries) add_pointer_to_array (block, emacs_tags_index, emacs_tags, - emacs_tags_slots, 10, EMACS_TAG_BLOCK *); + emacs_tags_slots, 10, EMACS_TAG_BLOCK *); else { free (block->filename); @@ -462,7 +447,7 @@ static void fatal_file_error (filename) char *filename; { - fprintf (stderr, "Couldn't manipulate the file %s.\n", filename); + fprintf (stderr, _("Couldn't manipulate the file %s.\n"), filename); exit (2); } |