chiark / gitweb /
Fix incorrect uses of ctype.h (passing it uncast chars, or other
authorSimon Tatham <anakin@pobox.com>
Sat, 17 Apr 2010 13:27:15 +0000 (13:27 +0000)
committerSimon Tatham <anakin@pobox.com>
Sat, 17 Apr 2010 13:27:15 +0000 (13:27 +0000)
things potentially not in the range 0..255).

[originally from svn r8922]

filling.c
magnets.c
signpost.c
singles.c

index 896fe411de057f4508010ad7d5635f4ba2964430..b6d0ed1166629e46afce360e6d64725ef463b830 100644 (file)
--- a/filling.c
+++ b/filling.c
@@ -1100,7 +1100,7 @@ static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
         button = 0;
         break;
       default:
-        if (!isdigit(button)) return NULL;
+        if (button < '0' || button > '9') return NULL;
         button -= '0';
         if (button > (w == 2 && h == 2? 3: max(w, h))) return NULL;
     }
index beeedf54c54cc27b9b44baf835888a7d338ae614..57bf37a782db21fd39d854a315e6c205f330e4f9 100644 (file)
--- a/magnets.c
+++ b/magnets.c
@@ -386,7 +386,7 @@ static char n2c(int num) { /* XXX cloned from singles.c */
 }
 
 static int c2n(char c) { /* XXX cloned from singles.c */
-    if (isdigit(c))
+    if (isdigit((unsigned char)c))
         return (int)(c - '0');
     else if (c >= 'a' && c <= 'z')
         return (int)(c - 'a' + 10);
index b6db3a3b01e06df71804e16eac4e201df7edee84..efed3f774480f18064590e6266db7ab9abf52266 100644 (file)
@@ -513,7 +513,7 @@ static void unpick_desc(game_params *params, char *desc,
         }
 
         c = *desc;
-        if (isdigit(c)) {
+        if (isdigit((unsigned char)c)) {
             num = (num*10) + (int)(c-'0');
             if (num > state->n) {
                 msg = "Number too large";
index d8016ff21eb63c4737038d715e24857898e1c3c7..c20d0cf89c763f16bbd0fe231b2a80c384558b36 100644 (file)
--- a/singles.c
+++ b/singles.c
@@ -324,7 +324,7 @@ static char n2c(int num) {
 }
 
 static int c2n(char c) {
-    if (isdigit(c))
+    if (isdigit((unsigned char)c))
         return (int)(c - '0');
     else if (c >= 'a' && c <= 'z')
         return (int)(c - 'a' + 10);