📄 makeinfo.c
字号:
/* Makeinfo -- convert Texinfo source files into Info files. $Id: makeinfo.c,v 1.11 1998/07/06 21:58:00 law Exp $ Copyright (C) 1987, 92, 93, 94, 95, 96, 97, 98 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 the Free Software Foundation; either version 2, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Makeinfo was authored by Brian Fox (bfox@ai.mit.edu). *//* Indent #pragma so that older Cpp's don't try to parse it. */#ifdef _AIX #pragma alloca#endif /* _AIX */int major_version = 1;int minor_version = 68;#include "system.h"#include "getopt.h"#ifdef TM_IN_SYS_TIME#include <sys/time.h>#else#include <time.h>#endif /* !TM_IN_SYS_TIME */#ifdef __GNUC__# undef alloca# define alloca __builtin_alloca#else# ifdef HAVE_ALLOCA_H# include <alloca.h># else# ifndef _AIXchar *alloca ();# endif# endif#endif/* We'd like to take advantage of _doprnt if it's around, a la error.c, but then we'd have no VA_SPRINTF. */#if HAVE_VPRINTF# if __STDC__# include <stdarg.h># define VA_START(args, lastarg) va_start(args, lastarg)# else# include <varargs.h># define VA_START(args, lastarg) va_start(args)# endif# define VA_FPRINTF(file, fmt, ap) vfprintf (file, fmt, ap)# define VA_SPRINTF(str, fmt, ap) vsprintf (str, fmt, ap)#else /* not HAVE_VPRINTF */# define VA_START(args, lastarg)# define va_alist a1, a2, a3, a4, a5, a6, a7, a8# define va_dcl char *a1, *a2, *a3, *a4, *a5, *a6, *a7, *a8;# define va_end(args)#endif/* You can change some of the behavior of Makeinfo by changing the following defines: *//* Define INDENT_PARAGRAPHS_IN_TABLE if you want the paragraphs which appear within an @table, @ftable, or @itemize environment to have standard paragraph indentation. Without this, such paragraphs have no starting indentation. *//* #define INDENT_PARAGRAPHS_IN_TABLE *//* Define DEFAULT_INDENTATION_INCREMENT as an integer which is the amount that @example should increase indentation by. This incremement is used for all insertions which indent the enclosed text. */#define DEFAULT_INDENTATION_INCREMENT 5/* Define PARAGRAPH_START_INDENT to be the amount of indentation that the first lines of paragraphs receive by default, where no other value has been specified. Users can change this value on the command line, with the --paragraph-indent option, or within the texinfo file, with the @paragraphindent command. */#define PARAGRAPH_START_INDENT 3/* Define DEFAULT_PARAGRAPH_SPACING as the number of blank lines that you wish to appear between paragraphs. A value of 1 creates a single blank line between paragraphs. Paragraphs are defined by 2 or more consecutive newlines in the input file (i.e., one or more blank lines). */#define DEFAULT_PARAGRAPH_SPACING 1/* Define HAVE_MACROS to enable the macro facility of Texinfo. Using this facility, users can create their own command procedures with arguments. Must always be defined. */#define HAVE_MACROS#define COMPILING_MAKEINFO#include "makeinfo.h"/* Nonzero means that we are currently hacking the insides of an insertion which would use a fixed width font. */static int in_fixed_width_font = 0;/* Nonzero means that start_paragraph () MUST be called before we pay any attention to close_paragraph () calls. */int must_start_paragraph = 0;/* Nonzero means a string is in execution, as opposed to a file. */static int executing_string = 0;/* Nonzero means a macro string is in execution, as opposed to a file. */static int me_executing_string = 0;#if defined (HAVE_MACROS)/* If non-NULL, this is an output stream to write the full macro expansion of the input text to. The result is another texinfo file, but missing @include, @infoinclude, @macro, and macro invocations. Instead, all of the text is placed within the file. */FILE *macro_expansion_output_stream = (FILE *)NULL;char *macro_expansion_filename;/* Here is a structure used to remember input text strings and offsets within them. */typedef struct { char *pointer; /* Pointer to the input text. */ int offset; /* Offset of the last character output. */} ITEXT;static ITEXT **itext_info = (ITEXT **)NULL;static int itext_size = 0;/* Nonzero means to inhibit writing macro expansions to the output stream, because it has already been written. */int me_inhibit_expansion = 0;ITEXT *remember_itext ();void forget_itext (), me_append_before_this_command ();void append_to_expansion_output (), write_region_to_macro_output ();void maybe_write_itext (), me_execute_string ();#endif /* HAVE_MACROS *//* **************************************************************** *//* *//* Global Variables *//* *//* **************************************************************** *//* Global pointer to argv[0]. */char *progname;/* Return nonzero if STRING is the text at input_text + input_text_offset, else zero. */#define looking_at(string) \ (strncmp (input_text + input_text_offset, string, strlen (string)) == 0)/* And writing to the output. *//* The output file name. */char *output_filename = (char *)NULL;char *pretty_output_filename;/* Name of the output file that the user elected to pass on the command line. Such a name overrides any name found with the @setfilename command. */char *command_output_filename = (char *)NULL;/* A colon separated list of directories to search for files included with @include. This can be controlled with the `-I' option to makeinfo. */char *include_files_path = (char *)NULL;/* Position in the output file. */int output_position;#define INITIAL_PARAGRAPH_SPACE 5000int paragraph_buffer_len = INITIAL_PARAGRAPH_SPACE;/* Nonzero indicates that filling will take place on long lines. */int filling_enabled = 1;/* Nonzero means that words are not to be split, even in long lines. This gets changed for cm_w (). */int non_splitting_words = 0;/* Nonzero indicates that filling a line also indents the new line. */int indented_fill = 0;/* The amount of indentation to add at the starts of paragraphs. 0 means don't change existing indentation at paragraph starts. > 0 is amount to indent new paragraphs by. < 0 means indent to column zero by removing indentation if necessary. This is normally zero, but some people prefer paragraph starts to be somewhat more indented than paragraph bodies. A pretty value for this is 3. */int paragraph_start_indent = PARAGRAPH_START_INDENT;/* Nonzero means that the use of paragraph_start_indent is inhibited. @example uses this to line up the left columns of the example text. A negative value for this variable is incremented each time it is used. @noindent uses this to inhibit indentation for a single paragraph. */int inhibit_paragraph_indentation = 0;/* Indentation that is pending insertion. We have this for hacking lines which look blank, but contain whitespace. We want to treat those as blank lines. */int pending_indent = 0;/* The amount that indentation increases/decreases by. */int default_indentation_increment = DEFAULT_INDENTATION_INCREMENT;/* Nonzero indicates that indentation is temporarily turned off. */int no_indent = 1;/* Nonzero means forcing output text to be flushright. */int force_flush_right = 0;/* Nonzero means that the footnote style for this document was set on the command line, which overrides any other settings. */int footnote_style_preset = 0;/* Nonzero means that we automatically number footnotes that have no specified marker. */int number_footnotes = 1;/* The current footnote number in this node. Each time a new node is started this is reset to 1. */int current_footnote_number = 1;/* Command name in the process of being hacked. */char *command;/* The index in our internal command table of the currently executing command. */int command_index;/* A search string which is used to find a line defining a node. */char node_search_string[] = { '\n', COMMAND_PREFIX, 'n', 'o', 'd', 'e', ' ', 0 };/* A search string which is used to find a line defining a menu. */char menu_search_string[] = { '\n', COMMAND_PREFIX, 'm', 'e', 'n', 'u', 0 };/* A search string which is used to find the first @setfilename. */char setfilename_search[] = { COMMAND_PREFIX, 's', 'e', 't', 'f', 'i', 'l', 'e', 'n', 'a', 'm', 'e', 0 };/* A stack of file information records. If a new file is read in with "@input", we remember the old input file state on this stack. */typedef struct fstack{ struct fstack *next; char *filename; char *text; int size; int offset; int line_number;} FSTACK;FSTACK *filestack = (FSTACK *) NULL;/* Stuff for nodes. *//* The current nodes node name. */char *current_node = (char *)NULL;/* The current nodes section level. */int current_section = 0;/* The filename of the current input file. This is never freed. */char *node_filename = (char *)NULL;/* What we remember for each node. */typedef struct tentry{ struct tentry *next_ent; char *node; /* name of this node. */ char *prev; /* name of "Prev:" for this node. */ char *next; /* name of "Next:" for this node. */ char *up; /* name of "Up:" for this node. */ int position; /* output file position of this node. */ int line_no; /* defining line in source file. */ char *filename; /* The file that this node was found in. */ int touched; /* Nonzero means this node has been referenced. */ int flags; /* Room for growth. Right now, contains 1 bit. */} TAG_ENTRY;/* If node-a has a "Next" for node-b, but node-b has no "Prev" for node-a, we turn on this flag bit in node-b's tag entry. This means that when it is time to validate node-b, we don't report an additional error if there was no "Prev" field. */#define PREV_ERROR 0x1#define NEXT_ERROR 0x2#define UP_ERROR 0x4#define NO_WARN 0x8#define IS_TOP 0x10TAG_ENTRY *tag_table = (TAG_ENTRY *) NULL;/* Values for calling handle_variable_internal (). */#define SET 1#define CLEAR 2#define IFSET 3#define IFCLEAR 4#if defined (HAVE_MACROS)#define ME_RECURSE 0x01#define ME_QUOTE_ARG 0x02/* Macro definitions for user-defined commands. */typedef struct { char *name; /* Name of the macro. */ char **arglist; /* Args to replace when executing. */ char *body; /* Macro body. */ char *source_file; /* File where this macro is defined. */ int source_lineno; /* Line number within FILENAME. */ int inhibited; /* Nonzero means make find_macro () fail. */ int flags; /* ME_RECURSE, ME_QUOTE_ARG, etc. */} MACRO_DEF;void add_macro (), execute_macro ();MACRO_DEF *find_macro (), *delete_macro ();#endif /* HAVE_MACROS *//* Menu reference, *note reference, and validation hacking. *//* The various references that we know about. */enum reftype{ menu_reference, followed_reference};/* A structure to remember references with. A reference to a node is either an entry in a menu, or a cross-reference made with [px]ref. */typedef struct node_ref{ struct node_ref *next; char *node; /* Name of node referred to. */ char *containing_node; /* Name of node containing this reference. */ int line_no; /* Line number where the reference occurs. */ int section; /* Section level where the reference occurs. */ char *filename; /* Name of file where the reference occurs. */ enum reftype type; /* Type of reference, either menu or note. */} NODE_REF;/* The linked list of such structures. */NODE_REF *node_references = (NODE_REF *) NULL;/* Flag which tells us whether to examine menu lines or not. */int in_menu = 0;/* Flag which tells us how to examine menu lines. */int in_detailmenu = 0;/* Nonzero means that we have seen "@top" once already. */int top_node_seen = 0;/* Nonzero means that we have seen a non-"@top" node already. */int non_top_node_seen = 0;/* Flags controlling the operation of the program. *//* Default is to remove output if there were errors. */int force = 0;/* Default is to notify users of bad choices. */int print_warnings = 1;/* Default is to check node references. */int validating = 1;/* Nonzero means do not output "Node: Foo" for node separations. */int no_headers = 0;/* Number of errors that we tolerate on a given fileset. */int max_error_level = 100;/* Maximum number of references to a single node before complaining. */int reference_warning_limit = 1000;/* Nonzero means print out information about what is going on when it is going on. */int verbose_mode = 0;/* Nonzero means to be relaxed about the input file. This is useful when we can successfully format the input, but it doesn't strictly match our somewhat pedantic ideas of correctness. Right now, it affects what @table and @itemize do without arguments. */int allow_lax_format = 0;/* The list of commands that we hack in texinfo. Each one has an associated function. When the command is encountered in the text, the associated function is called with START as the argument. If the function expects arguments in braces, it remembers itself on the stack. When the corresponding close brace is encountered, the function is called with END as the argument. */#define START 0#define END 1typedef struct brace_element{ struct brace_element *next; COMMAND_FUNCTION *proc; int pos, line; int in_fixed_width_font;} BRACE_ELEMENT;BRACE_ELEMENT *brace_stack = (BRACE_ELEMENT *) NULL;extern void do_multitable ();void print_version_info ();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -