Module Name: src
Committed By: rillig
Date: Sun Oct 31 10:09:43 UTC 2021
Modified Files:
src/usr.bin/indent: indent.c indent.h lexi.c
Log Message:
indent: add separate lexer symbol for offsetof
No functional change.
To generate a diff of this commit:
cvs rdiff -u -r1.197 -r1.198 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.69 -r1.70 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.120 -r1.121 src/usr.bin/indent/lexi.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.bin/indent/indent.c
diff -u src/usr.bin/indent/indent.c:1.197 src/usr.bin/indent/indent.c:1.198
--- src/usr.bin/indent/indent.c:1.197 Sun Oct 31 10:00:37 2021
+++ src/usr.bin/indent/indent.c Sun Oct 31 10:09:43 2021
@@ -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 @@ static char sccsid[] = "@(#)indent.c 5.1
#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 @@ want_blank_before_lparen(void)
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 @@ main_loop(void)
process_type(&decl_ind, &tabs_to_var);
goto copy_token;
+ case lsym_offsetof:
case lsym_sizeof:
case lsym_ident:
case lsym_funcname:
Index: src/usr.bin/indent/indent.h
diff -u src/usr.bin/indent/indent.h:1.69 src/usr.bin/indent/indent.h:1.70
--- src/usr.bin/indent/indent.h:1.69 Sun Oct 31 10:00:37 2021
+++ src/usr.bin/indent/indent.h Sun Oct 31 10:09:43 2021
@@ -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 @@ typedef enum lexer_symbol {
lsym_case_label, /* 'case' or 'default' */
lsym_string_prefix, /* 'L' */
lsym_sizeof,
+ lsym_offsetof,
lsym_ident, /* identifier, constant or string */
lsym_funcname,
lsym_do,
Index: src/usr.bin/indent/lexi.c
diff -u src/usr.bin/indent/lexi.c:1.120 src/usr.bin/indent/lexi.c:1.121
--- src/usr.bin/indent/lexi.c:1.120 Sun Oct 31 10:00:37 2021
+++ src/usr.bin/indent/lexi.c Sun Oct 31 10:09:43 2021
@@ -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 @@ static char sccsid[] = "@(#)lexi.c 8.1 (
#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 @@ lsym_name(lexer_symbol sym)
"case_label",
"string_prefix",
"sizeof",
+ "offsetof",
"ident",
"funcname",
"do",
@@ -535,6 +536,7 @@ lexi_alnum(void)
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;
}