From: simon Date: Sat, 17 Apr 2010 13:27:15 +0000 (+0000) Subject: Fix incorrect uses of ctype.h (passing it uncast chars, or other X-Git-Url: https://git.distorted.org.uk/~mdw/sgt/puzzles/commitdiff_plain/4d6d127734e9debf3eb909b3a5817110fcc67bf5 Fix incorrect uses of ctype.h (passing it uncast chars, or other things potentially not in the range 0..255). git-svn-id: svn://svn.tartarus.org/sgt/puzzles@8922 cda61777-01e9-0310-a592-d414129be87e --- diff --git a/filling.c b/filling.c index 896fe41..b6d0ed1 100644 --- 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; } diff --git a/magnets.c b/magnets.c index beeedf5..57bf37a 100644 --- 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); diff --git a/signpost.c b/signpost.c index b6db3a3..efed3f7 100644 --- a/signpost.c +++ b/signpost.c @@ -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"; diff --git a/singles.c b/singles.c index d8016ff..c20d0cf 100644 --- 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);