📄 indent.h
字号:
/* Copyright (c) 1992, Free Software Foundation, Inc. All rights reserved. Copyright (c) 1985 Sun Microsystems, Inc. Copyright (c) 1980 The Regents of the University of California. Copyright (c) 1976 Board of Trustees of the University of Illinois. All rights reserved. Redistribution and use in source and binary forms are permitted provided that the above copyright notice and this paragraph are duplicated in all such forms and that any documentation, advertising materials, and other materials related to such distribution and use acknowledge that the software was developed by the University of California, Berkeley, the University of Illinois, Urbana, and Sun Microsystems, Inc. The name of either University or Sun Microsystems may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */#define BACKSLASH '\\'enum codes{ code_eof = 0, /* end of file */ newline, lparen, /* '(' or '['. Also '{' in an initialization. */ rparen, /* ')' or ']'. Also '}' in an initialization. */ unary_op, binary_op, postop, question, casestmt, colon, semicolon, lbrace, rbrace, ident, /* string or char literal, identifier, number */ comma, comment, swstmt, preesc, /* '#'. */ form_feed, decl, sp_paren, /* if, for, or while token */ sp_nparen, ifstmt, whilestmt, forstmt, stmt, stmtl, elselit, dolit, dohead, dostmt, ifhead, elsehead, period};enum rwcodes{ rw_none, rw_break, rw_switch, rw_case, rw_struct_like, /* struct, enum, union */ rw_decl, rw_sp_paren, /* if, while, for */ rw_sp_nparen, /* do, else */ rw_sizeof, rw_return};#define false 0#define true 1/* Name of input file. */extern char *in_name;extern char *in_prog; /* pointer to the null-terminated input program *//* Point to the position in the input program which we are currently looking at. */extern char *in_prog_pos;/* Point to the start of the current line. */extern char *cur_line;/* Size of the input program, not including the ' \n\0' we add at the end */extern unsigned int in_prog_size;extern FILE *output; /* the output file */#define check_code_size \ if (e_code >= l_code) { \ register nsize = l_code-s_code+400; \ codebuf = (char *) realloc(codebuf, nsize); \ e_code = codebuf + (e_code-s_code) + 1; \ l_code = codebuf + nsize - 5; \ s_code = codebuf + 1; \ }#define check_com_size \ if (e_com >= l_com) { \ register nsize = l_com-s_com+400; \ combuf = (char *) realloc(combuf, nsize); \ e_com = combuf + (e_com-s_com) + 1; \ l_com = combuf + nsize - 5; \ s_com = combuf + 1; \ }#define check_lab_size \ if (e_lab >= l_lab) { \ register nsize = l_lab-s_lab+400; \ labbuf = (char *) realloc(labbuf, nsize); \ e_lab = labbuf + (e_lab-s_lab) + 1; \ l_lab = labbuf + nsize - 5; \ s_lab = labbuf + 1; \ }extern char *labbuf; /* buffer for label */extern char *s_lab; /* start ... */extern char *e_lab; /* .. and end of stored label */extern char *l_lab; /* limit of label buffer */extern char *codebuf; /* buffer for code section */extern char *s_code; /* start ... */extern char *e_code; /* .. and end of stored code */extern char *l_code; /* limit of code section */extern char *combuf; /* buffer for comments */extern char *s_com; /* start ... */extern char *e_com; /* ... and end of stored comments */extern char *l_com; /* limit of comment buffer */extern char *buf_ptr; /* ptr to next character to be taken from in_buffer */extern char *buf_end; /* ptr to first after last char in in_buffer *//* pointer to the token that lexi() has just found */extern char *token;/* points to the first char after the end of token */extern char *token_end;/* Functions from lexi.c */enum codes lexi ();/* Used to keep track of buffers. */struct buf{ char *ptr; /* points to the start of the buffer */ char *end; /* points to the character beyond the last one (e.g. is equal to ptr if the buffer is empty). */ int size; /* how many chars are currently allocated. */};/* Buffer in which to save a comment which occurs between an if(), while(), etc., and the statement following it. Note: the fact that we point into this buffer, and that we might realloc() it (via the need_chars macro) is a bad thing (since when the buffer is realloc'd its address might change, making any pointers into it point to garbage), but since the filling of the buffer (hence the need_chars) and the using of the buffer (where buf_ptr points into it) occur at different times, we can get away with it (it would not be trivial to fix). */extern struct buf save_com;extern char *bp_save; /* saved value of buf_ptr when taking input from save_com */extern char *be_save; /* similarly saved value of buf_end */extern int use_stdout;extern int pointer_as_binop;extern int blanklines_after_declarations;extern int blanklines_before_blockcomments;extern int blanklines_after_procs;extern int blanklines_around_conditional_compilation;extern int swallow_optional_blanklines;extern int n_real_blanklines;extern int prefix_blankline_requested;extern int postfix_blankline_requested;extern int break_comma; /* when true and not in parens, break after a comma */extern int found_err; /* flag set in diag() on error */extern int else_or_endif;extern int di_stack_alloc;extern int *di_stack;/* number of spaces to indent braces from the suround if, while, etc. in -bl (bype_2 == 0) code */extern int brace_indent;extern int btype_2; /* when true, brace should be on same line as if, while, etc *//* If true, a space is inserted between if, while, or for, and a semicolon for example while (*p++ == ' ') ; */extern int space_sp_semicolon;/* True if a #else or #endif has been encountered. */extern int else_or_endif;extern int case_ind; /* indentation level to be used for a "case n:" in spaces */extern int code_lines; /* count of lines with code *//* the number of comments processed, set by pr_comment. */extern int out_coms;extern int out_lines; /* the number of lines written, set by dump_line */extern int com_lines; /* the number of lines with comments, set by dump_line */extern int had_eof; /* set to true when input is exhausted */extern int line_no; /* the current line number. */extern int max_col; /* the maximum allowable line length */extern int verbose; /* when true, non-essential error messages are printed */extern int cuddle_else; /* true if else should cuddle up to '}' */extern int star_comment_cont; /* true iff comment continuation lines should have stars at the beginning of each line. */extern int comment_delimiter_on_blankline;extern int troff; /* true iff were generating troff input */extern int procnames_start_line; /* if true, the names of procedures being defined get placed in column 1 (ie. a newline is placed between the type of the
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -