From 00e61068e33e7883a2657744514452a32660d461 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Wed, 27 Apr 2011 16:05:43 +0930 Subject: [PATCH] str: fix tests on unsigned chars, and !HAVE_ISBLANK. --- ccan/str/test/compile_fail-isalnum.c | 3 +-- ccan/str/test/compile_fail-isalpha.c | 3 +-- ccan/str/test/compile_fail-isascii.c | 3 +-- ccan/str/test/compile_fail-isblank.c | 9 ++++++--- ccan/str/test/compile_fail-iscntrl.c | 3 +-- ccan/str/test/compile_fail-isdigit.c | 3 +-- ccan/str/test/compile_fail-islower.c | 3 +-- ccan/str/test/compile_fail-isprint.c | 3 +-- ccan/str/test/compile_fail-ispunct.c | 3 +-- ccan/str/test/compile_fail-isspace.c | 3 +-- ccan/str/test/compile_fail-isupper.c | 3 +-- ccan/str/test/compile_fail-isxdigit.c | 3 +-- tools/configurator/configurator.c | 1 + 13 files changed, 18 insertions(+), 25 deletions(-) diff --git a/ccan/str/test/compile_fail-isalnum.c b/ccan/str/test/compile_fail-isalnum.c index 1b6a3633..930defff 100644 --- a/ccan/str/test/compile_fail-isalnum.c +++ b/ccan/str/test/compile_fail-isalnum.c @@ -15,8 +15,7 @@ int main(int argc, char *argv[]) #ifdef FAIL /* Fake fail on unsigned char platforms. */ - c = 255; - BUILD_ASSERT(c < 0); + BUILD_ASSERT((char)255 < 0); #endif return isalnum(c); diff --git a/ccan/str/test/compile_fail-isalpha.c b/ccan/str/test/compile_fail-isalpha.c index 76de1504..20051098 100644 --- a/ccan/str/test/compile_fail-isalpha.c +++ b/ccan/str/test/compile_fail-isalpha.c @@ -15,8 +15,7 @@ int main(int argc, char *argv[]) #ifdef FAIL /* Fake fail on unsigned char platforms. */ - c = 255; - BUILD_ASSERT(c < 0); + BUILD_ASSERT((char)255 < 0); #endif return isalpha(c); diff --git a/ccan/str/test/compile_fail-isascii.c b/ccan/str/test/compile_fail-isascii.c index af6e64d5..ee55e499 100644 --- a/ccan/str/test/compile_fail-isascii.c +++ b/ccan/str/test/compile_fail-isascii.c @@ -15,8 +15,7 @@ int main(int argc, char *argv[]) #ifdef FAIL /* Fake fail on unsigned char platforms. */ - c = 255; - BUILD_ASSERT(c < 0); + BUILD_ASSERT((char)255 < 0); #endif return isascii(c); diff --git a/ccan/str/test/compile_fail-isblank.c b/ccan/str/test/compile_fail-isblank.c index 86a33503..f4cb961d 100644 --- a/ccan/str/test/compile_fail-isblank.c +++ b/ccan/str/test/compile_fail-isblank.c @@ -4,7 +4,7 @@ int main(int argc, char *argv[]) { #ifdef FAIL -#if !HAVE_BUILTIN_TYPES_COMPATIBLE_P || !HAVE_TYPEOF +#if !HAVE_BUILTIN_TYPES_COMPATIBLE_P || !HAVE_TYPEOF || !HAVE_ISBLANK #error We need typeof to check isblank. #endif char @@ -15,9 +15,12 @@ int main(int argc, char *argv[]) #ifdef FAIL /* Fake fail on unsigned char platforms. */ - c = 255; - BUILD_ASSERT(c < 0); + BUILD_ASSERT((char)255 < 0); #endif +#if HAVE_ISBLANK return isblank(c); +#else + return c; +#endif } diff --git a/ccan/str/test/compile_fail-iscntrl.c b/ccan/str/test/compile_fail-iscntrl.c index 5ae783b1..bc741465 100644 --- a/ccan/str/test/compile_fail-iscntrl.c +++ b/ccan/str/test/compile_fail-iscntrl.c @@ -15,8 +15,7 @@ int main(int argc, char *argv[]) #ifdef FAIL /* Fake fail on unsigned char platforms. */ - c = 255; - BUILD_ASSERT(c < 0); + BUILD_ASSERT((char)255 < 0); #endif return iscntrl(c); diff --git a/ccan/str/test/compile_fail-isdigit.c b/ccan/str/test/compile_fail-isdigit.c index 68d81ba4..71d1c714 100644 --- a/ccan/str/test/compile_fail-isdigit.c +++ b/ccan/str/test/compile_fail-isdigit.c @@ -15,8 +15,7 @@ int main(int argc, char *argv[]) #ifdef FAIL /* Fake fail on unsigned char platforms. */ - c = 255; - BUILD_ASSERT(c < 0); + BUILD_ASSERT((char)255 < 0); #endif return isdigit(c); diff --git a/ccan/str/test/compile_fail-islower.c b/ccan/str/test/compile_fail-islower.c index 9dec95f6..ca3f9907 100644 --- a/ccan/str/test/compile_fail-islower.c +++ b/ccan/str/test/compile_fail-islower.c @@ -15,8 +15,7 @@ int main(int argc, char *argv[]) #ifdef FAIL /* Fake fail on unsigned char platforms. */ - c = 255; - BUILD_ASSERT(c < 0); + BUILD_ASSERT((char)255 < 0); #endif return islower(c); diff --git a/ccan/str/test/compile_fail-isprint.c b/ccan/str/test/compile_fail-isprint.c index 30f7639c..6432e41d 100644 --- a/ccan/str/test/compile_fail-isprint.c +++ b/ccan/str/test/compile_fail-isprint.c @@ -15,8 +15,7 @@ int main(int argc, char *argv[]) #ifdef FAIL /* Fake fail on unsigned char platforms. */ - c = 255; - BUILD_ASSERT(c < 0); + BUILD_ASSERT((char)255 < 0); #endif return isprint(c); diff --git a/ccan/str/test/compile_fail-ispunct.c b/ccan/str/test/compile_fail-ispunct.c index f1ae13ac..5d941fcb 100644 --- a/ccan/str/test/compile_fail-ispunct.c +++ b/ccan/str/test/compile_fail-ispunct.c @@ -15,8 +15,7 @@ int main(int argc, char *argv[]) #ifdef FAIL /* Fake fail on unsigned char platforms. */ - c = 255; - BUILD_ASSERT(c < 0); + BUILD_ASSERT((char)255 < 0); #endif return ispunct(c); diff --git a/ccan/str/test/compile_fail-isspace.c b/ccan/str/test/compile_fail-isspace.c index c94c49e4..bfee1f89 100644 --- a/ccan/str/test/compile_fail-isspace.c +++ b/ccan/str/test/compile_fail-isspace.c @@ -15,8 +15,7 @@ int main(int argc, char *argv[]) #ifdef FAIL /* Fake fail on unsigned char platforms. */ - c = 255; - BUILD_ASSERT(c < 0); + BUILD_ASSERT((char)255 < 0); #endif return isspace(c); diff --git a/ccan/str/test/compile_fail-isupper.c b/ccan/str/test/compile_fail-isupper.c index f23dd659..4cf9fd35 100644 --- a/ccan/str/test/compile_fail-isupper.c +++ b/ccan/str/test/compile_fail-isupper.c @@ -15,8 +15,7 @@ int main(int argc, char *argv[]) #ifdef FAIL /* Fake fail on unsigned char platforms. */ - c = 255; - BUILD_ASSERT(c < 0); + BUILD_ASSERT((char)255 < 0); #endif return isupper(c); diff --git a/ccan/str/test/compile_fail-isxdigit.c b/ccan/str/test/compile_fail-isxdigit.c index 6a7377fd..65e6006a 100644 --- a/ccan/str/test/compile_fail-isxdigit.c +++ b/ccan/str/test/compile_fail-isxdigit.c @@ -15,8 +15,7 @@ int main(int argc, char *argv[]) #ifdef FAIL /* Fake fail on unsigned char platforms. */ - c = 255; - BUILD_ASSERT(c < 0); + BUILD_ASSERT((char)255 < 0); #endif return isxdigit(c); diff --git a/tools/configurator/configurator.c b/tools/configurator/configurator.c index 7b9652be..b78b112f 100644 --- a/tools/configurator/configurator.c +++ b/tools/configurator/configurator.c @@ -116,6 +116,7 @@ static struct test tests[] = { "#include \n" "static int func(void) { return getpagesize(); }" }, { "HAVE_ISBLANK", DEFINES_FUNC, NULL, + "#define _GNU_SOURCE\n" "#include \n" "static int func(void) { return isblank(' '); }" }, { "HAVE_LITTLE_ENDIAN", INSIDE_MAIN|EXECUTE, NULL, -- 2.39.2