tests/lint: sync tests for platform-dependent character comparisons
This commit is contained in:
parent
3e1a285a2f
commit
d6ea25cda3
|
@ -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"
|
# 3 "msg_230.c"
|
||||||
|
|
||||||
// Test for message: nonportable character comparison '%s %d' [230]
|
// Test for message: nonportable character comparison '%s %d' [230]
|
||||||
|
@ -71,7 +71,7 @@ compare_plain_char_yoda(char c)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
compare_lt(char c)
|
compare_greater(char c)
|
||||||
{
|
{
|
||||||
|
|
||||||
/* expect+1: warning: nonportable character comparison '> -2' [230] */
|
/* expect+1: warning: nonportable character comparison '> -2' [230] */
|
||||||
|
|
|
@ -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"
|
# 3 "msg_230_uchar.c"
|
||||||
|
|
||||||
// Test for message: nonportable character comparison '%s %d' [230]
|
// Test for message: nonportable character comparison '%s %d' [230]
|
||||||
|
@ -46,32 +46,32 @@ compare_plain_char(char c)
|
||||||
void
|
void
|
||||||
compare_plain_char_yoda(char c)
|
compare_plain_char_yoda(char c)
|
||||||
{
|
{
|
||||||
/* expect+1: warning: nonportable character comparison '== -129' */
|
/* expect+1: warning: nonportable character comparison '== -129' [230] */
|
||||||
if (-129 == c)
|
if (-129 == c)
|
||||||
return;
|
return;
|
||||||
/* expect+1: warning: nonportable character comparison '== -128' */
|
/* expect+1: warning: nonportable character comparison '== -128' [230] */
|
||||||
if (-128 == c)
|
if (-128 == c)
|
||||||
return;
|
return;
|
||||||
/* expect+1: warning: nonportable character comparison '== -1' */
|
/* expect+1: warning: nonportable character comparison '== -1' [230] */
|
||||||
if (-1 == c)
|
if (-1 == c)
|
||||||
return;
|
return;
|
||||||
if (0 == c)
|
if (0 == c)
|
||||||
return;
|
return;
|
||||||
if (127 == c)
|
if (127 == c)
|
||||||
return;
|
return;
|
||||||
/* expect+1: warning: nonportable character comparison '== 128' */
|
/* expect+1: warning: nonportable character comparison '== 128' [230] */
|
||||||
if (128 == c)
|
if (128 == c)
|
||||||
return;
|
return;
|
||||||
/* expect+1: warning: nonportable character comparison '== 255' */
|
/* expect+1: warning: nonportable character comparison '== 255' [230] */
|
||||||
if (255 == c)
|
if (255 == c)
|
||||||
return;
|
return;
|
||||||
/* expect+1: warning: nonportable character comparison '== 256' */
|
/* expect+1: warning: nonportable character comparison '== 256' [230] */
|
||||||
if (256 == c)
|
if (256 == c)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
compare_lt(char c)
|
compare_greater(char c)
|
||||||
{
|
{
|
||||||
|
|
||||||
/* expect+1: warning: nonportable character comparison '> -2' [230] */
|
/* expect+1: warning: nonportable character comparison '> -2' [230] */
|
||||||
|
@ -116,3 +116,19 @@ compare_lt(char c)
|
||||||
if (c >= 129)
|
if (c >= 129)
|
||||||
return;
|
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;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue