packages: don't put oss on cd.
[minix.git] / commands / indent / globs.h
blobcfd58782925c19912e41ab774ead65a0edce40dc
1 /**
2 * Copyright (c) 1985 Sun Microsystems, Inc.
3 * Copyright (c) 1980 The Regents of the University of California.
4 * Copyright (c) 1976 Board of Trustees of the University of Illinois.
5 * All rights reserved.
7 * Redistribution and use in source and binary forms are permitted
8 * provided that the above copyright notice and this paragraph are
9 * duplicated in all such forms and that any documentation,
10 * advertising materials, and other materials related to such
11 * distribution and use acknowledge that the software was developed
12 * by the University of California, Berkeley, the University of Illinois,
13 * Urbana, and Sun Microsystems, Inc. The name of either University
14 * or Sun Microsystems may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
18 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
20 * @(#)indent_globs.h 5.7 (Berkeley) 9/15/88
23 #include <stdio.h>
25 #define BACKSLASH '\\'
26 #define bufsize 200 /* size of internal buffers */
27 #define inp_bufs 600 /* size of input buffer */
28 #define sc_size 5000 /* size of save_com buffer */
29 #define label_offset 2 /* number of levels a label is
30 placed to left of code */
32 #define tabsize 8 /* the size of a tab */
33 #define tabmask 0177770 /* mask used when figuring
34 length of lines with tabs */
37 #define false 0
38 #define true !false
41 PUBLIC FILE *input; /* the fid for the input file */
42 PUBLIC FILE *output; /* the output file */
44 PUBLIC char *labbuf; /* buffer for label */
45 PUBLIC char *s_lab; /* start ... */
46 PUBLIC char *e_lab; /* .. and end of stored label */
47 PUBLIC char *l_lab; /* limit of label buffer */
49 PUBLIC char *codebuf; /* buffer for code section */
50 PUBLIC char *s_code; /* start ... */
51 PUBLIC char *e_code; /* .. and end of stored code */
52 PUBLIC char *l_code; /* limit of code section */
54 PUBLIC char *combuf; /* buffer for comments */
55 PUBLIC char *s_com; /* start ... */
56 PUBLIC char *e_com; /* ... and end of stored
57 comments */
58 PUBLIC char *l_com; /* limit of comment buffer */
60 PUBLIC char in_buffer[inp_bufs]; /* input buffer */
61 PUBLIC char *buf_ptr; /* ptr to next character to be
62 taken from in_buffer */
63 PUBLIC char *buf_end; /* ptr to first after last char
64 in in_buffer */
66 PUBLIC char save_com[sc_size]; /* input text is saved here
67 when looking for the brace
68 after an if, while, etc */
69 PUBLIC char *sc_end; /* pointer into save_com buffer */
71 PUBLIC char *bp_save; /* saved value of buf_ptr when
72 taking input from save_com */
73 PUBLIC char *be_save; /* similarly saved value of
74 buf_end */
76 PUBLIC char token[bufsize]; /* the last token scanned */
79 PUBLIC int ptr_binop; /* pointer as binop */
80 PUBLIC int bl_aft_decl; /* blanklines after
81 declarations */
82 PUBLIC int bl_bef_bk; /* blanklines before
83 blockcomments */
84 PUBLIC int bl_a_procs; /* blanklines after procs */
85 PUBLIC int bl_around; /* blanklines around
86 conditional compilation */
87 PUBLIC int swallow_opt_bl; /* swallow optional blanklines */
88 PUBLIC int n_real_blanklines;
89 PUBLIC int prefix_blankline_requested;
90 PUBLIC int postfix_blankline_requested;
91 PUBLIC int break_comma; /* when true and not in parens,
92 break after a comma */
93 PUBLIC int btype_2; /* when true, brace should be
94 on same line as if, while,
95 etc */
96 PUBLIC long case_ind; /* indentation level to be used
97 for a "case n:" */
98 PUBLIC int code_lines; /* count of lines with code */
99 PUBLIC int had_eof; /* set to true when input is
100 exhausted */
101 PUBLIC int line_no; /* the current line number. */
102 PUBLIC int max_col; /* the maximum allowable line
103 length */
104 PUBLIC int verbose; /* when true, non-essential
105 error messages are printed */
106 PUBLIC int cuddle_else; /* true if else should cuddle
107 up to '}' */
108 PUBLIC int star_comment_cont; /* true iff comment
109 continuation lines should
110 have stars at the beginning
111 of each line. */
112 PUBLIC int del_on_bl; /* comment_delimiter_on_blanklin
113 e */
114 PUBLIC int troff; /* true iff were generating
115 troff input */
116 PUBLIC int proc_str_line; /* if true, the names of
117 procedures being defined get
118 placed in column 1 (ie. a
119 newline is placed between
120 the type of the procedure
121 and its name) */
122 PUBLIC int proc_calls_space; /* If true, procedure calls
123 look like: foo(bar) rather
124 than foo (bar) */
125 PUBLIC int format_col1_comments; /* If comments which start in
126 column 1 are to be magically
127 reformatted (just like
128 comments that begin in later
129 columns) */
130 PUBLIC int inhibit_formatting; /* true if INDENT OFF is in
131 effect */
132 PUBLIC int suppress_blanklines; /* set iff following blanklines
133 should be suppressed */
134 PUBLIC int continuation_indent; /* set to the indentation
135 between the edge of code and
136 continuation lines */
137 PUBLIC int lineup_to_parens; /* if true, continued code
138 within parens will be lined
139 up to the open paren */
140 PUBLIC int Bill_Shannon; /* true iff a blank should
141 always be inserted after
142 sizeof */
143 PUBLIC int bl_at_proctop; /* This is vaguely similar to
144 blanklines_after_declarations
145 except that it only applies
146 to the first set of
147 declarations in a procedure
148 (just after the first '{')
149 and it causes a blank line
150 to be generated even if
151 there are no declarations */
152 PUBLIC int bk_max_col;
153 PUBLIC int ex_expr_indent; /* True if continuation lines
154 from the expression part of
155 "if(e)", "while(e)",
156 "for(e;e;e)" should be
157 indented an extra tab stop
158 so that they don't conflict
159 with the code that follows */
161 /* -troff font state information */
163 struct fstate
165 char font[4];
166 char size;
167 int allcaps;
170 PUBLIC struct fstate
171 keywordf, /* keyword font */
172 stringf, /* string font */
173 boxcomf, /* Box comment font */
174 blkcomf, /* Block comment font */
175 scomf, /* Same line comment font */
176 bodyf; /* major body font */
179 #define STACKSIZE 150
181 PUBLIC struct parser_state
183 int last_token;
184 struct fstate cfont; /* Current font */
185 int p_stack[STACKSIZE]; /* this is the parsers stack */
186 int il[STACKSIZE]; /* this stack stores
187 indentation levels */
188 long cstk[STACKSIZE]; /* used to store case stmt
189 indentation levels */
190 int box_com; /* set to true when we are in a
191 "boxed" comment. In that
192 case, the first non-blank
193 char should be lined up with
194 the / in / * */
195 int comment_delta, n_comment_delta;
196 int cast_mask; /* indicates which close parens
197 close off casts */
198 int sizeof_mask; /* indicates which close parens
199 close off sizeof''s */
200 int block_init; /* true iff inside a block
201 initialization */
202 int block_init_level; /* The level of brace nesting
203 in an initialization */
204 int last_nl; /* this is true if the last
205 thing scanned was a newline */
206 int in_or_st; /* Will be true iff there has
207 been a declarator (e.g. int
208 or char) and no left paren
209 since the last semicolon.
210 When true, a '{' is starting
211 a structure definition or an
212 initialization list */
213 int bl_line; /* set to 1 by dump_line if the
214 line is blank */
215 int col_1; /* set to true if the last
216 token started in column 1 */
217 int com_col; /* this is the column in which
218 the current coment should
219 start */
220 int com_ind; /* the column in which comments
221 to the right of code should
222 start */
223 int com_lines; /* the number of lines with
224 comments, set by dump_line */
225 int dec_nest; /* current nesting level for
226 structure or init */
227 int decl_com_ind; /* the column in which comments
228 after declarations should be
229 put */
230 int decl_on_line; /* set to true if this line of
231 code has part of a
232 declaration on it */
233 int i_l_follow; /* the level to which ind_level
234 should be set after the
235 current line is printed */
236 int in_decl; /* set to true when we are in a
237 declaration stmt. The
238 processing of braces is then
239 slightly different */
240 int in_stmt; /* set to 1 while in a stmt */
241 int ind_level; /* the current indentation
242 level */
243 int ind_size; /* the size of one indentation
244 level */
245 int ind_stmt; /* set to 1 if next line should
246 have an extra indentation
247 level because we are in the
248 middle of a stmt */
249 int last_u_d; /* set to true after scanning a
250 token which forces a
251 following operator to be
252 unary */
253 int leave_comma; /* if true, never break
254 declarations after commas */
255 int ljust_decl; /* true if declarations should
256 be left justified */
257 int out_coms; /* the number of comments
258 processed, set by pr_comment */
259 int out_lines; /* the number of lines written,
260 set by dump_line */
261 int p_l_follow; /* used to remember how to
262 indent following statement */
263 int paren_level; /* parenthesization level. used
264 to indent within stmts */
265 short paren_indents[20]; /* column positions of each
266 paren */
267 int pcase; /* set to 1 if the current line
268 label is a case. It is
269 printed differently from a
270 regular label */
271 int search_brace; /* set to true by parse when it
272 is necessary to buffer up
273 all info up to the start of
274 a stmt after an if, while,
275 etc */
276 int unindent_displace; /* comments not to the right of
277 code will be placed this
278 many indentation levels to
279 the left of code */
280 int use_ff; /* set to one if the current
281 line should be terminated
282 with a form feed */
283 int want_blank; /* set to true when the
284 following token should be
285 prefixed by a blank. (Said
286 prefixing is ignored in some
287 cases.) */
288 int else_if; /* True iff else if pairs
289 should be handled specially */
290 int decl_indent; /* column to indent declared
291 identifiers to */
292 int its_a_keyword;
293 int sizeof_keyword;
294 int dumped_decl_indent;
295 int case_indent; /* The distance to indent case
296 labels from the switch
297 statement */
298 int in_par_decl;
299 int indent_parameters;
300 int tos; /* pointer to top of stack */
301 char procname[100]; /* The name of the current
302 procedure */
303 int just_saw_decl;
304 } ps;
306 PUBLIC int ifdef_level;
307 PUBLIC struct parser_state state_stack[5];
308 PUBLIC struct parser_state match_state[5];