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*24454Smckusick * @(#)indent_globs.h 5.2 (Berkeley) 08/28/85 721975Sdist */ 88802Smckusick 9*24454Smckusick /*- 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 32*24454Smckusick */ 33*24454Smckusick 34*24454Smckusick #include <stdio.h> 35*24454Smckusick 36*24454Smckusick #define BACKSLASH '\\' 37*24454Smckusick #define bufsize 600 /* size of internal buffers */ 38*24454Smckusick #define inp_bufs 600 /* size of input buffer */ 39*24454Smckusick #define sc_size 5000 /* size of save_com buffer */ 40*24454Smckusick #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 */ 44*24454Smckusick #define tabmask 0177770 /* mask used when figuring length of lines with tabs */ 458802Smckusick 468802Smckusick 478802Smckusick #define false 0 488802Smckusick #define true 1 498802Smckusick 508802Smckusick 51*24454Smckusick FILE *input; /* the fid for the input file */ 52*24454Smckusick FILE *output; /* the output file */ 538802Smckusick 54*24454Smckusick char labbuf[bufsize]; /* buffer for label */ 558802Smckusick char *s_lab; /* start ... */ 568802Smckusick char *e_lab; /* .. and end of stored label */ 578802Smckusick 58*24454Smckusick char codebuf[bufsize]; /* buffer for code section */ 598802Smckusick char *s_code; /* start ... */ 608802Smckusick char *e_code; /* .. and end of stored code */ 618802Smckusick 62*24454Smckusick char combuf[bufsize]; /* buffer for comments */ 638802Smckusick char *s_com; /* start ... */ 648802Smckusick char *e_com; /* ... and end of stored comments */ 658802Smckusick 66*24454Smckusick 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 70*24454Smckusick 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 78*24454Smckusick char token[bufsize]; /* the last token scanned */ 798802Smckusick 808802Smckusick 818802Smckusick 82*24454Smckusick int blanklines_after_declarations; 83*24454Smckusick int blanklines_before_blockcomments; 84*24454Smckusick int blanklines_after_procs; 85*24454Smckusick int swallow_optional_blanklines; 86*24454Smckusick int n_real_blanklines; 87*24454Smckusick int prefix_blankline_requested; 88*24454Smckusick int postfix_blankline_requested; 89*24454Smckusick 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 */ 92*24454Smckusick 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 */ 978802Smckusick int verbose; /* when true, non-essential error messages are printed 988802Smckusick */ 99*24454Smckusick int cuddle_else; /* true if else should cuddle up to '}' */ 100*24454Smckusick int star_comment_cont; /* true iff comment continuation lines should 101*24454Smckusick have stars at the beginning of each line. 102*24454Smckusick */ 103*24454Smckusick int comment_delimiter_on_blankline; 104*24454Smckusick int troff; /* true iff were generating troff input */ 105*24454Smckusick int procnames_start_line; /* if true, the names of procedures being 106*24454Smckusick defined get placed in column 1 (ie. a 107*24454Smckusick newline is placed between the type of the 108*24454Smckusick procedure and its name) */ 109*24454Smckusick int proc_calls_space; /* If true, procedure calls look like: 110*24454Smckusick foo(bar) rather than foo (bar) */ 111*24454Smckusick int format_col1_comments; /* If comments which start in column 1 are to 112*24454Smckusick be magically reformatted (just like comments that 113*24454Smckusick begin in later columns) */ 114*24454Smckusick int inhibit_formatting; /* true if INDENT OFF is in effect */ 115*24454Smckusick int suppress_blanklines; /* set iff following blanklines should be 116*24454Smckusick suppressed */ 117*24454Smckusick int continuation_indent; /* set to the indentation between the edge of 118*24454Smckusick code and continuation lines */ 119*24454Smckusick int lineup_to_parens; /* if true, continued code within parens will 120*24454Smckusick be lined up to the open paren */ 121*24454Smckusick int block_comment_max_col; 122*24454Smckusick 123*24454Smckusick 124*24454Smckusick struct parser_state { 125*24454Smckusick int last_token; 126*24454Smckusick int p_stack[50]; /* this is the parsers stack */ 127*24454Smckusick int il[50]; /* this stack stores indentation levels */ 128*24454Smckusick float cstk[50]; /* used to store case stmt indentation 129*24454Smckusick * levels */ 130*24454Smckusick int box_com; /* set to true when we are in a "boxed" 131*24454Smckusick * comment. In that case, the first 132*24454Smckusick * non-blank char should be lined up with 133*24454Smckusick * the / in /* */ 134*24454Smckusick int comment_delta, 135*24454Smckusick n_comment_delta; 136*24454Smckusick int cast_mask; /* indicates which close parens close off 137*24454Smckusick * casts */ 138*24454Smckusick int sizeof_mask; /* indicates which close parens close off 139*24454Smckusick sizeof''s */ 140*24454Smckusick int block_init; /* true iff inside a block initialization */ 141*24454Smckusick int last_nl; /* this is true if the last thing scanned 142*24454Smckusick * was a newline */ 143*24454Smckusick int in_or_st; /* Will be true iff there has been a 144*24454Smckusick * declarator (e.g. int or char) and no 145*24454Smckusick * left paren since the last semicolon. 146*24454Smckusick * When true, a '{' is starting a 147*24454Smckusick * structure definition or an 148*24454Smckusick * initialization list */ 149*24454Smckusick int bl_line; /* set to 1 by dump_line if the line is 150*24454Smckusick * blank */ 151*24454Smckusick int col_1; /* set to true if the last token started 152*24454Smckusick * in column 1 */ 153*24454Smckusick int com_col; /* this is the column in which the current 154*24454Smckusick * coment should start */ 155*24454Smckusick int com_ind; /* the column in which comments to the 156*24454Smckusick * right of code should start */ 157*24454Smckusick int com_lines; /* the number of lines with comments, set 158*24454Smckusick * by dump_line */ 159*24454Smckusick int dec_nest; /* current nesting level for structure or 160*24454Smckusick * init */ 161*24454Smckusick int decl_com_ind; /* the column in which comments after 162*24454Smckusick * declarations should be put */ 163*24454Smckusick int decl_on_line; /* set to true if this line of code has 164*24454Smckusick * part of a declaration on it */ 165*24454Smckusick int i_l_follow; /* the level to which ind_level should be 166*24454Smckusick * set after the current line is printed */ 167*24454Smckusick int in_decl; /* set to true when we are in a 168*24454Smckusick * declaration stmt. The processing of 169*24454Smckusick * braces is then slightly different */ 170*24454Smckusick int in_stmt; /* set to 1 while in a stmt */ 171*24454Smckusick int ind_level; /* the current indentation level */ 172*24454Smckusick int ind_size; /* the size of one indentation level */ 173*24454Smckusick int ind_stmt; /* set to 1 if next line should have an 174*24454Smckusick * extra indentation level because we are 175*24454Smckusick * in the middle of a stmt */ 176*24454Smckusick int last_u_d; /* set to true after scanning a token 177*24454Smckusick * which forces a following operator to be 178*24454Smckusick * unary */ 179*24454Smckusick int leave_comma; /* if true, never break declarations after 180*24454Smckusick * commas */ 181*24454Smckusick int ljust_decl; /* true if declarations should be left 182*24454Smckusick * justified */ 183*24454Smckusick int out_coms; /* the number of comments processed, set 184*24454Smckusick * by pr_comment */ 185*24454Smckusick int out_lines; /* the number of lines written, set by 186*24454Smckusick * dump_line */ 187*24454Smckusick int p_l_follow; /* used to remember how to indent 188*24454Smckusick * following statement */ 189*24454Smckusick int paren_level; /* parenthesization level. used to indent 190*24454Smckusick * within stmts */ 191*24454Smckusick short paren_indents[20]; /* column positions of each paren */ 192*24454Smckusick int pcase; /* set to 1 if the current line label is a 193*24454Smckusick * case. It is printed differently from 194*24454Smckusick * a regular label */ 195*24454Smckusick int search_brace; /* set to true by parse when it is 196*24454Smckusick * necessary to buffer up all info up to 197*24454Smckusick * the start of a stmt after an if, while, 198*24454Smckusick * etc */ 199*24454Smckusick int unindent_displace; /* comments not to the right of 200*24454Smckusick * code will be placed this many 201*24454Smckusick * indentation levels to the left 202*24454Smckusick * of code */ 203*24454Smckusick int use_ff; /* set to one if the current line should 204*24454Smckusick * be terminated with a form feed */ 205*24454Smckusick int want_blank; /* set to true when the following token 206*24454Smckusick * should be prefixed by a blank. (Said 207*24454Smckusick * prefixing is ignored in some cases.) */ 208*24454Smckusick int else_if; /* True iff else if pairs should be 209*24454Smckusick * handled specially */ 210*24454Smckusick int decl_indent; /* column to indent declared identifiers 211*24454Smckusick * to */ 212*24454Smckusick int its_a_keyword; 213*24454Smckusick int sizeof_keyword; 214*24454Smckusick int dumped_decl_indent; 215*24454Smckusick float case_indent; /* The distance to indent case labels from 216*24454Smckusick * the switch statement */ 217*24454Smckusick int in_parameter_declaration; 218*24454Smckusick int indent_parameters; 219*24454Smckusick int tos; /* pointer to top of stack */ 220*24454Smckusick char procname[100]; /* The name of the current procedure */ 221*24454Smckusick int just_saw_decl; 222*24454Smckusick } ps; 223*24454Smckusick 224*24454Smckusick int ifdef_level; 225*24454Smckusick struct parser_state state_stack[5]; 226*24454Smckusick struct parser_state match_state[5]; 227