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 tokens to be more obvious



details:   https://anonhg.NetBSD.org/src/rev/c816dc96bceb
branches:  trunk
changeset: 1019418:c816dc96bceb
user:      rillig <rillig%NetBSD.org@localhost>
date:      Tue Mar 09 18:28:10 2021 +0000

description:
indent: rename a few tokens to be more obvious

For casual readers it is not obvious whether the 'sp' meant 'special' or
'space' or something entirely different.

diffstat:

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

diffs (112 lines):

diff -r ef64ebda72f1 -r c816dc96bceb usr.bin/indent/indent.c
--- a/usr.bin/indent/indent.c   Tue Mar 09 18:21:01 2021 +0000
+++ b/usr.bin/indent/indent.c   Tue Mar 09 18:28:10 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: indent.c,v 1.36 2021/03/09 16:48:28 rillig Exp $       */
+/*     $NetBSD: indent.c,v 1.37 2021/03/09 18:28:10 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.36 2021/03/09 16:48:28 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.37 2021/03/09 18:28:10 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
 #endif
@@ -481,11 +481,11 @@
 
                    remove_newlines =
                        /* "} else" */
-                       (type_code == sp_nparen && *token == 'e' &&
+                       (type_code == keyword_do_else && *token == 'e' &&
                            e_code != s_code && e_code[-1] == '}')
                        /* "else if" */
-                       || (type_code == sp_paren && *token == 'i' &&
-                           last_else && opt.else_if);
+                       || (type_code == keyword_for_if_while &&
+                           *token == 'i' && last_else && opt.else_if);
                    if (remove_newlines)
                        force_nl = false;
                    if (sc_end == NULL) {       /* ignore buffering if
@@ -993,7 +993,7 @@
                                 * expression */
            goto copy_id;       /* go move the token into buffer */
 
-       case sp_paren:          /* token is if, while, for */
+       case keyword_for_if_while:
            sp_sw = true;       /* the interesting stuff is done after the
                                 * expression is scanned */
            hd_type = (*token == 'i' ? ifstmt :
@@ -1004,7 +1004,7 @@
             */
            goto copy_id;       /* copy the token into line */
 
-       case sp_nparen:         /* got else, do */
+       case keyword_do_else:
            ps.in_stmt = false;
            if (*token == 'e') {
                if (e_code != s_code && (!opt.cuddle_else || e_code[-1] != '}')) {
diff -r ef64ebda72f1 -r c816dc96bceb usr.bin/indent/indent_codes.h
--- a/usr.bin/indent/indent_codes.h     Tue Mar 09 18:21:01 2021 +0000
+++ b/usr.bin/indent/indent_codes.h     Tue Mar 09 18:28:10 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: indent_codes.h,v 1.8 2021/03/07 20:30:48 rillig Exp $  */
+/*     $NetBSD: indent_codes.h,v 1.9 2021/03/09 18:28:10 rillig Exp $  */
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -61,8 +61,8 @@
     preesc,
     form_feed,
     decl,
-    sp_paren,
-    sp_nparen,
+    keyword_for_if_while,
+    keyword_do_else,
     ifstmt,
     whilestmt,
     forstmt,
diff -r ef64ebda72f1 -r c816dc96bceb usr.bin/indent/lexi.c
--- a/usr.bin/indent/lexi.c     Tue Mar 09 18:21:01 2021 +0000
+++ b/usr.bin/indent/lexi.c     Tue Mar 09 18:28:10 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lexi.c,v 1.28 2021/03/09 16:48:28 rillig Exp $ */
+/*     $NetBSD: lexi.c,v 1.29 2021/03/09 18:28:10 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.28 2021/03/09 16:48:28 rillig Exp $");
+__RCSID("$NetBSD: lexi.c,v 1.29 2021/03/09 18:28:10 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/lexi.c 337862 2018-08-15 18:19:45Z pstef $");
 #endif
@@ -207,7 +207,8 @@
        "binary_op", "postop", "question", "casestmt", "colon",
        "semicolon", "lbrace", "rbrace", "ident", "comma",
        "comment", "swstmt", "preesc", "form_feed", "decl",
-       "sp_paren", "sp_nparen", "ifstmt", "whilestmt", "forstmt",
+       "keyword_for_if_while", "keyword_do_else",
+       "ifstmt", "whilestmt", "forstmt",
        "stmt", "stmtl", "elselit", "dolit", "dohead",
        "ifhead", "elsehead", "period", "strpfx", "storage",
        "funcname", "type_def", "structure"
@@ -387,10 +388,10 @@
                return lexi_end(decl);
 
            case rw_for_or_if_or_while:
-               return lexi_end(sp_paren);
+               return lexi_end(keyword_for_if_while);
 
            case rw_do_or_else:
-               return lexi_end(sp_nparen);
+               return lexi_end(keyword_do_else);
 
            case rw_storage_class:
                return lexi_end(storage);



Home | Main Index | Thread Index | Old Index