121975Sdist /* 221975Sdist * Copyright (c) 1980 Regents of the University of California. 321975Sdist * All rights reserved. The Berkeley software License Agreement 421975Sdist * specifies the terms and conditions for redistribution. 521975Sdist * 6*24677Smckusick * @(#)indent_globs.h 5.4 (Berkeley) 09/10/85 721975Sdist */ 88802Smckusick 924454Smckusick /*- 108802Smckusick 118802Smckusick Copyright (C) 1976 128802Smckusick by the 138802Smckusick Board of Trustees 148802Smckusick of the 158802Smckusick University of Illinois 168802Smckusick 178802Smckusick All rights reserved 188802Smckusick 198802Smckusick FILE NAME: 208802Smckusick indent_globs.h 218802Smckusick 228802Smckusick PURPOSE: 238802Smckusick This include file contains the declarations for all global variables 248802Smckusick used in indent. 258802Smckusick 268802Smckusick GLOBALS: 278802Smckusick The names of all of the variables will not be repeated here. The 288802Smckusick declarations start on the next page. 298802Smckusick 308802Smckusick FUNCTIONS: 318802Smckusick None 3224454Smckusick */ 3324454Smckusick 3424454Smckusick #include <stdio.h> 3524454Smckusick 3624454Smckusick #define BACKSLASH '\\' 3724454Smckusick #define bufsize 600 /* size of internal buffers */ 3824454Smckusick #define inp_bufs 600 /* size of input buffer */ 3924454Smckusick #define sc_size 5000 /* size of save_com buffer */ 4024454Smckusick #define label_offset 2 /* number of levels a label is placed to left of code 418802Smckusick */ 428802Smckusick 438802Smckusick #define tabsize 8 /* the size of a tab */ 4424454Smckusick #define tabmask 0177770 /* mask used when figuring length of lines with tabs */ 458802Smckusick 468802Smckusick 478802Smckusick #define false 0 488802Smckusick #define true 1 498802Smckusick 508802Smckusick 5124454Smckusick FILE *input; /* the fid for the input file */ 5224454Smckusick FILE *output; /* the output file */ 538802Smckusick 5424454Smckusick char labbuf[bufsize]; /* buffer for label */ 558802Smckusick char *s_lab; /* start ... */ 568802Smckusick char *e_lab; /* .. and end of stored label */ 578802Smckusick 5824454Smckusick char codebuf[bufsize]; /* buffer for code section */ 598802Smckusick char *s_code; /* start ... */ 608802Smckusick char *e_code; /* .. and end of stored code */ 618802Smckusick 6224454Smckusick char combuf[bufsize]; /* buffer for comments */ 638802Smckusick char *s_com; /* start ... */ 648802Smckusick char *e_com; /* ... and end of stored comments */ 658802Smckusick 6624454Smckusick char in_buffer[inp_bufs]; /* input buffer */ 678802Smckusick char *buf_ptr; /* ptr to next character to be taken from in_buffer */ 688802Smckusick char *buf_end; /* ptr to first after last char in in_buffer */ 698802Smckusick 7024454Smckusick char save_com[sc_size]; /* input text is saved here when looking for the brace 718802Smckusick after an if, while, etc */ 728802Smckusick char *sc_end; /* pointer into save_com buffer */ 738802Smckusick 748802Smckusick char *bp_save; /* saved value of buf_ptr when taking input from 758802Smckusick save_com */ 768802Smckusick char *be_save; /* similarly saved value of buf_end */ 778802Smckusick 7824454Smckusick char token[bufsize]; /* the last token scanned */ 798802Smckusick 808802Smckusick 818802Smckusick 8224454Smckusick int blanklines_after_declarations; 8324454Smckusick int blanklines_before_blockcomments; 8424454Smckusick int blanklines_after_procs; 8524454Smckusick int swallow_optional_blanklines; 8624454Smckusick int n_real_blanklines; 8724454Smckusick int prefix_blankline_requested; 8824454Smckusick int postfix_blankline_requested; 8924454Smckusick int break_comma; /* when true and not in parens, break after a comma */ 908802Smckusick int btype_2; /* when true, brace should be on same line as if, 918802Smckusick while, etc */ 9224454Smckusick float case_ind; /* indentation level to be used for a "case n:" */ 938802Smckusick int code_lines;/* count of lines with code */ 948802Smckusick int had_eof; /* set to true when input is exhausted */ 958802Smckusick int line_no; /* the current line number. */ 968802Smckusick int max_col; /* the maximum allowable line length */ 97*24677Smckusick int pointer_as_binop; /* when true, "->" is treated as a binary 98*24677Smckusick operator (giving, e.g., "p -> f") */ 998802Smckusick int verbose; /* when true, non-essential error messages are printed 1008802Smckusick */ 10124454Smckusick int cuddle_else; /* true if else should cuddle up to '}' */ 10224454Smckusick int star_comment_cont; /* true iff comment continuation lines should 10324454Smckusick have stars at the beginning of each line. 10424454Smckusick */ 10524454Smckusick int comment_delimiter_on_blankline; 10624454Smckusick int troff; /* true iff were generating troff input */ 10724454Smckusick int procnames_start_line; /* if true, the names of procedures being 10824454Smckusick defined get placed in column 1 (ie. a 10924454Smckusick newline is placed between the type of the 11024454Smckusick procedure and its name) */ 11124454Smckusick int proc_calls_space; /* If true, procedure calls look like: 11224454Smckusick foo(bar) rather than foo (bar) */ 11324454Smckusick int format_col1_comments; /* If comments which start in column 1 are to 11424454Smckusick be magically reformatted (just like comments that 11524454Smckusick begin in later columns) */ 11624454Smckusick int inhibit_formatting; /* true if INDENT OFF is in effect */ 11724454Smckusick int suppress_blanklines; /* set iff following blanklines should be 11824454Smckusick suppressed */ 11924454Smckusick int continuation_indent; /* set to the indentation between the edge of 12024454Smckusick code and continuation lines */ 12124454Smckusick int lineup_to_parens; /* if true, continued code within parens will 12224454Smckusick be lined up to the open paren */ 12324454Smckusick int block_comment_max_col; 12424454Smckusick 12524454Smckusick 12624454Smckusick struct parser_state { 12724454Smckusick int last_token; 12824454Smckusick int p_stack[50]; /* this is the parsers stack */ 12924454Smckusick int il[50]; /* this stack stores indentation levels */ 13024454Smckusick float cstk[50]; /* used to store case stmt indentation 13124454Smckusick * levels */ 13224454Smckusick int box_com; /* set to true when we are in a "boxed" 13324454Smckusick * comment. In that case, the first 13424454Smckusick * non-blank char should be lined up with 13524454Smckusick * the / in /* */ 13624454Smckusick int comment_delta, 13724454Smckusick n_comment_delta; 13824454Smckusick int cast_mask; /* indicates which close parens close off 13924454Smckusick * casts */ 14024454Smckusick int sizeof_mask; /* indicates which close parens close off 14124454Smckusick sizeof''s */ 14224454Smckusick int block_init; /* true iff inside a block initialization */ 14324454Smckusick int last_nl; /* this is true if the last thing scanned 14424454Smckusick * was a newline */ 14524454Smckusick int in_or_st; /* Will be true iff there has been a 14624454Smckusick * declarator (e.g. int or char) and no 14724454Smckusick * left paren since the last semicolon. 14824454Smckusick * When true, a '{' is starting a 14924454Smckusick * structure definition or an 15024454Smckusick * initialization list */ 15124454Smckusick int bl_line; /* set to 1 by dump_line if the line is 15224454Smckusick * blank */ 15324454Smckusick int col_1; /* set to true if the last token started 15424454Smckusick * in column 1 */ 15524454Smckusick int com_col; /* this is the column in which the current 15624454Smckusick * coment should start */ 15724454Smckusick int com_ind; /* the column in which comments to the 15824454Smckusick * right of code should start */ 15924454Smckusick int com_lines; /* the number of lines with comments, set 16024454Smckusick * by dump_line */ 16124454Smckusick int dec_nest; /* current nesting level for structure or 16224454Smckusick * init */ 16324454Smckusick int decl_com_ind; /* the column in which comments after 16424454Smckusick * declarations should be put */ 16524454Smckusick int decl_on_line; /* set to true if this line of code has 16624454Smckusick * part of a declaration on it */ 16724454Smckusick int i_l_follow; /* the level to which ind_level should be 16824454Smckusick * set after the current line is printed */ 16924454Smckusick int in_decl; /* set to true when we are in a 17024454Smckusick * declaration stmt. The processing of 17124454Smckusick * braces is then slightly different */ 17224454Smckusick int in_stmt; /* set to 1 while in a stmt */ 17324454Smckusick int ind_level; /* the current indentation level */ 17424454Smckusick int ind_size; /* the size of one indentation level */ 17524454Smckusick int ind_stmt; /* set to 1 if next line should have an 17624454Smckusick * extra indentation level because we are 17724454Smckusick * in the middle of a stmt */ 17824454Smckusick int last_u_d; /* set to true after scanning a token 17924454Smckusick * which forces a following operator to be 18024454Smckusick * unary */ 18124454Smckusick int leave_comma; /* if true, never break declarations after 18224454Smckusick * commas */ 18324454Smckusick int ljust_decl; /* true if declarations should be left 18424454Smckusick * justified */ 18524454Smckusick int out_coms; /* the number of comments processed, set 18624454Smckusick * by pr_comment */ 18724454Smckusick int out_lines; /* the number of lines written, set by 18824454Smckusick * dump_line */ 18924454Smckusick int p_l_follow; /* used to remember how to indent 19024454Smckusick * following statement */ 19124454Smckusick int paren_level; /* parenthesization level. used to indent 19224454Smckusick * within stmts */ 19324454Smckusick short paren_indents[20]; /* column positions of each paren */ 19424454Smckusick int pcase; /* set to 1 if the current line label is a 19524454Smckusick * case. It is printed differently from 19624454Smckusick * a regular label */ 19724454Smckusick int search_brace; /* set to true by parse when it is 19824454Smckusick * necessary to buffer up all info up to 19924454Smckusick * the start of a stmt after an if, while, 20024454Smckusick * etc */ 20124454Smckusick int unindent_displace; /* comments not to the right of 20224454Smckusick * code will be placed this many 20324454Smckusick * indentation levels to the left 20424454Smckusick * of code */ 20524454Smckusick int use_ff; /* set to one if the current line should 20624454Smckusick * be terminated with a form feed */ 20724454Smckusick int want_blank; /* set to true when the following token 20824454Smckusick * should be prefixed by a blank. (Said 20924454Smckusick * prefixing is ignored in some cases.) */ 21024454Smckusick int else_if; /* True iff else if pairs should be 21124454Smckusick * handled specially */ 21224454Smckusick int decl_indent; /* column to indent declared identifiers 21324454Smckusick * to */ 21424454Smckusick int its_a_keyword; 21524454Smckusick int sizeof_keyword; 21624454Smckusick int dumped_decl_indent; 21724454Smckusick float case_indent; /* The distance to indent case labels from 21824454Smckusick * the switch statement */ 21924454Smckusick int in_parameter_declaration; 22024454Smckusick int indent_parameters; 22124454Smckusick int tos; /* pointer to top of stack */ 22224454Smckusick char procname[100]; /* The name of the current procedure */ 22324454Smckusick int just_saw_decl; 22424454Smckusick } ps; 22524454Smckusick 22624454Smckusick int ifdef_level; 22724454Smckusick struct parser_state state_stack[5]; 22824454Smckusick struct parser_state match_state[5]; 229