mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-21 08:01:30 -07:00
Fix incorrect uses of ctype.h (passing it uncast chars, or other
things potentially not in the range 0..255). [originally from svn r8922]
This commit is contained in:
@ -1100,7 +1100,7 @@ static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
|
|||||||
button = 0;
|
button = 0;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (!isdigit(button)) return NULL;
|
if (button < '0' || button > '9') return NULL;
|
||||||
button -= '0';
|
button -= '0';
|
||||||
if (button > (w == 2 && h == 2? 3: max(w, h))) return NULL;
|
if (button > (w == 2 && h == 2? 3: max(w, h))) return NULL;
|
||||||
}
|
}
|
||||||
|
@ -386,7 +386,7 @@ static char n2c(int num) { /* XXX cloned from singles.c */
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int c2n(char c) { /* 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');
|
return (int)(c - '0');
|
||||||
else if (c >= 'a' && c <= 'z')
|
else if (c >= 'a' && c <= 'z')
|
||||||
return (int)(c - 'a' + 10);
|
return (int)(c - 'a' + 10);
|
||||||
|
@ -513,7 +513,7 @@ static void unpick_desc(game_params *params, char *desc,
|
|||||||
}
|
}
|
||||||
|
|
||||||
c = *desc;
|
c = *desc;
|
||||||
if (isdigit(c)) {
|
if (isdigit((unsigned char)c)) {
|
||||||
num = (num*10) + (int)(c-'0');
|
num = (num*10) + (int)(c-'0');
|
||||||
if (num > state->n) {
|
if (num > state->n) {
|
||||||
msg = "Number too large";
|
msg = "Number too large";
|
||||||
|
@ -324,7 +324,7 @@ static char n2c(int num) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int c2n(char c) {
|
static int c2n(char c) {
|
||||||
if (isdigit(c))
|
if (isdigit((unsigned char)c))
|
||||||
return (int)(c - '0');
|
return (int)(c - '0');
|
||||||
else if (c >= 'a' && c <= 'z')
|
else if (c >= 'a' && c <= 'z')
|
||||||
return (int)(c - 'a' + 10);
|
return (int)(c - 'a' + 10);
|
||||||
|
Reference in New Issue
Block a user