Module Name:    src
Committed By:   rillig
Date:           Tue Jun 29 07:23:21 UTC 2021

Modified Files:
        src/tests/usr.bin/xlint/lint1: msg_077.c msg_077.exp
        src/usr.bin/xlint/lint1: lex.c

Log Message:
lint: fix lexical analysis of character constants in traditional C

The code now follows the wording of the C Reference Manual from 1978.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/xlint/lint1/msg_077.c \
    src/tests/usr.bin/xlint/lint1/msg_077.exp
cvs rdiff -u -r1.46 -r1.47 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/msg_077.c
diff -u src/tests/usr.bin/xlint/lint1/msg_077.c:1.3 src/tests/usr.bin/xlint/lint1/msg_077.c:1.4
--- src/tests/usr.bin/xlint/lint1/msg_077.c:1.3	Tue Jun 29 07:17:43 2021
+++ src/tests/usr.bin/xlint/lint1/msg_077.c	Tue Jun 29 07:23:21 2021
@@ -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';
Index: src/tests/usr.bin/xlint/lint1/msg_077.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_077.exp:1.3 src/tests/usr.bin/xlint/lint1/msg_077.exp:1.4
--- src/tests/usr.bin/xlint/lint1/msg_077.exp:1.3	Tue Jun 29 07:17:43 2021
+++ src/tests/usr.bin/xlint/lint1/msg_077.exp	Tue Jun 29 07:23:21 2021
@@ -1 +1,2 @@
 msg_077.c(8): warning: bad octal digit 8 [77]
+msg_077.c(26): warning: multi-character character constant [294]

Index: src/usr.bin/xlint/lint1/lex.c
diff -u src/usr.bin/xlint/lint1/lex.c:1.46 src/usr.bin/xlint/lint1/lex.c:1.47
--- src/usr.bin/xlint/lint1/lex.c:1.46	Sun Jun 20 20:32:42 2021
+++ src/usr.bin/xlint/lint1/lex.c	Tue Jun 29 07:23:21 2021
@@ -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 */

Reply via email to