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 offsetof



details:   https://anonhg.NetBSD.org/src/rev/021effc032d6
branches:  trunk
changeset: 1024695:021effc032d6
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Oct 31 10:09:43 2021 +0000

description:
indent: add separate lexer symbol for offsetof

No functional change.

diffstat:

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

diffs (96 lines):

diff -r 4f2c342a132b -r 021effc032d6 usr.bin/indent/indent.c
--- a/usr.bin/indent/indent.c   Sun Oct 31 10:00:37 2021 +0000
+++ b/usr.bin/indent/indent.c   Sun Oct 31 10:09:43 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: indent.c,v 1.197 2021/10/31 10:00:37 rillig Exp $      */
+/*     $NetBSD: indent.c,v 1.198 2021/10/31 10:09:43 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.197 2021/10/31 10:00:37 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.198 2021/10/31 10:09:43 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
 #endif
@@ -741,15 +741,15 @@
        return false;
     if (ps.prev_token == lsym_rparen_or_rbracket)
        return false;
+    if (ps.prev_token == lsym_offsetof)
+       return opt.proc_calls_space;
     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)
        return true;
-    if (ps.prev_keyword == kw_sizeof)
-       return opt.blank_after_sizeof;
-    return ps.prev_keyword != kw_0 && ps.prev_keyword != kw_offsetof;
+    return ps.prev_keyword != kw_0;
 }
 
 static void
@@ -1497,6 +1497,7 @@
            process_type(&decl_ind, &tabs_to_var);
            goto copy_token;
 
+       case lsym_offsetof:
        case lsym_sizeof:
        case lsym_ident:
        case lsym_funcname:
diff -r 4f2c342a132b -r 021effc032d6 usr.bin/indent/indent.h
--- a/usr.bin/indent/indent.h   Sun Oct 31 10:00:37 2021 +0000
+++ b/usr.bin/indent/indent.h   Sun Oct 31 10:09:43 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: indent.h,v 1.69 2021/10/31 10:00:37 rillig Exp $       */
+/*     $NetBSD: indent.h,v 1.70 2021/10/31 10:09:43 rillig Exp $       */
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -96,6 +96,7 @@
     lsym_case_label,           /* 'case' or 'default' */
     lsym_string_prefix,                /* 'L' */
     lsym_sizeof,
+    lsym_offsetof,
     lsym_ident,                        /* identifier, constant or string */
     lsym_funcname,
     lsym_do,
diff -r 4f2c342a132b -r 021effc032d6 usr.bin/indent/lexi.c
--- a/usr.bin/indent/lexi.c     Sun Oct 31 10:00:37 2021 +0000
+++ b/usr.bin/indent/lexi.c     Sun Oct 31 10:09:43 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lexi.c,v 1.120 2021/10/31 10:00:37 rillig Exp $        */
+/*     $NetBSD: lexi.c,v 1.121 2021/10/31 10:09:43 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.120 2021/10/31 10:00:37 rillig Exp $");
+__RCSID("$NetBSD: lexi.c,v 1.121 2021/10/31 10:09:43 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/lexi.c 337862 2018-08-15 18:19:45Z pstef $");
 #endif
@@ -237,6 +237,7 @@
        "case_label",
        "string_prefix",
        "sizeof",
+       "offsetof",
        "ident",
        "funcname",
        "do",
@@ -535,6 +536,7 @@
        case kw_do:             return lsym_do;
        case kw_storage_class:  return lsym_storage_class;
        case kw_typedef:        return lsym_typedef;
+       case kw_offsetof:       return lsym_offsetof;
        case kw_sizeof:         return lsym_sizeof;
        default:                return lsym_ident;
        }



Home | Main Index | Thread Index | Old Index