Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/indent indent: un-abbreviate a few parser_state memb...



details:   https://anonhg.NetBSD.org/src/rev/847aeb80126f
branches:  trunk
changeset: 987399:847aeb80126f
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Sep 25 20:56:53 2021 +0000

description:
indent: un-abbreviate a few parser_state members, clean up comments

No functional change.

diffstat:

 usr.bin/indent/indent.c       |  39 +++++++++++++++++----------------
 usr.bin/indent/indent_globs.h |  42 ++++++++++++++++++------------------
 usr.bin/indent/io.c           |   6 ++--
 usr.bin/indent/parse.c        |  49 +++++++++++++++++++++---------------------
 4 files changed, 68 insertions(+), 68 deletions(-)

diffs (truncated from 402 to 300 lines):

diff -r f9893e65abfd -r 847aeb80126f usr.bin/indent/indent.c
--- a/usr.bin/indent/indent.c   Sat Sep 25 20:23:42 2021 +0000
+++ b/usr.bin/indent/indent.c   Sat Sep 25 20:56:53 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: indent.c,v 1.78 2021/09/25 20:23:42 rillig Exp $       */
+/*     $NetBSD: indent.c,v 1.79 2021/09/25 20:56:53 rillig Exp $       */
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: indent.c,v 1.78 2021/09/25 20:23:42 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.79 2021/09/25 20:56:53 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
 #endif
@@ -498,7 +498,7 @@
        p++;
     }
     if (col > opt.indent_size)
-       ps.ind_level = ps.i_l_follow = col / opt.indent_size;
+       ps.ind_level = ps.ind_level_follow = col / opt.indent_size;
 }
 
 static void __attribute__((__noreturn__))
@@ -769,7 +769,7 @@
                  token_type hd_type,
                  bool *inout_force_nl)
 {
-    if (ps.dec_nest == 0)
+    if (ps.decl_nest == 0)
        ps.in_or_st = false;    /* we are not in an initialization or
                                 * structure declaration */
     *inout_scase = false; /* these will only need resetting in an error */
@@ -789,7 +789,7 @@
        ps.dumped_decl_indent = true;
     }
 
-    ps.in_decl = (ps.dec_nest > 0);    /* if we were in a first level
+    ps.in_decl = (ps.decl_nest > 0);   /* if we were in a first level
                                                 * structure declaration, we
                                                 * arent any more */
 
@@ -837,7 +837,7 @@
            dump_line();
            ps.want_blank = false;
        } else if (ps.in_parameter_declaration && !ps.in_or_st) {
-           ps.i_l_follow = 0;
+           ps.ind_level_follow = 0;
            if (opt.function_brace_split) { /* dump the line prior
                                 * to the brace ... */
                dump_line();
@@ -856,7 +856,7 @@
        if (*inout_sp_sw) {     /* check for unclosed if, for, etc. */
            *inout_sp_sw = false;
            parse(hd_type);
-           ps.ind_level = ps.i_l_follow;
+           ps.ind_level = ps.ind_level_follow;
        }
     }
     if (code.s == code.e)
@@ -864,11 +864,11 @@
                                 * with '{' */
     if (ps.in_decl && ps.in_or_st) {   /* this is either a structure
                                 * declaration or an init */
-       di_stack[ps.dec_nest] = *inout_dec_ind;
-       if (++ps.dec_nest == di_stack_cap) {
+       di_stack[ps.decl_nest] = *inout_dec_ind;
+       if (++ps.decl_nest == di_stack_cap) {
            diag(0, "Reached internal limit of %d struct levels",
                 di_stack_cap);
-           ps.dec_nest--;
+           ps.decl_nest--;
        }
        /* ?            dec_ind = 0; */
     } else {
@@ -913,9 +913,9 @@
     *code.e++ = '}';
     ps.want_blank = true;
     ps.in_stmt = ps.ind_stmt = false;
-    if (ps.dec_nest > 0) { /* we are in multi-level structure declaration */
-       *inout_dec_ind = di_stack[--ps.dec_nest];
-       if (ps.dec_nest == 0 && !ps.in_parameter_declaration)
+    if (ps.decl_nest > 0) { /* we are in multi-level structure declaration */
+       *inout_dec_ind = di_stack[--ps.decl_nest];
+       if (ps.decl_nest == 0 && !ps.in_parameter_declaration)
            ps.just_saw_decl = 2;
        ps.in_decl = true;
     }
@@ -924,7 +924,7 @@
     ps.search_brace = opt.cuddle_else
                      && ps.p_stack[ps.tos] == if_expr_stmt
                      && ps.il[ps.tos] >= ps.ind_level;
-    if (ps.tos <= 1 && opt.blanklines_after_procs && ps.dec_nest <= 0)
+    if (ps.tos <= 1 && opt.blanklines_after_procs && ps.decl_nest <= 0)
        postfix_blankline_requested = true;
 }
 
@@ -965,20 +965,21 @@
            ps.want_blank = false;
        }
     }
-    if (ps.in_parameter_declaration && opt.indent_parameters && ps.dec_nest == 0) {
-       ps.ind_level = ps.i_l_follow = 1;
+    if (ps.in_parameter_declaration && opt.indent_parameters &&
+       ps.decl_nest == 0) {
+       ps.ind_level = ps.ind_level_follow = 1;
        ps.ind_stmt = false;
     }
     ps.in_or_st = true;                /* this might be a structure or initialization
                                 * declaration */
     ps.in_decl = ps.decl_on_line = ps.last_token != type_def;
-    if ( /* !ps.in_or_st && */ ps.dec_nest <= 0)
+    if ( /* !ps.in_or_st && */ ps.decl_nest <= 0)
        ps.just_saw_decl = 2;
     prefix_blankline_requested = false;
     int i;
     for (i = 0; token.s[i++] != '\0';);        /* get length of token */
 
-    if (ps.ind_level == 0 || ps.dec_nest > 0) {
+    if (ps.ind_level == 0 || ps.decl_nest > 0) {
        /* global variable or struct member in local variable */
        *out_dec_ind = opt.decl_indent > 0 ? opt.decl_indent : i;
        *out_tabs_to_var = opt.use_tabs ? opt.decl_indent > 0 : false;
@@ -1235,7 +1236,7 @@
 
     sp_sw = force_nl = false;
     dec_ind = 0;
-    di_stack[ps.dec_nest = 0] = 0;
+    di_stack[ps.decl_nest = 0] = 0;
     scase = false;
     squest = 0;
     tabs_to_var = false;
diff -r f9893e65abfd -r 847aeb80126f usr.bin/indent/indent_globs.h
--- a/usr.bin/indent/indent_globs.h     Sat Sep 25 20:23:42 2021 +0000
+++ b/usr.bin/indent/indent_globs.h     Sat Sep 25 20:56:53 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: indent_globs.h,v 1.34 2021/09/25 20:23:42 rillig Exp $ */
+/*     $NetBSD: indent_globs.h,v 1.35 2021/09/25 20:56:53 rillig Exp $ */
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -99,7 +99,7 @@
     int         decl_comment_column; /* the column in which comments after
                                 * declarations should be put */
     bool       cuddle_else;    /* whether 'else' should cuddle up to '}' */
-    int         continuation_indent; /* set to the indentation between the
+    int         continuation_indent; /* the indentation between the
                                 * edge of code and continuation lines */
     float       case_indent;   /* The distance (measured in tabsize) to
                                 * indent case labels from the switch
@@ -179,13 +179,13 @@
 extern bool        postfix_blankline_requested;
 extern bool        break_comma;        /* when true and not in parens, break after a
                                 * comma */
-extern float       case_ind;           /* indentation level to be used for a "case
+extern float       case_ind;   /* indentation level to be used for a "case
                                 * n:" */
-extern bool        had_eof;            /* set to true when input is exhausted */
+extern bool        had_eof;            /* whether input is exhausted */
 extern int         line_no;            /* the current line number. */
 extern bool        inhibit_formatting; /* true if INDENT OFF is in effect */
-extern int         suppress_blanklines;/* set iff following blanklines should be
-                                * suppressed */
+extern int         suppress_blanklines;/* set iff following blanklines should
+                                * be suppressed */
 
 #define        STACKSIZE 256
 
@@ -217,25 +217,25 @@
                                 * paren since the last semicolon. When true,
                                 * a '{' is starting a structure definition or
                                 * an initialization list */
-    bool       col_1;          /* set to true if the last token started in
+    bool       col_1;          /* whether the last token started in
                                 * column 1 */
     int         com_col;       /* this is the column in which the current
                                 * comment should start */
-    int         dec_nest;      /* current nesting level for structure or init */
-    bool       decl_on_line;   /* set to true if this line of code has part
+    int         decl_nest;     /* current nesting level for structure or init */
+    bool       decl_on_line;   /* whether this line of code has part
                                 * of a declaration on it */
-    int         i_l_follow;    /* the level to which ind_level should be set
+    int         ind_level_follow; /* the level to which ind_level should be set
                                 * after the current line is printed */
-    bool       in_decl;        /* set to true when we are in a declaration
-                                * stmt.  The processing of braces is then
-                                * slightly different */
-    bool       in_stmt;        /* set to 1 while in a stmt */
+    bool       in_decl;        /* whether we are in a declaration stmt.
+                                * The processing of braces is then slightly
+                                * different */
+    bool       in_stmt;        /* whether in a stmt */
     int         ind_level;     /* the current indentation level */
-    bool       ind_stmt;       /* set to 1 if next line should have an extra
+    bool       ind_stmt;       /* whether the next line should have an extra
                                 * indentation level because we are in the
                                 * middle of a stmt */
-    bool       last_u_d;       /* set to true after scanning a token which
-                                * forces a following operator to be unary */
+    bool       last_u_d;       /* whether the following operator should be
+                                * unary */
     int         p_l_follow;    /* used to remember how to indent the
                                 * following statement */
     int         paren_level;   /* parenthesization level. used to indent
@@ -243,15 +243,15 @@
     short       paren_indents[20]; /* indentation of the operand/argument of
                                 * each level of parentheses or brackets,
                                 * relative to the enclosing statement */
-    bool       pcase;          /* set to 1 if the current line label is a
+    bool       pcase;          /* whether the current line label is a
                                 * case.  It is printed differently from a
                                 * regular label */
-    bool       search_brace;   /* set to true by parse when it is necessary
+    bool       search_brace;   /* whether it is necessary
                                 * to buffer up all info up to the start of a
                                 * stmt after an if, while, etc */
-    bool       use_ff;         /* set to one if the current line should be
+    bool       use_ff;         /* whether the current line should be
                                 * terminated with a form feed */
-    bool       want_blank;     /* set to true when the following token should
+    bool       want_blank;     /* whether the following token should
                                 * be prefixed by a blank. (Said prefixing is
                                 * ignored in some cases.) */
     enum rwcode keyword;       /* the type of a keyword or 0 */
diff -r f9893e65abfd -r 847aeb80126f usr.bin/indent/io.c
--- a/usr.bin/indent/io.c       Sat Sep 25 20:23:42 2021 +0000
+++ b/usr.bin/indent/io.c       Sat Sep 25 20:56:53 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: io.c,v 1.63 2021/09/25 20:23:42 rillig Exp $   */
+/*     $NetBSD: io.c,v 1.64 2021/09/25 20:56:53 rillig Exp $   */
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: io.c,v 1.63 2021/09/25 20:23:42 rillig Exp $");
+__RCSID("$NetBSD: io.c,v 1.64 2021/09/25 20:56:53 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/io.c 334927 2018-06-10 16:44:18Z pstef $");
 #endif
@@ -268,7 +268,7 @@
     *(lab.e = lab.s) = '\0';   /* reset buffers */
     *(code.e = code.s) = '\0';
     *(com.e = com.s = com.buf + 1) = '\0';
-    ps.ind_level = ps.i_l_follow;
+    ps.ind_level = ps.ind_level_follow;
     ps.paren_level = ps.p_l_follow;
     if (ps.paren_level > 0) {
         /* TODO: explain what negative indentation means */
diff -r f9893e65abfd -r 847aeb80126f usr.bin/indent/parse.c
--- a/usr.bin/indent/parse.c    Sat Sep 25 20:23:42 2021 +0000
+++ b/usr.bin/indent/parse.c    Sat Sep 25 20:56:53 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: parse.c,v 1.25 2021/09/25 17:36:51 rillig Exp $        */
+/*     $NetBSD: parse.c,v 1.26 2021/09/25 20:56:53 rillig Exp $        */
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -83,7 +83,7 @@
            break_comma = true; /* while in declaration, newline should be
                                 * forced after comma */
            ps.p_stack[++ps.tos] = decl;
-           ps.il[ps.tos] = ps.i_l_follow;
+           ps.il[ps.tos] = ps.ind_level_follow;
 
            if (opt.ljust_decl) {/* only do if we want left justified
                                 * declarations */
@@ -92,7 +92,7 @@
                    if (ps.p_stack[i] == decl)
                        ++ps.ind_level; /* indentation is number of
                                         * declaration levels deep we are */
-               ps.i_l_follow = ps.ind_level;
+               ps.ind_level_follow = ps.ind_level;
            }
        }
        break;
@@ -104,15 +104,15 @@
             * reducing "else if" to "if". This saves a lot of stack space
             * in case of a long "if-else-if ... else-if" sequence.
             */
-           ps.i_l_follow = ps.il[ps.tos--];
+           ps.ind_level_follow = ps.il[ps.tos--];
        }
        /* the rest is the same as for keyword_do and for_exprs */
        /* FALLTHROUGH */
     case keyword_do:           /* 'do' */
     case for_exprs:            /* 'for' (...) */
        ps.p_stack[++ps.tos] = ttype;
-       ps.il[ps.tos] = ps.ind_level = ps.i_l_follow;
-       ++ps.i_l_follow;        /* subsequent statements should be indented 1 */
+       ps.il[ps.tos] = ps.ind_level = ps.ind_level_follow;
+       ++ps.ind_level_follow;  /* subsequent statements should be indented 1 */
        ps.search_brace = opt.btype_2;
        break;



Home | Main Index | Thread Index | Old Index