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: rename a few more token types



details:   https://anonhg.NetBSD.org/src/rev/2508897c7887
branches:  trunk
changeset: 953468:2508897c7887
user:      rillig <rillig%NetBSD.org@localhost>
date:      Tue Mar 09 19:23:08 2021 +0000

description:
indent: rename a few more token types

The previous names were either too short or ambiguous.

No functional change.

diffstat:

 usr.bin/indent/indent.c       |  20 +++++++++++---------
 usr.bin/indent/indent_codes.h |  12 ++++++------
 usr.bin/indent/lexi.c         |  32 ++++++++++++++++----------------
 3 files changed, 33 insertions(+), 31 deletions(-)

diffs (223 lines):

diff -r 75899bab9b79 -r 2508897c7887 usr.bin/indent/indent.c
--- a/usr.bin/indent/indent.c   Tue Mar 09 19:14:39 2021 +0000
+++ b/usr.bin/indent/indent.c   Tue Mar 09 19:23:08 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: indent.c,v 1.38 2021/03/09 19:14:39 rillig Exp $       */
+/*     $NetBSD: indent.c,v 1.39 2021/03/09 19:23:08 rillig Exp $       */
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -46,7 +46,7 @@
 #include <sys/cdefs.h>
 #ifndef lint
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: indent.c,v 1.38 2021/03/09 19:14:39 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.39 2021/03/09 19:23:08 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
 #endif
@@ -595,7 +595,7 @@
        if (
                (type_code != comment) &&
                (type_code != newline) &&
-               (type_code != preesc) &&
+               (type_code != preprocessing) &&
                (type_code != form_feed)) {
            if (force_nl &&
                    (type_code != semicolon) &&
@@ -770,7 +770,7 @@
            ps.want_blank = true;
            break;
 
-       case postop:            /* got a trailing ++ or -- */
+       case postfix_op:        /* got a trailing ++ or -- */
            *e_code++ = token[0];
            *e_code++ = token[1];
            ps.want_blank = true;
@@ -1032,11 +1032,11 @@
            goto copy_id;       /* move the token into line */
 
        case type_def:
-       case storage:
+       case storage_class:
            prefix_blankline_requested = 0;
            goto copy_id;
 
-       case structure:
+       case keyword_struct_union_enum:
            if (ps.p_l_follow > 0)
                goto copy_id;
            /* FALLTHROUGH */
@@ -1114,7 +1114,7 @@
                ps.want_blank = true;
            break;
 
-       case strpfx:
+       case string_prefix:
            {
                int len = e_token - s_token;
 
@@ -1154,7 +1154,7 @@
            }
            break;
 
-       case preesc:            /* got the character '#' */
+       case preprocessing:     /* '#' */
            if ((s_com != e_com) ||
                    (s_lab != e_lab) ||
                    (s_code != e_code))
@@ -1308,7 +1308,9 @@
        }                       /* end of big switch stmt */
 
        *e_code = '\0';         /* make sure code section is null terminated */
-       if (type_code != comment && type_code != newline && type_code != preesc)
+       if (type_code != comment &&
+           type_code != newline &&
+           type_code != preprocessing)
            ps.last_token = type_code;
     }                          /* end of main while (1) loop */
 }
diff -r 75899bab9b79 -r 2508897c7887 usr.bin/indent/indent_codes.h
--- a/usr.bin/indent/indent_codes.h     Tue Mar 09 19:14:39 2021 +0000
+++ b/usr.bin/indent/indent_codes.h     Tue Mar 09 19:23:08 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: indent_codes.h,v 1.10 2021/03/09 19:14:39 rillig Exp $ */
+/*     $NetBSD: indent_codes.h,v 1.11 2021/03/09 19:23:08 rillig Exp $ */
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -47,7 +47,7 @@
     rparen,                    /* ')' or ']' */
     unary_op,                  /* e.g. '+' or '&' */
     binary_op,                 /* e.g. '<<' or '+' or '&&' or '/=' */
-    postop,                    /* trailing '++' or '--' */
+    postfix_op,                        /* trailing '++' or '--' */
     question,                  /* the '?' from a '?:' expression */
     case_label,
     colon,
@@ -58,7 +58,7 @@
     comma,
     comment,
     switch_expr,               /* 'switch' '(' <expr> ')' */
-    preesc,
+    preprocessing,             /* '#' */
     form_feed,
     decl,
     keyword_for_if_while,      /* 'for', 'if' or 'while' */
@@ -74,9 +74,9 @@
     if_expr_stmt,              /* 'if' '(' <expr> ')' <stmt> */
     if_expr_stmt_else,         /* 'if' '(' <expr> ')' <stmt> 'else' */
     period,
-    strpfx,
-    storage,
+    string_prefix,             /* 'L' */
+    storage_class,
     funcname,
     type_def,
-    structure
+    keyword_struct_union_enum
 } token_type;
diff -r 75899bab9b79 -r 2508897c7887 usr.bin/indent/lexi.c
--- a/usr.bin/indent/lexi.c     Tue Mar 09 19:14:39 2021 +0000
+++ b/usr.bin/indent/lexi.c     Tue Mar 09 19:23:08 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lexi.c,v 1.30 2021/03/09 19:14:39 rillig Exp $ */
+/*     $NetBSD: lexi.c,v 1.31 2021/03/09 19:23:08 rillig Exp $ */
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -46,7 +46,7 @@
 #include <sys/cdefs.h>
 #ifndef lint
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: lexi.c,v 1.30 2021/03/09 19:14:39 rillig Exp $");
+__RCSID("$NetBSD: lexi.c,v 1.31 2021/03/09 19:23:08 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/lexi.c 337862 2018-08-15 18:19:45Z pstef $");
 #endif
@@ -204,14 +204,14 @@
 {
     static const char *const name[] = {
        "end_of_file", "newline", "lparen", "rparen", "unary_op",
-       "binary_op", "postop", "question", "case_label", "colon",
+       "binary_op", "postfix_op", "question", "case_label", "colon",
        "semicolon", "lbrace", "rbrace", "ident", "comma",
-       "comment", "switch_expr", "preesc", "form_feed", "decl",
+       "comment", "switch_expr", "preprocessing", "form_feed", "decl",
        "keyword_for_if_while", "keyword_do_else",
        "if_expr", "while_expr", "for_exprs",
        "stmt", "stmt_list", "keyword_else", "keyword_do", "do_stmt",
-       "if_expr_stmt", "if_expr_stmt_else", "period", "strpfx", "storage",
-       "funcname", "type_def", "structure"
+       "if_expr_stmt", "if_expr_stmt_else", "period", "string_prefix",
+       "storage_class", "funcname", "type_def", "keyword_struct_union_enum"
     };
 
     assert(0 <= tk && tk < sizeof name / sizeof name[0]);
@@ -329,24 +329,24 @@
 
        if (s_token[0] == 'L' && s_token[1] == '\0' &&
              (*buf_ptr == '"' || *buf_ptr == '\''))
-           return lexi_end(strpfx);
+           return lexi_end(string_prefix);
 
        while (*buf_ptr == ' ' || *buf_ptr == '\t') {   /* get rid of blanks */
            if (++buf_ptr >= buf_end)
                fill_buffer();
        }
        state->keyword = rw_0;
-       if (state->last_token == structure && !state->p_l_follow) {
-                               /* if last token was 'struct' and we're not
-                                * in parentheses, then this token
-                                * should be treated as a declaration */
+       if (state->last_token == keyword_struct_union_enum &&
+           !state->p_l_follow) {
+           /* if last token was 'struct' and we're not in parentheses, then
+            * this token should be treated as a declaration */
            state->last_u_d = true;
            return lexi_end(decl);
        }
        /*
         * Operator after identifier is binary unless last token was 'struct'
         */
-       state->last_u_d = (state->last_token == structure);
+       state->last_u_d = (state->last_token == keyword_struct_union_enum);
 
        p = bsearch(s_token, specials, sizeof specials / sizeof specials[0],
            sizeof specials[0], compare_templ_array);
@@ -382,7 +382,7 @@
                    break;
                }
                if (p != NULL && p->rwcode == rw_struct_or_union_or_enum)
-                   return lexi_end(structure);
+                   return lexi_end(keyword_struct_union_enum);
                if (state->p_l_follow)
                    break;
                return lexi_end(decl);
@@ -394,7 +394,7 @@
                return lexi_end(keyword_do_else);
 
            case rw_storage_class:
-               return lexi_end(storage);
+               return lexi_end(storage_class);
 
            case rw_typedef:
                return lexi_end(type_def);
@@ -501,7 +501,7 @@
 
     case '#':
        unary_delim = state->last_u_d;
-       code = preesc;
+       code = preprocessing;
        break;
 
     case '?':
@@ -562,7 +562,7 @@
            *e_token++ = *buf_ptr++;
            /* buffer overflow will be checked at end of loop */
            if (state->last_token == ident || state->last_token == rparen) {
-               code = (state->last_u_d ? unary_op : postop);
+               code = (state->last_u_d ? unary_op : postfix_op);
                /* check for following ++ or -- */
                unary_delim = false;
            }



Home | Main Index | Thread Index | Old Index