Module Name: src
Committed By: rillig
Date: Sun Oct 31 10:00:38 UTC 2021
Modified Files:
src/usr.bin/indent: indent.c indent.h lexi.c
Log Message:
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.
To generate a diff of this commit:
cvs rdiff -u -r1.196 -r1.197 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.68 -r1.69 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.119 -r1.120 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.196 src/usr.bin/indent/indent.c:1.197
--- src/usr.bin/indent/indent.c:1.196 Sat Oct 30 23:27:33 2021
+++ src/usr.bin/indent/indent.c Sun Oct 31 10:00:37 2021
@@ -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 @@ static char sccsid[] = "@(#)indent.c 5.1
#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 @@ want_blank_before_lparen(void)
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 @@ main_loop(void)
process_type(&decl_ind, &tabs_to_var);
goto copy_token;
- case lsym_funcname:
+ case lsym_sizeof:
case lsym_ident:
+ case lsym_funcname:
process_ident(lsym, decl_ind, tabs_to_var, &spaced_expr,
&force_nl, hd);
copy_token:
Index: src/usr.bin/indent/indent.h
diff -u src/usr.bin/indent/indent.h:1.68 src/usr.bin/indent/indent.h:1.69
--- src/usr.bin/indent/indent.h:1.68 Sun Oct 31 09:52:37 2021
+++ src/usr.bin/indent/indent.h Sun Oct 31 10:00:37 2021
@@ -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 @@ typedef enum lexer_symbol {
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,
Index: src/usr.bin/indent/lexi.c
diff -u src/usr.bin/indent/lexi.c:1.119 src/usr.bin/indent/lexi.c:1.120
--- src/usr.bin/indent/lexi.c:1.119 Sun Oct 31 09:52:37 2021
+++ src/usr.bin/indent/lexi.c Sun Oct 31 10:00:37 2021
@@ -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 @@ static char sccsid[] = "@(#)lexi.c 8.1 (
#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 @@ lsym_name(lexer_symbol sym)
"tag",
"case_label",
"string_prefix",
+ "sizeof",
"ident",
"funcname",
"do",
@@ -534,6 +535,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_sizeof: return lsym_sizeof;
default: return lsym_ident;
}
/* INDENT ON */