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 tokens lparen and rparen to be...



details:   https://anonhg.NetBSD.org/src/rev/72c21ea3ec51
branches:  trunk
changeset: 1024033:72c21ea3ec51
user:      rillig <rillig%NetBSD.org@localhost>
date:      Fri Oct 08 16:20:33 2021 +0000

description:
indent: rename tokens lparen and rparen to be more precise

No functional change.

diffstat:

 usr.bin/indent/indent.c |  14 +++++++-------
 usr.bin/indent/indent.h |   6 +++---
 usr.bin/indent/lexi.c   |  16 +++++++++-------
 3 files changed, 19 insertions(+), 17 deletions(-)

diffs (134 lines):

diff -r 404188d70ceb -r 72c21ea3ec51 usr.bin/indent/indent.c
--- a/usr.bin/indent/indent.c   Fri Oct 08 16:16:54 2021 +0000
+++ b/usr.bin/indent/indent.c   Fri Oct 08 16:20:33 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: indent.c,v 1.125 2021/10/07 23:18:47 rillig Exp $      */
+/*     $NetBSD: indent.c,v 1.126 2021/10/08 16:20:33 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.125 2021/10/07 23:18:47 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.126 2021/10/08 16:20:33 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
 #endif
@@ -621,7 +621,7 @@
 {
     if (!ps.want_blank)
        return false;
-    if (ps.last_token == rparen)
+    if (ps.last_token == rparen_or_rbracket)
        return false;
     if (ps.last_token != ident && ps.last_token != funcname)
        return true;
@@ -803,7 +803,7 @@
                                 * structure declaration */
     *seen_case = false;                /* these will only need resetting in an error */
     *seen_quest = 0;
-    if (ps.last_token == rparen)
+    if (ps.last_token == rparen_or_rbracket)
        ps.in_parameter_declaration = false;
     ps.cast_mask = 0;
     ps.not_cast_mask = 0;
@@ -1000,7 +1000,7 @@
 {
     parse(decl);               /* let parser worry about indentation */
 
-    if (ps.last_token == rparen && ps.tos <= 1) {
+    if (ps.last_token == rparen_or_rbracket && ps.tos <= 1) {
        if (code.s != code.e) {
            dump_line();
            ps.want_blank = false;
@@ -1316,11 +1316,11 @@
            process_newline();
            break;
 
-       case lparen:            /* got a '(' or '[' */
+       case lparen_or_lbracket:
            process_lparen_or_lbracket(decl_ind, tabs_to_var, sp_sw);
            break;
 
-       case rparen:            /* got a ')' or ']' */
+       case rparen_or_rbracket:
            process_rparen_or_rbracket(&sp_sw, &force_nl, hd_type);
            break;
 
diff -r 404188d70ceb -r 72c21ea3ec51 usr.bin/indent/indent.h
--- a/usr.bin/indent/indent.h   Fri Oct 08 16:16:54 2021 +0000
+++ b/usr.bin/indent/indent.h   Fri Oct 08 16:20:33 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: indent.h,v 1.31 2021/10/08 16:16:54 rillig Exp $       */
+/*     $NetBSD: indent.h,v 1.32 2021/10/08 16:20:33 rillig Exp $       */
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -73,8 +73,8 @@
 typedef enum token_type {
     end_of_file,
     newline,
-    lparen,                    /* '(' or '[' */
-    rparen,                    /* ')' or ']' */
+    lparen_or_lbracket,
+    rparen_or_rbracket,
     unary_op,                  /* e.g. '+' or '&' */
     binary_op,                 /* e.g. '<<' or '+' or '&&' or '/=' */
     postfix_op,                        /* trailing '++' or '--' */
diff -r 404188d70ceb -r 72c21ea3ec51 usr.bin/indent/lexi.c
--- a/usr.bin/indent/lexi.c     Fri Oct 08 16:16:54 2021 +0000
+++ b/usr.bin/indent/lexi.c     Fri Oct 08 16:20:33 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lexi.c,v 1.78 2021/10/07 23:15:15 rillig Exp $ */
+/*     $NetBSD: lexi.c,v 1.79 2021/10/08 16:20:33 rillig Exp $ */
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: lexi.c,v 1.78 2021/10/07 23:15:15 rillig Exp $");
+__RCSID("$NetBSD: lexi.c,v 1.79 2021/10/08 16:20:33 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/lexi.c 337862 2018-08-15 18:19:45Z pstef $");
 #endif
@@ -222,8 +222,9 @@
 token_type_name(token_type ttype)
 {
     static const char *const name[] = {
-       "end_of_file", "newline", "lparen", "rparen", "unary_op",
-       "binary_op", "postfix_op", "question", "case_label", "colon",
+       "end_of_file", "newline", "lparen_or_lbracket", "rparen_or_rbracket",
+       "unary_op", "binary_op", "postfix_op", "question",
+       "case_label", "colon",
        "semicolon", "lbrace", "rbrace", "ident", "comma",
        "comment", "switch_expr", "preprocessing", "form_feed", "decl",
        "keyword_for_if_while", "keyword_do_else",
@@ -525,12 +526,12 @@
     case '(':
     case '[':
        unary_delim = true;
-       ttype = lparen;
+       ttype = lparen_or_lbracket;
        break;
 
     case ')':
     case ']':
-       ttype = rparen;
+       ttype = rparen_or_rbracket;
        break;
 
     case '#':
@@ -589,7 +590,8 @@
            /* check for doubled character */
            *token.e++ = *inp.s++;
            /* buffer overflow will be checked at end of loop */
-           if (state->last_token == ident || state->last_token == rparen) {
+           if (state->last_token == ident ||
+                   state->last_token == rparen_or_rbracket) {
                ttype = state->last_u_d ? unary_op : postfix_op;
                /* check for following ++ or -- */
                unary_delim = false;



Home | Main Index | Thread Index | Old Index