Module Name: src
Committed By: rillig
Date: Sun Nov 28 14:29:03 UTC 2021
Modified Files:
src/distrib/sets/lists/tests: mi
src/tests/usr.bin/indent: Makefile
src/usr.bin/indent: indent.c indent.h lexi.c
Removed Files:
src/tests/usr.bin/indent: lsym_string_prefix.c
Log Message:
indent: treat L"string" as a single token
There is never whitespace between the 'L' and the string literal or the
character constant. There might be a backslash-newline between them, but
that case was not handled before either.
No functional change.
To generate a diff of this commit:
cvs rdiff -u -r1.1168 -r1.1169 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.34 -r1.35 src/tests/usr.bin/indent/Makefile
cvs rdiff -u -r1.1 -r0 src/tests/usr.bin/indent/lsym_string_prefix.c
cvs rdiff -u -r1.238 -r1.239 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.106 -r1.107 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.166 -r1.167 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/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.1168 src/distrib/sets/lists/tests/mi:1.1169
--- src/distrib/sets/lists/tests/mi:1.1168 Thu Nov 18 21:19:18 2021
+++ src/distrib/sets/lists/tests/mi Sun Nov 28 14:29:03 2021
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1168 2021/11/18 21:19:18 rillig Exp $
+# $NetBSD: mi,v 1.1169 2021/11/28 14:29:03 rillig Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@@ -4823,7 +4823,7 @@
./usr/tests/usr.bin/indent/lsym_semicolon.c tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/indent/lsym_sizeof.c tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/indent/lsym_storage_class.c tests-usr.bin-tests compattestfile,atf
-./usr/tests/usr.bin/indent/lsym_string_prefix.c tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/indent/lsym_string_prefix.c tests-obsolete obsolete,atf
./usr/tests/usr.bin/indent/lsym_switch.c tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/indent/lsym_tag.c tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/indent/lsym_type_in_parentheses.c tests-usr.bin-tests compattestfile,atf
Index: src/tests/usr.bin/indent/Makefile
diff -u src/tests/usr.bin/indent/Makefile:1.34 src/tests/usr.bin/indent/Makefile:1.35
--- src/tests/usr.bin/indent/Makefile:1.34 Thu Nov 18 21:19:19 2021
+++ src/tests/usr.bin/indent/Makefile Sun Nov 28 14:29:03 2021
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.34 2021/11/18 21:19:19 rillig Exp $
+# $NetBSD: Makefile,v 1.35 2021/11/28 14:29:03 rillig Exp $
.include <bsd.own.mk>
@@ -43,7 +43,6 @@ FILES+= lsym_rparen_or_rbracket.c
FILES+= lsym_semicolon.c
FILES+= lsym_sizeof.c
FILES+= lsym_storage_class.c
-FILES+= lsym_string_prefix.c
FILES+= lsym_switch.c
FILES+= lsym_tag.c
FILES+= lsym_type_in_parentheses.c
Index: src/usr.bin/indent/indent.c
diff -u src/usr.bin/indent/indent.c:1.238 src/usr.bin/indent/indent.c:1.239
--- src/usr.bin/indent/indent.c:1.238 Sun Nov 28 11:49:10 2021
+++ src/usr.bin/indent/indent.c Sun Nov 28 14:29:03 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: indent.c,v 1.238 2021/11/28 11:49:10 rillig Exp $ */
+/* $NetBSD: indent.c,v 1.239 2021/11/28 14:29:03 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.238 2021/11/28 11:49:10 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.239 2021/11/28 14:29:03 rillig Exp $");
#elif defined(__FreeBSD__)
__FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
#endif
@@ -1120,13 +1120,6 @@ copy_token(void)
}
static void
-process_string_prefix(void)
-{
- copy_token();
- ps.want_blank = false;
-}
-
-static void
process_period(void)
{
if (code.e > code.s && code.e[-1] == ',')
@@ -1440,10 +1433,6 @@ main_loop(void)
ps.want_blank = true;
break;
- case lsym_string_prefix:
- process_string_prefix();
- break;
-
case lsym_period:
process_period();
break;
Index: src/usr.bin/indent/indent.h
diff -u src/usr.bin/indent/indent.h:1.106 src/usr.bin/indent/indent.h:1.107
--- src/usr.bin/indent/indent.h:1.106 Sun Nov 28 11:49:10 2021
+++ src/usr.bin/indent/indent.h Sun Nov 28 14:29:03 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: indent.h,v 1.106 2021/11/28 11:49:10 rillig Exp $ */
+/* $NetBSD: indent.h,v 1.107 2021/11/28 14:29:03 rillig Exp $ */
/*-
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -96,7 +96,6 @@ typedef enum lexer_symbol {
lsym_type_in_parentheses,
lsym_tag, /* 'struct', 'union' or 'enum' */
lsym_case_label, /* 'case' or 'default' */
- lsym_string_prefix, /* 'L' */
lsym_sizeof,
lsym_offsetof,
lsym_word, /* identifier, constant or string */
Index: src/usr.bin/indent/lexi.c
diff -u src/usr.bin/indent/lexi.c:1.166 src/usr.bin/indent/lexi.c:1.167
--- src/usr.bin/indent/lexi.c:1.166 Sat Nov 27 20:58:16 2021
+++ src/usr.bin/indent/lexi.c Sun Nov 28 14:29:03 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: lexi.c,v 1.166 2021/11/27 20:58:16 rillig Exp $ */
+/* $NetBSD: lexi.c,v 1.167 2021/11/28 14:29:03 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.166 2021/11/27 20:58:16 rillig Exp $");
+__RCSID("$NetBSD: lexi.c,v 1.167 2021/11/28 14:29:03 rillig Exp $");
#elif defined(__FreeBSD__)
__FBSDID("$FreeBSD: head/usr.bin/indent/lexi.c 337862 2018-08-15 18:19:45Z pstef $");
#endif
@@ -219,7 +219,6 @@ lsym_name(lexer_symbol sym)
"type_in_parentheses",
"tag",
"case_label",
- "string_prefix",
"sizeof",
"offsetof",
"word",
@@ -500,15 +499,23 @@ lexi_alnum(void)
lex_number();
} else if (is_identifier_part(inp_peek())) {
lex_word();
+
+ if (token.s[0] == 'L' && token.e - token.s == 1 &&
+ (inp_peek() == '"' || inp_peek() == '\'')) {
+ token_add_char(inp_next());
+ lex_char_or_string();
+ ps.next_unary = false;
+
+ check_size_token(1);
+ *token.e = '\0';
+
+ return lsym_word;
+ }
} else
return lsym_eof; /* just as a placeholder */
*token.e = '\0';
- if (token.s[0] == 'L' && token.s[1] == '\0' &&
- (inp_peek() == '"' || inp_peek() == '\''))
- return lsym_string_prefix;
-
while (ch_isblank(inp_peek()))
inp_skip();