Module Name: src Committed By: rillig Date: Sat Jun 19 08:37:18 UTC 2021
Modified Files: src/tests/usr.bin/xlint/lint1: lex_string.c lex_string.exp src/usr.bin/xlint/lint1: lex.c Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/lex_string.c \ src/tests/usr.bin/xlint/lint1/lex_string.exp cvs rdiff -u -r1.38 -r1.39 src/usr.bin/xlint/lint1/lex.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/tests/usr.bin/xlint/lint1/lex_string.c diff -u src/tests/usr.bin/xlint/lint1/lex_string.c:1.1 src/tests/usr.bin/xlint/lint1/lex_string.c:1.2 --- src/tests/usr.bin/xlint/lint1/lex_string.c:1.1 Sat Jun 19 08:30:08 2021 +++ src/tests/usr.bin/xlint/lint1/lex_string.c Sat Jun 19 08:37:18 2021 @@ -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 @@ test(void) 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 */ Index: src/tests/usr.bin/xlint/lint1/lex_string.exp diff -u src/tests/usr.bin/xlint/lint1/lex_string.exp:1.1 src/tests/usr.bin/xlint/lint1/lex_string.exp:1.2 --- src/tests/usr.bin/xlint/lint1/lex_string.exp:1.1 Sat Jun 19 08:30:08 2021 +++ src/tests/usr.bin/xlint/lint1/lex_string.exp Sat Jun 19 08:37:18 2021 @@ -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] Index: src/usr.bin/xlint/lint1/lex.c diff -u src/usr.bin/xlint/lint1/lex.c:1.38 src/usr.bin/xlint/lint1/lex.c:1.39 --- src/usr.bin/xlint/lint1/lex.c:1.38 Fri Jun 18 20:29:00 2021 +++ src/usr.bin/xlint/lint1/lex.c Sat Jun 19 08:37:18 2021 @@ -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 @@ lex_string(void) 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);