C spec requires the ctype functions to be valid for unsigned chars, so
authorDavid Given <dg@cowlark.com>
Tue, 17 Mar 2015 20:20:27 +0000 (21:20 +0100)
committerDavid Given <dg@cowlark.com>
Tue, 17 Mar 2015 20:20:27 +0000 (21:20 +0100)
casting to char is invalid. We cast to uint8_t instead. Bonus: smaller
code!

--HG--
extra : source : b75c83c0539dd462bee151beab76938eca046294

12 files changed:
Library/libs/isalnum.c
Library/libs/isalpha.c
Library/libs/isascii.c
Library/libs/iscntrl.c
Library/libs/isdigit.c
Library/libs/isgraph.c
Library/libs/islower.c
Library/libs/isoctal.c
Library/libs/ispunct.c
Library/libs/isspace.c
Library/libs/isupper.c
Library/libs/isxdigit.c

index e3d2cf0..511038d 100644 (file)
@@ -1,3 +1,4 @@
+#include <stdint.h>
 #include <ctype.h>
 
 int isalnum(int c)
index 0980d09..07208ce 100644 (file)
@@ -1,3 +1,4 @@
+#include <stdint.h>
 #include <ctype.h>
 
 int isalpha(int c)
index b4278f0..2bc3805 100644 (file)
@@ -1,7 +1,9 @@
+#include <stdint.h>
 #include <ctype.h>
 
 int isascii(int c)
 {
-       return (c >= 0) && (c <= 127);
+       uint8_t cb = c;
+       return (cb >= 0) && (cb <= 127);
 }
 
index 4d770e9..a0f7d30 100644 (file)
@@ -1,7 +1,8 @@
+#include <stdint.h>
 #include <ctype.h>
 
 int iscntrl(int c)
 {
-       char bc = c;
+       uint8_t bc = c;
        return ((bc >= 0) && (bc <= 31)) || (bc == 127);
 }
index 7a3a2a9..669bb28 100644 (file)
@@ -1,8 +1,9 @@
+#include <stdint.h>
 #include <ctype.h>
 
 int isdigit(int c)
 {
-       char bc = c;
+       uint8_t bc = c;
        return (bc >= '0') && (bc <= '9');
 }
 
index d566013..fdc776e 100644 (file)
@@ -1,3 +1,4 @@
+#include <stdint.h>
 #include <ctype.h>
 
 int isgraph(int c)
index b63fce0..ba78d10 100644 (file)
@@ -1,7 +1,8 @@
+#include <stdint.h>
 #include <ctype.h>
 
 int islower(int c)
 {
-       char bc = c;
+       uint8_t bc = c;
        return (bc >= 'a') && (bc <= 'z');
 }
index 3d69a06..a1a8622 100644 (file)
@@ -1,8 +1,9 @@
+#include <stdint.h>
 #include <ctype.h>
 
 int isoctal(int c)
 {
-       char bc = c;
+       uint8_t bc = c;
        return (bc >= '0') && (bc <= '7');
 }
 
index be72ef8..2c88fa4 100644 (file)
@@ -1,3 +1,4 @@
+#include <stdint.h>
 #include <ctype.h>
 
 int ispunct(int c)
index 6cba2db..8cadeb5 100644 (file)
@@ -1,3 +1,4 @@
+#include <stdint.h>
 #include <ctype.h>
 #include <string.h>
 
index d2d3dd8..0dad20d 100644 (file)
@@ -1,7 +1,8 @@
+#include <stdint.h>
 #include <ctype.h>
 
 int isupper(int c)
 {
-       char bc = c;
+       uint8_t bc = c;
        return (bc >= 'A') && (bc <= 'Z');
 }
index 3da08f3..483e64b 100644 (file)
@@ -1,8 +1,9 @@
+#include <stdint.h>
 #include <ctype.h>
 
 int isxdigit(int c)
 {
-       char bc = c;
+       uint8_t bc = c;
        return isdigit(bc)
                || ((bc >= 'a') && (bc <= 'f'))
                || ((bc >= 'A') && (bc <= 'F'));