Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/xlint/lint1 lint: revert fix for endless loop in lex...



details:   https://anonhg.NetBSD.org/src/rev/7282947f9e79
branches:  trunk
changeset: 984029:7282947f9e79
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Jun 19 08:37:18 2021 +0000

description:
lint: revert fix for endless loop in lexer for string literals

String literals may contain null bytes, and these must be passed further
on.

This reintroduces the endless loop in the lexer, but that must be fixed
in another way that doesn't destroy the error handling.

diffstat:

 tests/usr.bin/xlint/lint1/lex_string.c   |  13 +++----------
 tests/usr.bin/xlint/lint1/lex_string.exp |  10 ++--------
 usr.bin/xlint/lint1/lex.c                |   6 +++---
 3 files changed, 8 insertions(+), 21 deletions(-)

diffs (71 lines):

diff -r 3bd10af41c09 -r 7282947f9e79 tests/usr.bin/xlint/lint1/lex_string.c
--- a/tests/usr.bin/xlint/lint1/lex_string.c    Sat Jun 19 08:30:08 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/lex_string.c    Sat Jun 19 08:37:18 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lex_string.c,v 1.1 2021/06/19 08:30:08 rillig Exp $    */
+/*     $NetBSD: lex_string.c,v 1.2 2021/06/19 08:37:18 rillig Exp $    */
 # 3 "lex_string.c"
 
 /*
@@ -18,18 +18,11 @@
 
        sink("\0");
 
-       /* expect+5: unknown character \134 */
-       /* expect+4: syntax error '0' */
-       /* expect+3: unknown character \134 */
-       /* expect+2: unknown character \134 */
-       /* expect+1: unknown character \134 */
        sink("\0\0\0\0");
 
-       /* expect+1: unknown character \134 */
+       /* expect+1: no hex digits follow \x [74] */
        sink("\x");             /* unfinished */
 
-       /* expect+1: unknown character \134 */
+       /* expect+1: dubious escape \y [79] */
        sink("\y");             /* unknown escape sequence */
 }
-
-/* expect+1: cannot recover from previous errors */
diff -r 3bd10af41c09 -r 7282947f9e79 tests/usr.bin/xlint/lint1/lex_string.exp
--- a/tests/usr.bin/xlint/lint1/lex_string.exp  Sat Jun 19 08:30:08 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/lex_string.exp  Sat Jun 19 08:37:18 2021 +0000
@@ -1,8 +1,2 @@
-lex_string.c(26): error: unknown character \134 [250]
-lex_string.c(26): error: syntax error '0' [249]
-lex_string.c(26): error: unknown character \134 [250]
-lex_string.c(26): error: unknown character \134 [250]
-lex_string.c(26): error: unknown character \134 [250]
-lex_string.c(29): error: unknown character \134 [250]
-lex_string.c(32): error: unknown character \134 [250]
-lex_string.c(36): error: cannot recover from previous errors [224]
+lex_string.c(24): error: no hex digits follow \x [74]
+lex_string.c(27): warning: dubious escape \y [79]
diff -r 3bd10af41c09 -r 7282947f9e79 usr.bin/xlint/lint1/lex.c
--- a/usr.bin/xlint/lint1/lex.c Sat Jun 19 08:30:08 2021 +0000
+++ b/usr.bin/xlint/lint1/lex.c Sat Jun 19 08:37:18 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lex.c,v 1.38 2021/06/18 20:29:00 rillig Exp $ */
+/* $NetBSD: lex.c,v 1.39 2021/06/19 08:37:18 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -38,7 +38,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: lex.c,v 1.38 2021/06/18 20:29:00 rillig Exp $");
+__RCSID("$NetBSD: lex.c,v 1.39 2021/06/19 08:37:18 rillig Exp $");
 #endif
 
 #include <ctype.h>
@@ -1304,7 +1304,7 @@
        s = xmalloc(max = 64);
 
        len = 0;
-       while ((c = get_escaped_char('"')) > 0) {
+       while ((c = get_escaped_char('"')) >= 0) {
                /* +1 to reserve space for a trailing NUL character */
                if (len + 1 == max)
                        s = xrealloc(s, max *= 2);



Home | Main Index | Thread Index | Old Index