BSD 4_3 release
[unix-history] / usr / src / ucb / indent / indent_globs.h
CommitLineData
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 *
95f51977 6 * @(#)indent_globs.h 5.4 (Berkeley) 9/10/85
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
19FILE NAME:
20 indent_globs.h
21
22PURPOSE:
23 This include file contains the declarations for all global variables
24 used in indent.
25
26GLOBALS:
27 The names of all of the variables will not be repeated here. The
28 declarations start on the next page.
29
30FUNCTIONS:
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
51FILE *input; /* the fid for the input file */
52FILE *output; /* the output file */
84262df4 53
1009bf5e 54char labbuf[bufsize]; /* buffer for label */
84262df4
KM
55char *s_lab; /* start ... */
56char *e_lab; /* .. and end of stored label */
57
1009bf5e 58char codebuf[bufsize]; /* buffer for code section */
84262df4
KM
59char *s_code; /* start ... */
60char *e_code; /* .. and end of stored code */
61
1009bf5e 62char combuf[bufsize]; /* buffer for comments */
84262df4
KM
63char *s_com; /* start ... */
64char *e_com; /* ... and end of stored comments */
65
1009bf5e 66char in_buffer[inp_bufs]; /* input buffer */
84262df4
KM
67char *buf_ptr; /* ptr to next character to be taken from in_buffer */
68char *buf_end; /* ptr to first after last char in in_buffer */
69
1009bf5e 70char save_com[sc_size]; /* input text is saved here when looking for the brace
84262df4
KM
71 after an if, while, etc */
72char *sc_end; /* pointer into save_com buffer */
73
74char *bp_save; /* saved value of buf_ptr when taking input from
75 save_com */
76char *be_save; /* similarly saved value of buf_end */
77
1009bf5e 78char token[bufsize]; /* the last token scanned */
84262df4
KM
79
80
81
1009bf5e
KM
82int blanklines_after_declarations;
83int blanklines_before_blockcomments;
84int blanklines_after_procs;
85int swallow_optional_blanklines;
86int n_real_blanklines;
87int prefix_blankline_requested;
88int postfix_blankline_requested;
89int break_comma; /* when true and not in parens, break after a comma */
84262df4
KM
90int btype_2; /* when true, brace should be on same line as if,
91 while, etc */
1009bf5e 92float case_ind; /* indentation level to be used for a "case n:" */
84262df4 93int code_lines;/* count of lines with code */
84262df4 94int had_eof; /* set to true when input is exhausted */
84262df4 95int line_no; /* the current line number. */
84262df4 96int max_col; /* the maximum allowable line length */
5c6e73ac
KM
97int pointer_as_binop; /* when true, "->" is treated as a binary
98 operator (giving, e.g., "p -> f") */
84262df4
KM
99int verbose; /* when true, non-essential error messages are printed
100 */
1009bf5e
KM
101int cuddle_else; /* true if else should cuddle up to '}' */
102int star_comment_cont; /* true iff comment continuation lines should
103 have stars at the beginning of each line.
104 */
105int comment_delimiter_on_blankline;
106int troff; /* true iff were generating troff input */
107int 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) */
111int proc_calls_space; /* If true, procedure calls look like:
112 foo(bar) rather than foo (bar) */
113int 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) */
116int inhibit_formatting; /* true if INDENT OFF is in effect */
117int suppress_blanklines; /* set iff following blanklines should be
118 suppressed */
119int continuation_indent; /* set to the indentation between the edge of
120 code and continuation lines */
121int lineup_to_parens; /* if true, continued code within parens will
122 be lined up to the open paren */
123int block_comment_max_col;
124
125
126struct 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
226int ifdef_level;
227struct parser_state state_stack[5];
228struct parser_state match_state[5];