Module Name: src
Committed By: rillig
Date: Tue Mar 9 18:28:10 UTC 2021
Modified Files:
src/usr.bin/indent: indent.c indent_codes.h lexi.c
Log Message:
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.
To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/indent/indent_codes.h
cvs rdiff -u -r1.28 -r1.29 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.36 src/usr.bin/indent/indent.c:1.37
--- src/usr.bin/indent/indent.c:1.36 Tue Mar 9 16:48:28 2021
+++ src/usr.bin/indent/indent.c Tue Mar 9 18:28:10 2021
@@ -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 @@ static char sccsid[] = "@(#)indent.c 5.1
#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 @@ main(int argc, char **argv)
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 @@ check_type:
* 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 @@ check_type:
*/
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] != '}')) {
Index: src/usr.bin/indent/indent_codes.h
diff -u src/usr.bin/indent/indent_codes.h:1.8 src/usr.bin/indent/indent_codes.h:1.9
--- src/usr.bin/indent/indent_codes.h:1.8 Sun Mar 7 20:30:48 2021
+++ src/usr.bin/indent/indent_codes.h Tue Mar 9 18:28:10 2021
@@ -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 @@ typedef enum token_type {
preesc,
form_feed,
decl,
- sp_paren,
- sp_nparen,
+ keyword_for_if_while,
+ keyword_do_else,
ifstmt,
whilestmt,
forstmt,
Index: src/usr.bin/indent/lexi.c
diff -u src/usr.bin/indent/lexi.c:1.28 src/usr.bin/indent/lexi.c:1.29
--- src/usr.bin/indent/lexi.c:1.28 Tue Mar 9 16:48:28 2021
+++ src/usr.bin/indent/lexi.c Tue Mar 9 18:28:10 2021
@@ -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 @@ static char sccsid[] = "@(#)lexi.c 8.1 (
#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 @@ token_type_name(token_type tk)
"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 @@ lexi(struct parser_state *state)
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);