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 lexical analysis of character ...
details: https://anonhg.NetBSD.org/src/rev/8dd7665b3cdc
branches: trunk
changeset: 379957:8dd7665b3cdc
user: rillig <rillig%NetBSD.org@localhost>
date: Tue Jun 29 07:23:21 2021 +0000
description:
lint: fix lexical analysis of character constants in traditional C
The code now follows the wording of the C Reference Manual from 1978.
diffstat:
tests/usr.bin/xlint/lint1/msg_077.c | 3 ++-
tests/usr.bin/xlint/lint1/msg_077.exp | 1 +
usr.bin/xlint/lint1/lex.c | 9 +++------
3 files changed, 6 insertions(+), 7 deletions(-)
diffs (51 lines):
diff -r 3ae4cc8f2652 -r 8dd7665b3cdc tests/usr.bin/xlint/lint1/msg_077.c
--- a/tests/usr.bin/xlint/lint1/msg_077.c Tue Jun 29 07:17:43 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_077.c Tue Jun 29 07:23:21 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: msg_077.c,v 1.3 2021/06/29 07:17:43 rillig Exp $ */
+/* $NetBSD: msg_077.c,v 1.4 2021/06/29 07:23:21 rillig Exp $ */
# 3 "msg_077.c"
/* Test for message: bad octal digit %c [77] */
@@ -22,4 +22,5 @@ char single_digit = '\8'; /* expect: bad
* anyway.
* https://mail-index.netbsd.org/tech-toolchain/2021/03/16/msg003933.html
*/
+/* expect+1: multi-character character constant [294] */
char several_digits = '\08';
diff -r 3ae4cc8f2652 -r 8dd7665b3cdc tests/usr.bin/xlint/lint1/msg_077.exp
--- a/tests/usr.bin/xlint/lint1/msg_077.exp Tue Jun 29 07:17:43 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_077.exp Tue Jun 29 07:23:21 2021 +0000
@@ -1,1 +1,2 @@
msg_077.c(8): warning: bad octal digit 8 [77]
+msg_077.c(26): warning: multi-character character constant [294]
diff -r 3ae4cc8f2652 -r 8dd7665b3cdc usr.bin/xlint/lint1/lex.c
--- a/usr.bin/xlint/lint1/lex.c Tue Jun 29 07:17:43 2021 +0000
+++ b/usr.bin/xlint/lint1/lex.c Tue Jun 29 07:23:21 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lex.c,v 1.46 2021/06/20 20:32:42 rillig Exp $ */
+/* $NetBSD: lex.c,v 1.47 2021/06/29 07:23:21 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.46 2021/06/20 20:32:42 rillig Exp $");
+__RCSID("$NetBSD: lex.c,v 1.47 2021/06/29 07:23:21 rillig Exp $");
#endif
#include <ctype.h>
@@ -987,10 +987,7 @@ get_escaped_char(int delim)
do {
v = (v << 3) + (c - '0');
c = inpc();
- } while (--n > 0 && isdigit(c) && (tflag || c <= '7'));
- if (tflag && n > 0 && isdigit(c))
- /* bad octal digit %c */
- warning(77, c);
+ } while (--n > 0 && '0' <= c && c <= '7');
pbc = c;
if (v > TARG_UCHAR_MAX) {
/* character escape does not fit in character */
Home |
Main Index |
Thread Index |
Old Index