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: fix tokenizing of word-like tokens (s...
details: https://anonhg.NetBSD.org/src/rev/a69f04e95894
branches: trunk
changeset: 1026360:a69f04e95894
user: rillig <rillig%NetBSD.org@localhost>
date: Sat Nov 20 09:43:03 2021 +0000
description:
indent: fix tokenizing of word-like tokens (since 2019-04-04)
After a backslash-newline, the first character of the next line is only
part of the identifier if it is an identifier character.
indent-2000.10.11.14.46.04
| int var \
| +name = 4;
indent-2012.11.20.03.02.57
indent-2014.09.04.04.06.07
| int var \
| +name = 4;
indent-2019.02.03.03.19.29
indent-2019.04.04.15.27.35
| int var+name = 4;
indent-2021.11.19.20.23.17
indent
| int var + name = 4;
diffstat:
tests/usr.bin/indent/lsym_word.c | 4 ++--
usr.bin/indent/lexi.c | 22 ++++++++++------------
2 files changed, 12 insertions(+), 14 deletions(-)
diffs (59 lines):
diff -r 44aabdc4c777 -r a69f04e95894 tests/usr.bin/indent/lsym_word.c
--- a/tests/usr.bin/indent/lsym_word.c Sat Nov 20 09:27:18 2021 +0000
+++ b/tests/usr.bin/indent/lsym_word.c Sat Nov 20 09:43:03 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lsym_word.c,v 1.2 2021/11/20 09:27:18 rillig Exp $ */
+/* $NetBSD: lsym_word.c,v 1.3 2021/11/20 09:43:03 rillig Exp $ */
/* $FreeBSD$ */
/*
@@ -31,5 +31,5 @@
#indent end
#indent run
-int var+name = 4;
+int var + name = 4;
#indent end
diff -r 44aabdc4c777 -r a69f04e95894 usr.bin/indent/lexi.c
--- a/usr.bin/indent/lexi.c Sat Nov 20 09:27:18 2021 +0000
+++ b/usr.bin/indent/lexi.c Sat Nov 20 09:43:03 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lexi.c,v 1.148 2021/11/19 20:23:17 rillig Exp $ */
+/* $NetBSD: lexi.c,v 1.149 2021/11/20 09:43:03 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.148 2021/11/19 20:23:17 rillig Exp $");
+__RCSID("$NetBSD: lexi.c,v 1.149 2021/11/20 09:43:03 rillig Exp $");
#elif defined(__FreeBSD__)
__FBSDID("$FreeBSD: head/usr.bin/indent/lexi.c 337862 2018-08-15 18:19:45Z pstef $");
#endif
@@ -361,16 +361,14 @@
static void
lex_word(void)
{
- while (is_identifier_part(inp_peek()) || inp_peek() == '\\' ) {
- if (inp_peek() == '\\') {
- if (inp_lookahead(1) == '\n') {
- inp_skip();
- inp_skip();
- } else
- break;
- }
-
- token_add_char(inp_next());
+ for (;;) {
+ if (is_identifier_part(inp_peek()))
+ token_add_char(inp_next());
+ else if (inp_peek() == '\\' && inp_lookahead(1) == '\n') {
+ inp_skip();
+ inp_skip();
+ } else
+ return;
}
}
Home |
Main Index |
Thread Index |
Old Index