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: add separate lexer symbol for sizeof



details:   https://anonhg.NetBSD.org/src/rev/83fff878789b
branches:  trunk
changeset: 990615:83fff878789b
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Oct 31 10:00:37 2021 +0000

description:
indent: add separate lexer symbol for sizeof

The plan is to get rid of the type keyword_kind, which largely overlaps
with lexer_symbol.

No functional change.

diffstat:

 usr.bin/indent/indent.c |  9 ++++++---
 usr.bin/indent/indent.h |  3 ++-
 usr.bin/indent/lexi.c   |  6 ++++--
 3 files changed, 12 insertions(+), 6 deletions(-)

diffs (89 lines):

diff -r 190df7507ea0 -r 83fff878789b usr.bin/indent/indent.c
--- a/usr.bin/indent/indent.c   Sun Oct 31 09:52:37 2021 +0000
+++ b/usr.bin/indent/indent.c   Sun Oct 31 10:00:37 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: indent.c,v 1.196 2021/10/30 23:27:33 rillig Exp $      */
+/*     $NetBSD: indent.c,v 1.197 2021/10/31 10:00:37 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.196 2021/10/30 23:27:33 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.197 2021/10/31 10:00:37 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
 #endif
@@ -741,6 +741,8 @@
        return false;
     if (ps.prev_token == lsym_rparen_or_rbracket)
        return false;
+    if (ps.prev_token == lsym_sizeof)
+       return opt.proc_calls_space || opt.blank_after_sizeof;
     if (ps.prev_token != lsym_ident && ps.prev_token != lsym_funcname)
        return true;
     if (opt.proc_calls_space)
@@ -1495,8 +1497,9 @@
            process_type(&decl_ind, &tabs_to_var);
            goto copy_token;
 
+       case lsym_sizeof:
+       case lsym_ident:
        case lsym_funcname:
-       case lsym_ident:
            process_ident(lsym, decl_ind, tabs_to_var, &spaced_expr,
                &force_nl, hd);
     copy_token:
diff -r 190df7507ea0 -r 83fff878789b usr.bin/indent/indent.h
--- a/usr.bin/indent/indent.h   Sun Oct 31 09:52:37 2021 +0000
+++ b/usr.bin/indent/indent.h   Sun Oct 31 10:00:37 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: indent.h,v 1.68 2021/10/31 09:52:37 rillig Exp $       */
+/*     $NetBSD: indent.h,v 1.69 2021/10/31 10:00:37 rillig Exp $       */
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -95,6 +95,7 @@
     lsym_tag,                  /* 'struct', 'union' or 'enum' */
     lsym_case_label,           /* 'case' or 'default' */
     lsym_string_prefix,                /* 'L' */
+    lsym_sizeof,
     lsym_ident,                        /* identifier, constant or string */
     lsym_funcname,
     lsym_do,
diff -r 190df7507ea0 -r 83fff878789b usr.bin/indent/lexi.c
--- a/usr.bin/indent/lexi.c     Sun Oct 31 09:52:37 2021 +0000
+++ b/usr.bin/indent/lexi.c     Sun Oct 31 10:00:37 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lexi.c,v 1.119 2021/10/31 09:52:37 rillig Exp $        */
+/*     $NetBSD: lexi.c,v 1.120 2021/10/31 10:00:37 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.119 2021/10/31 09:52:37 rillig Exp $");
+__RCSID("$NetBSD: lexi.c,v 1.120 2021/10/31 10:00:37 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/lexi.c 337862 2018-08-15 18:19:45Z pstef $");
 #endif
@@ -236,6 +236,7 @@
        "tag",
        "case_label",
        "string_prefix",
+       "sizeof",
        "ident",
        "funcname",
        "do",
@@ -534,6 +535,7 @@
        case kw_do:             return lsym_do;
        case kw_storage_class:  return lsym_storage_class;
        case kw_typedef:        return lsym_typedef;
+       case kw_sizeof:         return lsym_sizeof;
        default:                return lsym_ident;
        }
        /* INDENT ON */



Home | Main Index | Thread Index | Old Index