Commit | Line | Data |
---|---|---|
b2e768eb DF |
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 | * | |
1009bf5e | 6 | * @(#)indent_globs.h 5.2 (Berkeley) %G% |
b2e768eb | 7 | */ |
84262df4 | 8 | |
1009bf5e | 9 | /*- |
84262df4 KM |
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 | |
1009bf5e | 32 | */ |
84262df4 | 33 | |
1009bf5e KM |
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 | */ | |
84262df4 KM |
42 | |
43 | #define tabsize 8 /* the size of a tab */ | |
1009bf5e | 44 | #define tabmask 0177770 /* mask used when figuring length of lines with tabs */ |
84262df4 KM |
45 | |
46 | ||
47 | #define false 0 | |
48 | #define true 1 | |
49 | ||
50 | ||
1009bf5e KM |
51 | FILE *input; /* the fid for the input file */ |
52 | FILE *output; /* the output file */ | |
84262df4 | 53 | |
1009bf5e | 54 | char labbuf[bufsize]; /* buffer for label */ |
84262df4 KM |
55 | char *s_lab; /* start ... */ |
56 | char *e_lab; /* .. and end of stored label */ | |
57 | ||
1009bf5e | 58 | char codebuf[bufsize]; /* buffer for code section */ |
84262df4 KM |
59 | char *s_code; /* start ... */ |
60 | char *e_code; /* .. and end of stored code */ | |
61 | ||
1009bf5e | 62 | char combuf[bufsize]; /* buffer for comments */ |
84262df4 KM |
63 | char *s_com; /* start ... */ |
64 | char *e_com; /* ... and end of stored comments */ | |
65 | ||
1009bf5e | 66 | char in_buffer[inp_bufs]; /* input buffer */ |
84262df4 KM |
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 | ||
1009bf5e | 70 | char save_com[sc_size]; /* input text is saved here when looking for the brace |
84262df4 KM |
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 | ||
1009bf5e | 78 | char token[bufsize]; /* the last token scanned */ |
84262df4 KM |
79 | |
80 | ||
81 | ||
1009bf5e KM |
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 */ | |
84262df4 KM |
90 | int btype_2; /* when true, brace should be on same line as if, |
91 | while, etc */ | |
1009bf5e | 92 | float case_ind; /* indentation level to be used for a "case n:" */ |
84262df4 | 93 | int code_lines;/* count of lines with code */ |
84262df4 | 94 | int had_eof; /* set to true when input is exhausted */ |
84262df4 | 95 | int line_no; /* the current line number. */ |
84262df4 | 96 | int max_col; /* the maximum allowable line length */ |
84262df4 KM |
97 | int verbose; /* when true, non-essential error messages are printed |
98 | */ | |
1009bf5e KM |
99 | int cuddle_else; /* true if else should cuddle up to '}' */ |
100 | int star_comment_cont; /* true iff comment continuation lines should | |
101 | have stars at the beginning of each line. | |
102 | */ | |
103 | int comment_delimiter_on_blankline; | |
104 | int troff; /* true iff were generating troff input */ | |
105 | int procnames_start_line; /* if true, the names of procedures being | |
106 | defined get placed in column 1 (ie. a | |
107 | newline is placed between the type of the | |
108 | procedure and its name) */ | |
109 | int proc_calls_space; /* If true, procedure calls look like: | |
110 | foo(bar) rather than foo (bar) */ | |
111 | int format_col1_comments; /* If comments which start in column 1 are to | |
112 | be magically reformatted (just like comments that | |
113 | begin in later columns) */ | |
114 | int inhibit_formatting; /* true if INDENT OFF is in effect */ | |
115 | int suppress_blanklines; /* set iff following blanklines should be | |
116 | suppressed */ | |
117 | int continuation_indent; /* set to the indentation between the edge of | |
118 | code and continuation lines */ | |
119 | int lineup_to_parens; /* if true, continued code within parens will | |
120 | be lined up to the open paren */ | |
121 | int block_comment_max_col; | |
122 | ||
123 | ||
124 | struct parser_state { | |
125 | int last_token; | |
126 | int p_stack[50]; /* this is the parsers stack */ | |
127 | int il[50]; /* this stack stores indentation levels */ | |
128 | float cstk[50]; /* used to store case stmt indentation | |
129 | * levels */ | |
130 | int box_com; /* set to true when we are in a "boxed" | |
131 | * comment. In that case, the first | |
132 | * non-blank char should be lined up with | |
133 | * the / in /* */ | |
134 | int comment_delta, | |
135 | n_comment_delta; | |
136 | int cast_mask; /* indicates which close parens close off | |
137 | * casts */ | |
138 | int sizeof_mask; /* indicates which close parens close off | |
139 | sizeof''s */ | |
140 | int block_init; /* true iff inside a block initialization */ | |
141 | int last_nl; /* this is true if the last thing scanned | |
142 | * was a newline */ | |
143 | int in_or_st; /* Will be true iff there has been a | |
144 | * declarator (e.g. int or char) and no | |
145 | * left paren since the last semicolon. | |
146 | * When true, a '{' is starting a | |
147 | * structure definition or an | |
148 | * initialization list */ | |
149 | int bl_line; /* set to 1 by dump_line if the line is | |
150 | * blank */ | |
151 | int col_1; /* set to true if the last token started | |
152 | * in column 1 */ | |
153 | int com_col; /* this is the column in which the current | |
154 | * coment should start */ | |
155 | int com_ind; /* the column in which comments to the | |
156 | * right of code should start */ | |
157 | int com_lines; /* the number of lines with comments, set | |
158 | * by dump_line */ | |
159 | int dec_nest; /* current nesting level for structure or | |
160 | * init */ | |
161 | int decl_com_ind; /* the column in which comments after | |
162 | * declarations should be put */ | |
163 | int decl_on_line; /* set to true if this line of code has | |
164 | * part of a declaration on it */ | |
165 | int i_l_follow; /* the level to which ind_level should be | |
166 | * set after the current line is printed */ | |
167 | int in_decl; /* set to true when we are in a | |
168 | * declaration stmt. The processing of | |
169 | * braces is then slightly different */ | |
170 | int in_stmt; /* set to 1 while in a stmt */ | |
171 | int ind_level; /* the current indentation level */ | |
172 | int ind_size; /* the size of one indentation level */ | |
173 | int ind_stmt; /* set to 1 if next line should have an | |
174 | * extra indentation level because we are | |
175 | * in the middle of a stmt */ | |
176 | int last_u_d; /* set to true after scanning a token | |
177 | * which forces a following operator to be | |
178 | * unary */ | |
179 | int leave_comma; /* if true, never break declarations after | |
180 | * commas */ | |
181 | int ljust_decl; /* true if declarations should be left | |
182 | * justified */ | |
183 | int out_coms; /* the number of comments processed, set | |
184 | * by pr_comment */ | |
185 | int out_lines; /* the number of lines written, set by | |
186 | * dump_line */ | |
187 | int p_l_follow; /* used to remember how to indent | |
188 | * following statement */ | |
189 | int paren_level; /* parenthesization level. used to indent | |
190 | * within stmts */ | |
191 | short paren_indents[20]; /* column positions of each paren */ | |
192 | int pcase; /* set to 1 if the current line label is a | |
193 | * case. It is printed differently from | |
194 | * a regular label */ | |
195 | int search_brace; /* set to true by parse when it is | |
196 | * necessary to buffer up all info up to | |
197 | * the start of a stmt after an if, while, | |
198 | * etc */ | |
199 | int unindent_displace; /* comments not to the right of | |
200 | * code will be placed this many | |
201 | * indentation levels to the left | |
202 | * of code */ | |
203 | int use_ff; /* set to one if the current line should | |
204 | * be terminated with a form feed */ | |
205 | int want_blank; /* set to true when the following token | |
206 | * should be prefixed by a blank. (Said | |
207 | * prefixing is ignored in some cases.) */ | |
208 | int else_if; /* True iff else if pairs should be | |
209 | * handled specially */ | |
210 | int decl_indent; /* column to indent declared identifiers | |
211 | * to */ | |
212 | int its_a_keyword; | |
213 | int sizeof_keyword; | |
214 | int dumped_decl_indent; | |
215 | float case_indent; /* The distance to indent case labels from | |
216 | * the switch statement */ | |
217 | int in_parameter_declaration; | |
218 | int indent_parameters; | |
219 | int tos; /* pointer to top of stack */ | |
220 | char procname[100]; /* The name of the current procedure */ | |
221 | int just_saw_decl; | |
222 | } ps; | |
223 | ||
224 | int ifdef_level; | |
225 | struct parser_state state_stack[5]; | |
226 | struct parser_state match_state[5]; |