diff options
| author | Simon Tatham <anakin@pobox.com> | 2016-02-01 19:06:36 +0000 |
|---|---|---|
| committer | Simon Tatham <anakin@pobox.com> | 2016-02-01 19:06:36 +0000 |
| commit | 59705cccd15227bb8f590147402660e4e6237e5f (patch) | |
| tree | 3323152fc422441339859f3ec8119e6d1abac6e6 | |
| parent | 1d9d6cbf12733a0e157c6e06cdf1932db77d1cd9 (diff) | |
| download | puzzles-59705cccd15227bb8f590147402660e4e6237e5f.zip puzzles-59705cccd15227bb8f590147402660e4e6237e5f.tar.gz puzzles-59705cccd15227bb8f590147402660e4e6237e5f.tar.bz2 puzzles-59705cccd15227bb8f590147402660e4e6237e5f.tar.xz | |
Add missing casts to unsigned char inside ctype functions.
These are necessary because the argument to a ctype function cannot be
a negative value unless it's EOF. Thanks to Cygwin gcc for pointing
out the mistake, and to Patrick Shaughnessy for this patch.
| -rw-r--r-- | palisade.c | 12 |
1 files changed, 6 insertions, 6 deletions
@@ -697,17 +697,17 @@ static char *validate_desc(const game_params *params, const char *desc) int w = params->w, h = params->h, wh = w*h, squares = 0; for (/* nop */; *desc; ++desc) { - if (islower(*desc)) { + if (islower((unsigned char)*desc)) { squares += *desc - 'a' + 1; - } else if (isdigit(*desc)) { + } else if (isdigit((unsigned char)*desc)) { if (*desc > '4') { static char buf[] = "Invalid (too large) number: '5'"; - assert (isdigit(buf[lenof(buf) - 3])); + assert (isdigit((unsigned char)buf[lenof(buf) - 3])); buf[lenof(buf) - 3] = *desc; /* ... or 6, 7, 8, 9 :-) */ return buf; } ++squares; - } else if (isprint(*desc)) { + } else if (isprint((unsigned char)*desc)) { static char buf[] = "Invalid character in data: '?'"; buf[lenof(buf) - 3] = *desc; return buf; @@ -732,8 +732,8 @@ static game_state *new_game(midend *me, const game_params *params, setmem(state->shared->clues, EMPTY, wh); for (i = 0; *desc; ++desc) { - if (isdigit(*desc)) state->shared->clues[i++] = *desc - '0'; - else if (isalpha(*desc)) i += *desc - 'a' + 1; + if (isdigit((unsigned char)*desc)) state->shared->clues[i++] = *desc - '0'; + else if (isalpha((unsigned char)*desc)) i += *desc - 'a' + 1; } snewa(state->borders, wh); |