Browse Source

str: fix tests on unsigned chars, and !HAVE_ISBLANK.

Rusty Russell 14 years ago
parent
commit
00e61068e3

+ 1 - 2
ccan/str/test/compile_fail-isalnum.c

@@ -15,8 +15,7 @@ int main(int argc, char *argv[])
 
 
 #ifdef FAIL
 #ifdef FAIL
 	/* Fake fail on unsigned char platforms. */
 	/* Fake fail on unsigned char platforms. */
-	c = 255;
-	BUILD_ASSERT(c < 0);
+	BUILD_ASSERT((char)255 < 0);
 #endif
 #endif
 
 
 	return isalnum(c);
 	return isalnum(c);

+ 1 - 2
ccan/str/test/compile_fail-isalpha.c

@@ -15,8 +15,7 @@ int main(int argc, char *argv[])
 
 
 #ifdef FAIL
 #ifdef FAIL
 	/* Fake fail on unsigned char platforms. */
 	/* Fake fail on unsigned char platforms. */
-	c = 255;
-	BUILD_ASSERT(c < 0);
+	BUILD_ASSERT((char)255 < 0);
 #endif
 #endif
 
 
 	return isalpha(c);
 	return isalpha(c);

+ 1 - 2
ccan/str/test/compile_fail-isascii.c

@@ -15,8 +15,7 @@ int main(int argc, char *argv[])
 
 
 #ifdef FAIL
 #ifdef FAIL
 	/* Fake fail on unsigned char platforms. */
 	/* Fake fail on unsigned char platforms. */
-	c = 255;
-	BUILD_ASSERT(c < 0);
+	BUILD_ASSERT((char)255 < 0);
 #endif
 #endif
 
 
 	return isascii(c);
 	return isascii(c);

+ 6 - 3
ccan/str/test/compile_fail-isblank.c

@@ -4,7 +4,7 @@
 int main(int argc, char *argv[])
 int main(int argc, char *argv[])
 {
 {
 #ifdef FAIL
 #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.
 #error We need typeof to check isblank.
 #endif
 #endif
 	char
 	char
@@ -15,9 +15,12 @@ int main(int argc, char *argv[])
 
 
 #ifdef FAIL
 #ifdef FAIL
 	/* Fake fail on unsigned char platforms. */
 	/* Fake fail on unsigned char platforms. */
-	c = 255;
-	BUILD_ASSERT(c < 0);
+	BUILD_ASSERT((char)255 < 0);
 #endif
 #endif
 
 
+#if HAVE_ISBLANK
 	return isblank(c);
 	return isblank(c);
+#else
+	return c;
+#endif
 }
 }

+ 1 - 2
ccan/str/test/compile_fail-iscntrl.c

@@ -15,8 +15,7 @@ int main(int argc, char *argv[])
 
 
 #ifdef FAIL
 #ifdef FAIL
 	/* Fake fail on unsigned char platforms. */
 	/* Fake fail on unsigned char platforms. */
-	c = 255;
-	BUILD_ASSERT(c < 0);
+	BUILD_ASSERT((char)255 < 0);
 #endif
 #endif
 
 
 	return iscntrl(c);
 	return iscntrl(c);

+ 1 - 2
ccan/str/test/compile_fail-isdigit.c

@@ -15,8 +15,7 @@ int main(int argc, char *argv[])
 
 
 #ifdef FAIL
 #ifdef FAIL
 	/* Fake fail on unsigned char platforms. */
 	/* Fake fail on unsigned char platforms. */
-	c = 255;
-	BUILD_ASSERT(c < 0);
+	BUILD_ASSERT((char)255 < 0);
 #endif
 #endif
 
 
 	return isdigit(c);
 	return isdigit(c);

+ 1 - 2
ccan/str/test/compile_fail-islower.c

@@ -15,8 +15,7 @@ int main(int argc, char *argv[])
 
 
 #ifdef FAIL
 #ifdef FAIL
 	/* Fake fail on unsigned char platforms. */
 	/* Fake fail on unsigned char platforms. */
-	c = 255;
-	BUILD_ASSERT(c < 0);
+	BUILD_ASSERT((char)255 < 0);
 #endif
 #endif
 
 
 	return islower(c);
 	return islower(c);

+ 1 - 2
ccan/str/test/compile_fail-isprint.c

@@ -15,8 +15,7 @@ int main(int argc, char *argv[])
 
 
 #ifdef FAIL
 #ifdef FAIL
 	/* Fake fail on unsigned char platforms. */
 	/* Fake fail on unsigned char platforms. */
-	c = 255;
-	BUILD_ASSERT(c < 0);
+	BUILD_ASSERT((char)255 < 0);
 #endif
 #endif
 
 
 	return isprint(c);
 	return isprint(c);

+ 1 - 2
ccan/str/test/compile_fail-ispunct.c

@@ -15,8 +15,7 @@ int main(int argc, char *argv[])
 
 
 #ifdef FAIL
 #ifdef FAIL
 	/* Fake fail on unsigned char platforms. */
 	/* Fake fail on unsigned char platforms. */
-	c = 255;
-	BUILD_ASSERT(c < 0);
+	BUILD_ASSERT((char)255 < 0);
 #endif
 #endif
 
 
 	return ispunct(c);
 	return ispunct(c);

+ 1 - 2
ccan/str/test/compile_fail-isspace.c

@@ -15,8 +15,7 @@ int main(int argc, char *argv[])
 
 
 #ifdef FAIL
 #ifdef FAIL
 	/* Fake fail on unsigned char platforms. */
 	/* Fake fail on unsigned char platforms. */
-	c = 255;
-	BUILD_ASSERT(c < 0);
+	BUILD_ASSERT((char)255 < 0);
 #endif
 #endif
 
 
 	return isspace(c);
 	return isspace(c);

+ 1 - 2
ccan/str/test/compile_fail-isupper.c

@@ -15,8 +15,7 @@ int main(int argc, char *argv[])
 
 
 #ifdef FAIL
 #ifdef FAIL
 	/* Fake fail on unsigned char platforms. */
 	/* Fake fail on unsigned char platforms. */
-	c = 255;
-	BUILD_ASSERT(c < 0);
+	BUILD_ASSERT((char)255 < 0);
 #endif
 #endif
 
 
 	return isupper(c);
 	return isupper(c);

+ 1 - 2
ccan/str/test/compile_fail-isxdigit.c

@@ -15,8 +15,7 @@ int main(int argc, char *argv[])
 
 
 #ifdef FAIL
 #ifdef FAIL
 	/* Fake fail on unsigned char platforms. */
 	/* Fake fail on unsigned char platforms. */
-	c = 255;
-	BUILD_ASSERT(c < 0);
+	BUILD_ASSERT((char)255 < 0);
 #endif
 #endif
 
 
 	return isxdigit(c);
 	return isxdigit(c);

+ 1 - 0
tools/configurator/configurator.c

@@ -116,6 +116,7 @@ static struct test tests[] = {
 	  "#include <unistd.h>\n"
 	  "#include <unistd.h>\n"
 	  "static int func(void) { return getpagesize(); }" },
 	  "static int func(void) { return getpagesize(); }" },
 	{ "HAVE_ISBLANK", DEFINES_FUNC, NULL,
 	{ "HAVE_ISBLANK", DEFINES_FUNC, NULL,
+	  "#define _GNU_SOURCE\n"
 	  "#include <ctype.h>\n"
 	  "#include <ctype.h>\n"
 	  "static int func(void) { return isblank(' '); }" },
 	  "static int func(void) { return isblank(' '); }" },
 	{ "HAVE_LITTLE_ENDIAN", INSIDE_MAIN|EXECUTE, NULL,
 	{ "HAVE_LITTLE_ENDIAN", INSIDE_MAIN|EXECUTE, NULL,