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 lexing of numbers that are spread...



details:   https://anonhg.NetBSD.org/src/rev/caf43dfdef47
branches:  trunk
changeset: 374822:caf43dfdef47
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat May 13 13:31:37 2023 +0000

description:
indent: fix lexing of numbers that are spread over multiple lines

diffstat:

 tests/usr.bin/indent/lex_number.c |   6 ++----
 usr.bin/indent/lexi.c             |  10 ++++++++--
 2 files changed, 10 insertions(+), 6 deletions(-)

diffs (50 lines):

diff -r 1ff6f3761b2f -r caf43dfdef47 tests/usr.bin/indent/lex_number.c
--- a/tests/usr.bin/indent/lex_number.c Sat May 13 13:24:01 2023 +0000
+++ b/tests/usr.bin/indent/lex_number.c Sat May 13 13:31:37 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lex_number.c,v 1.1 2023/05/13 13:24:01 rillig Exp $ */
+/* $NetBSD: lex_number.c,v 1.2 2023/05/13 13:31:37 rillig Exp $ */
 
 /*
  * Test lexing of numbers.
@@ -33,8 +33,6 @@ 3456\
 78;
 //indent end
 
-/* FIXME: properly unwrap numbers */
 //indent run -di0
-int wrapped = 0 \
-x12345678;
+int wrapped = 0x12345678;
 //indent end
diff -r 1ff6f3761b2f -r caf43dfdef47 usr.bin/indent/lexi.c
--- a/usr.bin/indent/lexi.c     Sat May 13 13:24:01 2023 +0000
+++ b/usr.bin/indent/lexi.c     Sat May 13 13:31:37 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lexi.c,v 1.178 2023/05/13 12:31:02 rillig Exp $        */
+/*     $NetBSD: lexi.c,v 1.179 2023/05/13 13:31: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.178 2023/05/13 12:31:02 rillig Exp $");
+__RCSID("$NetBSD: lexi.c,v 1.179 2023/05/13 13:31:37 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/lexi.c 337862 2018-08-15 18:19:45Z pstef $");
 #endif
@@ -206,6 +206,12 @@ lex_number(void)
 {
     for (unsigned char s = 'A'; s != 'f' && s != 'i' && s != 'u';) {
        unsigned char ch = (unsigned char)inp_peek();
+       if (ch == '\\' && inp_lookahead(1) == '\n') {
+           inp_skip();
+           inp_skip();
+           line_no++;
+           continue;
+       }
        if (ch >= array_length(lex_number_row) || lex_number_row[ch] == 0)
            break;
 



Home | Main Index | Thread Index | Old Index