📄 makeinfo.c
字号:
fprintf (stderr, format, a1, a2, a3, a4, a5, a6, a7, a8);#endif /* not VA_FPRINTF */ va_end (ap); putc ('\n', stderr);}/* Just like error (), but print the line number as well. */void#if defined (VA_FPRINTF) && __STDC__line_error (char *format, ...)#elseline_error (format, va_alist) char *format; va_dcl#endif{#ifdef VA_FPRINTF va_list ap;#endif remember_error (); fprintf (stderr, "%s:%d: ", input_filename, line_number); VA_START (ap, format);#ifdef VA_FPRINTF VA_FPRINTF (stderr, format, ap);#else fprintf (stderr, format, a1, a2, a3, a4, a5, a6, a7, a8);#endif /* not VA_FPRINTF */ va_end (ap); fprintf (stderr, ".\n");}void#if defined (VA_FPRINTF) && __STDC__warning (char *format, ...)#elsewarning (format, va_alist) char *format; va_dcl#endif{#ifdef VA_FPRINTF va_list ap;#endif if (print_warnings) { fprintf (stderr, _("%s:%d: warning: "), input_filename, line_number); VA_START (ap, format);#ifdef VA_FPRINTF VA_FPRINTF (stderr, format, ap);#else fprintf (stderr, format, a1, a2, a3, a4, a5, a6, a7, a8);#endif /* not VA_FPRINTF */ va_end (ap); fprintf (stderr, ".\n"); }}/* Remember that an error has been printed. If more than max_error_level have been printed, then exit the program. */voidremember_error (){ errors_printed++; if (max_error_level && (errors_printed > max_error_level)) { fprintf (stderr, _("Too many errors! Gave up.\n")); flush_file_stack (); cm_bye (); exit (FATAL); }}/* **************************************************************** *//* *//* Main () Start of code *//* *//* **************************************************************** *//* For each file mentioned in the command line, process it, turning Texinfo commands into wonderfully formatted output text. */intmain (argc, argv) int argc; char **argv;{ extern int errors_printed; char *filename_part (); int c, ind; int reading_from_stdin = 0; /* The name of this program is the last filename in argv[0]. */ progname = filename_part (argv[0]);#ifdef HAVE_SETLOCALE /* Do not use LC_ALL, because LC_NUMERIC screws up the scanf parsing of the argument to @multicolumn. */ setlocale (LC_TIME, "");#ifdef HAVE_LC_MESSAGES setlocale (LC_MESSAGES, "");#endif#endif /* Set the text message domain. */ bindtextdomain (PACKAGE, LOCALEDIR); textdomain (PACKAGE); /* Parse argument flags from the input line. */ while ((c = getopt_long (argc, argv, "D:e:E:f:I:o:p:P:r:s:U:V", long_options, &ind)) != EOF) { if (c == 0 && long_options[ind].flag == 0) c = long_options[ind].val; switch (c) { case 'D': case 'U': /* User specified variable to set or clear. */ handle_variable_internal ((c == 'D') ? SET : CLEAR, optarg); break; case 'e': /* User specified error level. */ if (sscanf (optarg, "%d", &max_error_level) != 1) { fprintf (stderr, _("%s: %s arg must be numeric, not `%s'.\n"), "--error-limit", progname, optarg); usage (stderr, FATAL); } break; case 'E': /* User specified a macro expansion output file. */ if (!macro_expansion_output_stream) { macro_expansion_filename = optarg; macro_expansion_output_stream = strcmp (optarg, "-") == 0 ? stdout : fopen (optarg, "w"); if (!macro_expansion_output_stream) error (_("Couldn't open macro expansion output `%s'"), optarg); } else error (_("Cannot specify more than one macro expansion output")); break; case 'f': /* User specified fill_column. */ if (sscanf (optarg, "%d", &fill_column) != 1) { fprintf (stderr, _("%s: %s arg must be numeric, not `%s'.\n"), "--fill-column", progname, optarg); usage (FATAL); } break; case 'F': force++; /* Do not remove erroneous output. */ break; case 'h': usage (NO_ERROR); break; case 'I': /* Append user-specified dir to include file path. */ if (!include_files_path) include_files_path = xstrdup ("."); include_files_path = (char *) xrealloc (include_files_path, 2 + strlen (include_files_path) + strlen (optarg)); strcat (include_files_path, ":"); strcat (include_files_path, optarg); break; case 'o': /* User specified output file. */ command_output_filename = xstrdup (optarg); break; case 'p': /* User specified paragraph indent (paragraph_start_index). */ if (set_paragraph_indent (optarg) < 0) { fprintf (stderr, _("%s: --paragraph-indent arg must be numeric/`none'/`asis', not `%s'.\n"), progname, optarg); usage (FATAL); } break; case 'P': /* Prepend user-specified include dir to include path. */ if (!include_files_path) { include_files_path = xstrdup (optarg); include_files_path = (char *) xrealloc (include_files_path, strlen (include_files_path) + 3); /* 3 for ":.\0" */ strcat (include_files_path, ":."); } else { char *tmp = xstrdup (include_files_path); include_files_path = (char *) xrealloc (include_files_path, strlen (include_files_path) + strlen (optarg) + 2); /* 2 for ":\0" */ strcpy (include_files_path, optarg); strcat (include_files_path, ":"); strcat (include_files_path, tmp); free (tmp); } break; case 'r': /* User specified reference warning limit. */ if (sscanf (optarg, "%d", &reference_warning_limit) != 1) { fprintf (stderr, _("%s: %s arg must be numeric, not `%s'.\n"), "--reference-limit", progname, optarg); usage (FATAL); } break; case 's': /* User specified footnote style. */ if (set_footnote_style (optarg) < 0) { fprintf (stderr, _("%s: --footnote-style arg must be `separate' or `end', not `%s'.\n"), progname, optarg); usage (FATAL); } footnote_style_preset = 1; break; case 'V': /* User requested version info. */ print_version_info (); printf (_("Copyright (C) %s Free Software Foundation, Inc.\n\There is NO warranty. You may redistribute this software\n\under the terms of the GNU General Public License.\n\For more information about these matters, see the files named COPYING.\n"), "1998"); exit (NO_ERROR); break; case '?': usage (FATAL); break; } } if (optind == argc) { /* Check to see if input is a file. If so, process that. */ if (!isatty (fileno (stdin))) reading_from_stdin = 1; else { fprintf (stderr, _("%s: missing file argument.\n"), progname); usage (FATAL); } } /* If the user has specified --no-headers, this should imply --no-split. Do that here. I think it might also imply that we should ignore the setfilename at the top of the file, but this might break some FSF things, so I will hold off on that. */ if (no_headers) { splitting = 0; /* If the user has not specified an output file, use stdout. */ if (!command_output_filename) command_output_filename = xstrdup ("-"); } if (verbose_mode) print_version_info (); /* Remaining arguments are file names of texinfo files. Convert them, one by one. */ if (!reading_from_stdin) { while (optind != argc) convert_from_file (argv[optind++]); } else convert_from_stream (stdin, "stdin"); if (errors_printed) return (SYNTAX); else return (NO_ERROR);}/* Display the version info of this invocation of Makeinfo. */voidprint_version_info (){ printf ("makeinfo (GNU %s %s) %d.%d\n", PACKAGE, VERSION, major_version, minor_version);}/* If EXIT_VALUE is zero, print the full usage message to stdout. Otherwise, just say to use --help for more info. Then exit with EXIT_VALUE. */voidusage (exit_value) int exit_value;{ if (exit_value != 0) fprintf (stderr, _("Try `%s --help' for more information.\n"), progname); else printf (_("Usage: %s [OPTION]... TEXINFO-FILE...\n\\n\Translate Texinfo source documentation to a format suitable for reading\n\with GNU Info.\n\\n\Options:\n\-D VAR define a variable, as with @set.\n\-E MACRO-OFILE process macros only, output texinfo source.\n\-I DIR append DIR to the @include directory search path.\n\-P DIR prepend DIR to the @include directory search path.\n\-U VAR undefine a variable, as with @clear.\n\--error-limit NUM quit after NUM errors (default %d).\n\--fill-column NUM break lines at NUM characters (default %d).\n\--footnote-style STYLE output footnotes according to STYLE:\n\ `separate' to place footnotes in their own node,\n\ `end' to place the footnotes at the end of\n\ the node in which they are defined (the default).\n\--force preserve output even if errors.\n\--help display this help and exit.\n\--no-validate suppress node cross-reference validation.\n\--no-warn suppress warnings (but not errors).\n\--no-split suppress splitting of large files.\n\--no-headers suppress node separators and Node: Foo headers.\n\--output FILE, -o FILE output to FILE, and ignore any @setfilename.\n\--paragraph-indent VAL indent paragraphs with VAL spaces (default %d).\n\ if VAL is `none', do not indent; if VAL is `asis',\n\ preserve any existing indentation.\n\--reference-limit NUM complain about at most NUM references (default %d).\n\--verbose report about what is being done.\n\--version display version information and exit.\n\\n\Email bug reports to bug-texinfo@gnu.org.\n\"), progname, max_error_level, fill_column, paragraph_start_indent, reference_warning_limit); exit (exit_value);}/* Manipulating Lists */typedef struct generic_list { struct generic_list *next;} GENERIC_LIST;/* Reverse the chain of structures in LIST. Output the new head of the chain. You should always assign the output value of this function to something, or you will lose the chain. */GENERIC_LIST *reverse_list (list) register GENERIC_LIST *list;{ register GENERIC_LIST *next; register GENERIC_LIST *prev = (GENERIC_LIST *) NULL; while (list) { next = list->next; list->next = prev; prev = list; list = next; } return (prev);}/* Pushing and Popping Files *//* Find and load the file named FILENAME. Return a pointer to the loaded file, or NULL if it can't be loaded. */char *find_and_load (filename) char *filename;{ struct stat fileinfo; long file_size; int file = -1, count = 0; char *fullpath, *result, *get_file_info_in_path (); result = fullpath = (char *)NULL; fullpath = get_file_info_in_path (filename, include_files_path, &fileinfo); if (!fullpath) goto error_exit; filename = fullpath; file_size = (long) fileinfo.st_size; file = open (filename, O_RDONLY); if (file < 0) goto error_exit; /* Load the file, with enough room for a newline and a null. */ result = xmalloc (file_size + 2); /* VMS stat lies about the st_size value. The actual number of readable bytes is always less than this value. The arcane mysteries of VMS/RMS are too much to probe, so this hack
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -