Module Name: src
Committed By: rillig
Date: Sat Feb 26 11:13:01 UTC 2022
Modified Files:
src/tests/usr.bin/xlint/lint1: msg_230.c msg_230_uchar.c
Log Message:
tests/lint: sync tests for platform-dependent character comparisons
To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/tests/usr.bin/xlint/lint1/msg_230.c
cvs rdiff -u -r1.6 -r1.7 src/tests/usr.bin/xlint/lint1/msg_230_uchar.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_230.c
diff -u src/tests/usr.bin/xlint/lint1/msg_230.c:1.10 src/tests/usr.bin/xlint/lint1/msg_230.c:1.11
--- src/tests/usr.bin/xlint/lint1/msg_230.c:1.10 Sat Oct 9 22:03:38 2021
+++ src/tests/usr.bin/xlint/lint1/msg_230.c Sat Feb 26 11:13:01 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: msg_230.c,v 1.10 2021/10/09 22:03:38 rillig Exp $ */
+/* $NetBSD: msg_230.c,v 1.11 2022/02/26 11:13:01 rillig Exp $ */
# 3 "msg_230.c"
// Test for message: nonportable character comparison '%s %d' [230]
@@ -71,7 +71,7 @@ compare_plain_char_yoda(char c)
}
void
-compare_lt(char c)
+compare_greater(char c)
{
/* expect+1: warning: nonportable character comparison '> -2' [230] */
Index: src/tests/usr.bin/xlint/lint1/msg_230_uchar.c
diff -u src/tests/usr.bin/xlint/lint1/msg_230_uchar.c:1.6 src/tests/usr.bin/xlint/lint1/msg_230_uchar.c:1.7
--- src/tests/usr.bin/xlint/lint1/msg_230_uchar.c:1.6 Thu Dec 16 21:14:59 2021
+++ src/tests/usr.bin/xlint/lint1/msg_230_uchar.c Sat Feb 26 11:13:01 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: msg_230_uchar.c,v 1.6 2021/12/16 21:14:59 rillig Exp $ */
+/* $NetBSD: msg_230_uchar.c,v 1.7 2022/02/26 11:13:01 rillig Exp $ */
# 3 "msg_230_uchar.c"
// Test for message: nonportable character comparison '%s %d' [230]
@@ -46,32 +46,32 @@ compare_plain_char(char c)
void
compare_plain_char_yoda(char c)
{
- /* expect+1: warning: nonportable character comparison '== -129' */
+ /* expect+1: warning: nonportable character comparison '== -129' [230] */
if (-129 == c)
return;
- /* expect+1: warning: nonportable character comparison '== -128' */
+ /* expect+1: warning: nonportable character comparison '== -128' [230] */
if (-128 == c)
return;
- /* expect+1: warning: nonportable character comparison '== -1' */
+ /* expect+1: warning: nonportable character comparison '== -1' [230] */
if (-1 == c)
return;
if (0 == c)
return;
if (127 == c)
return;
- /* expect+1: warning: nonportable character comparison '== 128' */
+ /* expect+1: warning: nonportable character comparison '== 128' [230] */
if (128 == c)
return;
- /* expect+1: warning: nonportable character comparison '== 255' */
+ /* expect+1: warning: nonportable character comparison '== 255' [230] */
if (255 == c)
return;
- /* expect+1: warning: nonportable character comparison '== 256' */
+ /* expect+1: warning: nonportable character comparison '== 256' [230] */
if (256 == c)
return;
}
void
-compare_lt(char c)
+compare_greater(char c)
{
/* expect+1: warning: nonportable character comparison '> -2' [230] */
@@ -116,3 +116,19 @@ compare_lt(char c)
if (c >= 129)
return;
}
+
+void
+compare_with_character_literal(char ch)
+{
+ /*
+ * These comparisons are portable since the character constant is
+ * interpreted using the type 'char' on the exact same platform as
+ * where the comparison takes place.
+ */
+ if (ch == '\200')
+ return;
+ if (ch == '\377')
+ return;
+ if (ch == '\000')
+ return;
+}