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: condense code for building tokens fro...
details: https://anonhg.NetBSD.org/src/rev/68c861a675d5
branches: trunk
changeset: 1026459:68c861a675d5
user: rillig <rillig%NetBSD.org@localhost>
date: Thu Nov 25 17:35:46 2021 +0000
description:
indent: condense code for building tokens from characters
No functional change.
diffstat:
usr.bin/indent/lexi.c | 80 +++++++++++++++-----------------------------------
1 files changed, 24 insertions(+), 56 deletions(-)
diffs (116 lines):
diff -r bd1257a8b4ab -r 68c861a675d5 usr.bin/indent/lexi.c
--- a/usr.bin/indent/lexi.c Thu Nov 25 17:28:13 2021 +0000
+++ b/usr.bin/indent/lexi.c Thu Nov 25 17:35:46 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lexi.c,v 1.159 2021/11/25 17:28:13 rillig Exp $ */
+/* $NetBSD: lexi.c,v 1.160 2021/11/25 17:35:46 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.159 2021/11/25 17:28:13 rillig Exp $");
+__RCSID("$NetBSD: lexi.c,v 1.160 2021/11/25 17:35:46 rillig Exp $");
#elif defined(__FreeBSD__)
__FBSDID("$FreeBSD: head/usr.bin/indent/lexi.c 337862 2018-08-15 18:19:45Z pstef $");
#endif
@@ -579,6 +579,21 @@
bool next_unary;
switch (token.e[-1]) {
+
+ /* INDENT OFF */
+ case '(':
+ case '[': lsym = lsym_lparen_or_lbracket; next_unary = true; break;
+ case ')':
+ case ']': lsym = lsym_rparen_or_rbracket; next_unary = false; break;
+ case '?': lsym = lsym_question; next_unary = true; break;
+ case ':': lsym = lsym_colon; next_unary = true; break;
+ case ';': lsym = lsym_semicolon; next_unary = true; break;
+ case '{': lsym = lsym_lbrace; next_unary = true; break;
+ case '}': lsym = lsym_rbrace; next_unary = true; break;
+ case ',': lsym = lsym_comma; next_unary = true; break;
+ case '.': lsym = lsym_period; next_unary = false; break;
+ /* INDENT ON */
+
case '\n':
/* if data has been exhausted, the '\n' is a dummy. */
lsym = had_eof ? lsym_eof : lsym_newline;
@@ -586,68 +601,21 @@
ps.next_col_1 = true;
break;
- case '\'':
- case '"':
- lex_char_or_string();
- lsym = lsym_word;
- next_unary = false;
- break;
-
- case '(':
- case '[':
- lsym = lsym_lparen_or_lbracket;
- next_unary = true;
- break;
-
- case ')':
- case ']':
- lsym = lsym_rparen_or_rbracket;
- next_unary = false;
- break;
-
- case '#':
- lsym = lsym_preprocessing;
- next_unary = ps.next_unary;
- break;
-
- case '?':
- lsym = lsym_question;
- next_unary = true;
- break;
-
- case ':':
- lsym = lsym_colon;
- next_unary = true;
- break;
-
- case ';':
- lsym = lsym_semicolon;
- next_unary = true;
- break;
-
- case '{':
- lsym = lsym_lbrace;
- next_unary = true;
- break;
-
- case '}':
- lsym = lsym_rbrace;
- next_unary = true;
- break;
-
case '\f':
lsym = lsym_form_feed;
next_unary = ps.next_unary;
ps.next_col_1 = true;
break;
- case ',':
- lsym = lsym_comma;
- next_unary = true;
+ case '#':
+ lsym = lsym_preprocessing;
+ next_unary = ps.next_unary;
break;
- case '.':
- lsym = lsym_period;
+ case '\'':
+ case '"':
+ lex_char_or_string();
+ lsym = lsym_word;
next_unary = false;
break;
Home |
Main Index |
Thread Index |
Old Index