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: fix check for empty wide character...



details:   https://anonhg.NetBSD.org/src/rev/0a20c60a889d
branches:  trunk
changeset: 1021839:0a20c60a889d
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Jun 20 18:38:12 2021 +0000

description:
lint: fix check for empty wide character constant

This bug got almost 26 years old, it was already there at the initial
commit in 1995.

diffstat:

 tests/usr.bin/xlint/lint1/lex_wide_char.c   |  7 +++----
 tests/usr.bin/xlint/lint1/lex_wide_char.exp |  4 +++-
 usr.bin/xlint/lint1/lex.c                   |  6 +++---
 3 files changed, 9 insertions(+), 8 deletions(-)

diffs (70 lines):

diff -r d978e8a0b347 -r 0a20c60a889d tests/usr.bin/xlint/lint1/lex_wide_char.c
--- a/tests/usr.bin/xlint/lint1/lex_wide_char.c Sun Jun 20 18:23:07 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/lex_wide_char.c Sun Jun 20 18:38:12 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lex_wide_char.c,v 1.1 2021/06/19 08:30:08 rillig Exp $ */
+/*     $NetBSD: lex_wide_char.c,v 1.2 2021/06/20 18:38:12 rillig Exp $ */
 # 3 "lex_wide_char.c"
 
 /*
@@ -12,7 +12,7 @@
 void
 test(void)
 {
-       /* TODO: expect+1: empty character constant */
+       /* expect+1: empty character constant */
        sink(L'');
 
        sink(L'a');
@@ -22,7 +22,6 @@
        /* UTF-8 */
        /* expect+1: too many characters in character constant */
        sink(L'ä');
-       /* rescue the parser: ' */
 
        /* GCC extension */
        /* expect+1: dubious escape \e */
@@ -37,6 +36,6 @@
        /* newline */
        sink(L'\n');
 
-       /* TODO: expect+1: empty character constant */
+       /* expect+1: empty character constant */
        sink(L'');
 }
diff -r d978e8a0b347 -r 0a20c60a889d tests/usr.bin/xlint/lint1/lex_wide_char.exp
--- a/tests/usr.bin/xlint/lint1/lex_wide_char.exp       Sun Jun 20 18:23:07 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/lex_wide_char.exp       Sun Jun 20 18:38:12 2021 +0000
@@ -1,2 +1,4 @@
+lex_wide_char.c(16): error: empty character constant [73]
 lex_wide_char.c(24): error: too many characters in character constant [71]
-lex_wide_char.c(29): warning: dubious escape \e [79]
+lex_wide_char.c(28): warning: dubious escape \e [79]
+lex_wide_char.c(40): error: empty character constant [73]
diff -r d978e8a0b347 -r 0a20c60a889d usr.bin/xlint/lint1/lex.c
--- a/usr.bin/xlint/lint1/lex.c Sun Jun 20 18:23:07 2021 +0000
+++ b/usr.bin/xlint/lint1/lex.c Sun Jun 20 18:38:12 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lex.c,v 1.41 2021/06/19 20:25:58 rillig Exp $ */
+/* $NetBSD: lex.c,v 1.42 2021/06/20 18:38:12 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.41 2021/06/19 20:25:58 rillig Exp $");
+__RCSID("$NetBSD: lex.c,v 1.42 2021/06/20 18:38:12 rillig Exp $");
 #endif
 
 #include <ctype.h>
@@ -881,7 +881,7 @@
        if (c == -2) {
                /* unterminated character constant */
                error(253);
-       } else if (c == 0) {
+       } else if (i == 0) {
                /* empty character constant */
                error(73);
        } else {



Home | Main Index | Thread Index | Old Index