1: /*
   2:  * Copyright (c) 1980 Regents of the University of California.
   3:  * All rights reserved.  The Berkeley software License Agreement
   4:  * specifies the terms and conditions for redistribution.
   5:  *
   6:  *	@(#)indent_globs.h	5.4 (Berkeley) 9/10/85
   7:  */
   8: 
   9: /*-
  10: 
  11: 			  Copyright (C) 1976
  12: 				by the
  13: 			  Board of Trustees
  14: 				of the
  15: 			University of Illinois
  16: 
  17: 			 All rights reserved
  18: 
  19: FILE NAME:
  20: 	indent_globs.h
  21: 
  22: PURPOSE:
  23: 	This include file contains the declarations for all global variables
  24: 	used in indent.
  25: 
  26: GLOBALS:
  27: 	The names of all of the variables will not be repeated here.  The
  28: 	declarations start on the next page.
  29: 
  30: FUNCTIONS:
  31: 	None
  32: */
  33: 
  34: #include <stdio.h>
  35: 
  36: #define BACKSLASH '\\'
  37: #define bufsize 600    /* size of internal buffers */
  38: #define inp_bufs 600       /* size of input buffer */
  39: #define sc_size 5000       /* size of save_com buffer */
  40: #define label_offset 2     /* number of levels a label is placed to left of code
  41: 		   */
  42: 
  43: #define tabsize 8  /* the size of a tab */
  44: #define tabmask 0177770    /* mask used when figuring length of lines with tabs */
  45: 
  46: 
  47: #define false 0
  48: #define true  1
  49: 
  50: 
  51: FILE   *input;     /* the fid for the input file */
  52: FILE   *output;    /* the output file */
  53: 
  54: char    labbuf[bufsize];    /* buffer for label */
  55: char   *s_lab;     /* start ... */
  56: char   *e_lab;     /* .. and end of stored label */
  57: 
  58: char    codebuf[bufsize];   /* buffer for code section */
  59: char   *s_code;    /* start ... */
  60: char   *e_code;    /* .. and end of stored code */
  61: 
  62: char    combuf[bufsize];    /* buffer for comments */
  63: char   *s_com;     /* start ... */
  64: char   *e_com;     /* ... and end of stored comments */
  65: 
  66: char    in_buffer[inp_bufs];    /* input buffer */
  67: char   *buf_ptr;   /* ptr to next character to be taken from in_buffer */
  68: char   *buf_end;   /* ptr to first after last char in in_buffer */
  69: 
  70: char    save_com[sc_size];  /* input text is saved here when looking for the brace
  71: 		      after an if, while, etc */
  72: char   *sc_end;    /* pointer into save_com buffer */
  73: 
  74: char   *bp_save;   /* saved value of buf_ptr when taking input from
  75: 		      save_com */
  76: char   *be_save;   /* similarly saved value of buf_end */
  77: 
  78: char    token[bufsize]; /* the last token scanned */
  79: 
  80: 
  81: 
  82: int blanklines_after_declarations;
  83: int blanklines_before_blockcomments;
  84: int blanklines_after_procs;
  85: int swallow_optional_blanklines;
  86: int n_real_blanklines;
  87: int prefix_blankline_requested;
  88: int postfix_blankline_requested;
  89: int     break_comma;    /* when true and not in parens, break after a comma */
  90: int     btype_2;   /* when true, brace should be on same line as if,
  91: 		      while, etc */
  92: float   case_ind;  /* indentation level to be used for a "case n:" */
  93: int     code_lines;/* count of lines with code */
  94: int     had_eof;   /* set to true when input is exhausted */
  95: int     line_no;   /* the current line number. */
  96: int     max_col;   /* the maximum allowable line length */
  97: int     pointer_as_binop;   /* when true, "->" is treated as a binary
  98: 				   operator (giving, e.g., "p -> f") */
  99: int     verbose;   /* when true, non-essential error messages are printed
 100: 		   */
 101: int cuddle_else;        /* true if else should cuddle up to '}' */
 102: int star_comment_cont;  /* true iff comment continuation lines should
 103: 				   have stars at the beginning of each line.
 104: 				   */
 105: int     comment_delimiter_on_blankline;
 106: int     troff;          /* true iff were generating troff input */
 107: int procnames_start_line;   /* if true, the names of procedures being
 108: 				   defined get placed in column 1 (ie. a
 109: 				   newline is placed between the type of the
 110: 				   procedure and its name) */
 111: int proc_calls_space;   /* If true, procedure calls look like:
 112: 				   foo(bar) rather than foo (bar) */
 113: int format_col1_comments;   /* If comments which start in column 1 are to
 114: 				   be magically reformatted (just like comments that
 115: 				   begin in later columns) */
 116: int inhibit_formatting; /* true if INDENT OFF is in effect */
 117: int suppress_blanklines;    /* set iff following blanklines should be
 118: 				   suppressed */
 119: int continuation_indent;    /* set to the indentation between the edge of
 120: 				   code and continuation lines */
 121: int lineup_to_parens;   /* if true, continued code within parens will
 122: 				   be lined up to the open paren */
 123: int block_comment_max_col;
 124: 
 125: 
 126: struct parser_state {
 127:     int         last_token;
 128:     int         p_stack[50];    /* this is the parsers stack */
 129:     int         il[50];     /* this stack stores indentation levels */
 130:     float       cstk[50];   /* used to store case stmt indentation
 131: 				 * levels */
 132:     int         box_com;    /* set to true when we are in a "boxed"
 133: 				 * comment. In that case, the first
 134: 				 * non-blank char should be lined up with
 135: 				 * the / in /* */
 136:     int         comment_delta,
 137:                 n_comment_delta;
 138:     int         cast_mask;  /* indicates which close parens close off
 139: 				 * casts */
 140:     int     sizeof_mask;    /* indicates which close parens close off
 141: 				   sizeof''s */
 142:     int         block_init; /* true iff inside a block initialization */
 143:     int         last_nl;    /* this is true if the last thing scanned
 144: 				 * was a newline */
 145:     int         in_or_st;   /* Will be true iff there has been a
 146: 				 * declarator (e.g. int or char) and no
 147: 				 * left paren since the last semicolon.
 148: 				 * When true, a '{' is starting a
 149: 				 * structure definition or an
 150: 				 * initialization list */
 151:     int         bl_line;    /* set to 1 by dump_line if the line is
 152: 				 * blank */
 153:     int         col_1;      /* set to true if the last token started
 154: 				 * in column 1 */
 155:     int         com_col;    /* this is the column in which the current
 156: 				 * coment should start */
 157:     int         com_ind;    /* the column in which comments to the
 158: 				 * right of code should start */
 159:     int         com_lines;  /* the number of lines with comments, set
 160: 				 * by dump_line */
 161:     int         dec_nest;   /* current nesting level for structure or
 162: 				 * init */
 163:     int         decl_com_ind;   /* the column in which comments after
 164: 				 * declarations should be put */
 165:     int         decl_on_line;   /* set to true if this line of code has
 166: 				 * part of a declaration on it */
 167:     int         i_l_follow; /* the level to which ind_level should be
 168: 				 * set after the current line is printed */
 169:     int         in_decl;    /* set to true when we are in a
 170: 				 * declaration stmt.  The processing of
 171: 				 * braces is then slightly different */
 172:     int         in_stmt;    /* set to 1 while in a stmt */
 173:     int         ind_level;  /* the current indentation level */
 174:     int         ind_size;   /* the size of one indentation level */
 175:     int         ind_stmt;   /* set to 1 if next line should have an
 176: 				 * extra indentation level because we are
 177: 				 * in the middle of a stmt */
 178:     int         last_u_d;   /* set to true after scanning a token
 179: 				 * which forces a following operator to be
 180: 				 * unary */
 181:     int         leave_comma;    /* if true, never break declarations after
 182: 				 * commas */
 183:     int         ljust_decl; /* true if declarations should be left
 184: 				 * justified */
 185:     int         out_coms;   /* the number of comments processed, set
 186: 				 * by pr_comment */
 187:     int         out_lines;  /* the number of lines written, set by
 188: 				 * dump_line */
 189:     int         p_l_follow; /* used to remember how to indent
 190: 				 * following statement */
 191:     int         paren_level;    /* parenthesization level. used to indent
 192: 				 * within stmts */
 193:     short       paren_indents[20];  /* column positions of each paren */
 194:     int         pcase;      /* set to 1 if the current line label is a
 195: 				 * case.  It is printed differently from
 196: 				 * a regular label */
 197:     int         search_brace;   /* set to true by parse when it is
 198: 				 * necessary to buffer up all info up to
 199: 				 * the start of a stmt after an if, while,
 200: 				 * etc */
 201:     int         unindent_displace;  /* comments not to the right of
 202: 					 * code will be placed this many
 203: 					 * indentation levels to the left
 204: 					 * of code */
 205:     int         use_ff;     /* set to one if the current line should
 206: 				 * be terminated with a form feed */
 207:     int         want_blank; /* set to true when the following token
 208: 				 * should be prefixed by a blank. (Said
 209: 				 * prefixing is ignored in some cases.) */
 210:     int         else_if;    /* True iff else if pairs should be
 211: 				 * handled specially */
 212:     int         decl_indent;    /* column to indent declared identifiers
 213: 				 * to */
 214:     int         its_a_keyword;
 215:     int     sizeof_keyword;
 216:     int         dumped_decl_indent;
 217:     float       case_indent;    /* The distance to indent case labels from
 218: 				 * the switch statement */
 219:     int         in_parameter_declaration;
 220:     int         indent_parameters;
 221:     int         tos;        /* pointer to top of stack */
 222:     char        procname[100];  /* The name of the current procedure */
 223:     int     just_saw_decl;
 224: }           ps;
 225: 
 226: int ifdef_level;
 227: struct parser_state state_stack[5];
 228: struct parser_state match_state[5];

Defined variables

be_save defined in line 76; used 5 times
bp_save defined in line 74; used 7 times
break_comma defined in line 89; used 6 times
btype_2 defined in line 90; used 11 times
buf_ptr defined in line 67; used 102 times
case_ind defined in line 92; used 4 times
code_lines defined in line 93; used 2 times
codebuf defined in line 58; used 3 times
combuf defined in line 62; used 3 times
cuddle_else defined in line 101; used 4 times
e_code defined in line 60; used 82 times
e_com defined in line 64; used 79 times
e_lab defined in line 56; used 40 times
ifdef_level defined in line 226; used 10 times
inhibit_formatting defined in line 116; used 3 times
labbuf defined in line 54; used 3 times
lineup_to_parens defined in line 121; used 3 times
match_state defined in line 228; used 4 times
n_real_blanklines defined in line 86; used 8 times
pointer_as_binop defined in line 97; used 3 times
proc_calls_space defined in line 111; used 3 times
procnames_start_line defined in line 107; used 3 times
ps defined in line 224; used 509 times
s_code defined in line 59; used 36 times
s_com defined in line 63; used 45 times
save_com defined in line 70; used 8 times
sc_end defined in line 72; used 28 times
star_comment_cont defined in line 102; used 3 times
state_stack defined in line 227; used 4 times
suppress_blanklines defined in line 117; used 4 times
token defined in line 78; used 41 times
verbose defined in line 99; used 9 times

Defined struct's

parser_state defined in line 126; used 4 times

Defined macros

BACKSLASH defined in line 36; used 11 times
bufsize defined in line 37; used 5 times
false defined in line 47; used 89 times
inp_bufs defined in line 38; used 1 times
  • in line 66
label_offset defined in line 40; used 1 times
sc_size defined in line 39; used 2 times
tabmask defined in line 44; used 3 times
tabsize defined in line 43; used 3 times

Usage of this include

Last modified: 1994-01-01
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 3742
Valid CSS Valid XHTML 1.0 Strict