Annotation of 43BSDTahoe/ucb/indent/indent_globs.h, revision 1.1.1.1

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

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.