add '(uchar)' casts to ctype calls
This is from the pull request for the assertion failure fix. It did not mention how to reproduce the assertion failure, just added casts to a bunch of isspace/isprint/tolower calls that didn't already have such. I removed an obsolete change for win/tty/topl.c and changed the win/win32/mswproc.c code to avoid using an expression with side-effects (*colorstring++) in calls to tolower() in case someone overrides that with a macro which evaluates its argument more than once as some pre- ANSI ones used to do. Not tested, might have typos.... sys/wince/*.c still needs similar casts.
This commit is contained in:
@@ -245,7 +245,8 @@ boolean thrown_weapon; /* thrown weapons are less deadly */
|
||||
boolean plural = (reason[strlen(reason) - 1] == 's') ? 1 : 0;
|
||||
|
||||
/* avoid "The" Orcus's sting was poisoned... */
|
||||
pline("%s%s %s poisoned!", isupper(*reason) ? "" : "The ", reason,
|
||||
pline("%s%s %s poisoned!",
|
||||
isupper((uchar) *reason) ? "" : "The ", reason,
|
||||
plural ? "were" : "was");
|
||||
}
|
||||
if (Poison_resistance) {
|
||||
|
||||
@@ -299,7 +299,7 @@ int start;
|
||||
* whitespace, do not change the value of SAVEF.
|
||||
*/
|
||||
for (bp = buf; *bp; bp++)
|
||||
if (!isspace(*bp)) {
|
||||
if (!isspace((uchar) *bp)) {
|
||||
strncpy(SAVEF, bp, PATHLEN);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -153,7 +153,7 @@ int portdebug;
|
||||
if (vk == 0xBF)
|
||||
ch = M('?');
|
||||
else
|
||||
ch = M(tolower(keycode));
|
||||
ch = M(tolower((uchar) keycode));
|
||||
}
|
||||
if (ch == '\r')
|
||||
ch = '\n';
|
||||
|
||||
@@ -167,7 +167,7 @@ int portdebug;
|
||||
if (vk == 0xBF)
|
||||
ch = M('?');
|
||||
else
|
||||
ch = M(tolower(keycode));
|
||||
ch = M(tolower((uchar) keycode));
|
||||
}
|
||||
/* Attempt to work better with international keyboards. */
|
||||
else {
|
||||
|
||||
@@ -352,7 +352,7 @@ int portdebug;
|
||||
if (vk == 0xBF)
|
||||
ch = M('?');
|
||||
else
|
||||
ch = M(tolower(keycode));
|
||||
ch = M(tolower((uchar) keycode));
|
||||
} else if (ch < 32 && !isnumkeypad(scan)) {
|
||||
/* Control code; ReadConsole seems to filter some of these,
|
||||
* including ESC */
|
||||
|
||||
@@ -119,7 +119,7 @@ char *str;
|
||||
char *ptr;
|
||||
char drive;
|
||||
if ((ptr = index(str, ':')) != (char *) 0) {
|
||||
drive = toupper(*(ptr - 1));
|
||||
drive = toupper((uchar) *(ptr - 1));
|
||||
_chdrive((drive - 'A') + 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -653,7 +653,7 @@ const char *id;
|
||||
{
|
||||
struct grep_var *rv;
|
||||
|
||||
while (*id && isspace(*id))
|
||||
while (*id && isspace((uchar) *id))
|
||||
id++;
|
||||
if (!*id) {
|
||||
Fprintf(stderr, "missing identifier in line %d", grep_lineno);
|
||||
@@ -700,10 +700,10 @@ char *buf;
|
||||
int isif = 1;
|
||||
char *buf0 = buf;
|
||||
#if 1
|
||||
if (isspace(buf[0]))
|
||||
if (isspace((uchar) buf[0]))
|
||||
return &buf[-1]; /* XXX see docs above */
|
||||
#else
|
||||
while (buf[0] && isspace(buf[0]))
|
||||
while (buf[0] && isspace((uchar) buf[0]))
|
||||
buf++;
|
||||
#endif
|
||||
switch (buf[0]) {
|
||||
@@ -754,7 +754,7 @@ char *buf;
|
||||
default: {
|
||||
char str[10];
|
||||
|
||||
if (isprint(buf[0])) {
|
||||
if (isprint((uchar) buf[0])) {
|
||||
str[0] = buf[0];
|
||||
str[1] = '\0';
|
||||
} else {
|
||||
|
||||
@@ -181,7 +181,7 @@ pixel (*pixels)[TILE_X];
|
||||
/* DICE again... it doesn't seem to eat whitespace after the } like
|
||||
* it should, so we have to do so manually.
|
||||
*/
|
||||
while ((*c = fgetc(txtfile)) != EOF && isspace(*c))
|
||||
while ((*c = fgetc(txtfile)) != EOF && isspace((uchar) *c))
|
||||
;
|
||||
ungetc(*c, txtfile);
|
||||
#endif
|
||||
|
||||
@@ -1412,7 +1412,7 @@ onListChar(HWND hWnd, HWND hwndList, WORD ch)
|
||||
}
|
||||
}
|
||||
|
||||
if (isdigit(ch)) {
|
||||
if (isdigit((uchar) ch)) {
|
||||
int count;
|
||||
i = ListView_GetNextItem(hwndList, -1, LVNI_FOCUSED);
|
||||
if (i >= 0) {
|
||||
|
||||
@@ -310,7 +310,7 @@ onMSNHCommand(HWND hWnd, WPARAM wParam, LPARAM lParam)
|
||||
|
||||
/* check if the string is empty */
|
||||
for (p = data->window_text[MSG_LINES - 1].text;
|
||||
*p && isspace(*p); p++)
|
||||
*p && isspace((uchar) *p); p++)
|
||||
;
|
||||
|
||||
if (*p) {
|
||||
|
||||
@@ -1583,7 +1583,7 @@ mswin_yn_function(const char *question, const char *choices, CHAR_P def)
|
||||
(WPARAM) MSNH_MSG_CARET, (LPARAM) &createcaret);
|
||||
|
||||
/* display selection in the message window */
|
||||
if (isprint(ch) && ch != '#') {
|
||||
if (isprint((uchar) ch) && ch != '#') {
|
||||
res_ch[0] = ch;
|
||||
res_ch[1] = '\x0';
|
||||
mswin_putstr_ex(WIN_MESSAGE, ATR_BOLD, res_ch, 1);
|
||||
@@ -2019,7 +2019,7 @@ mswin_getmsghistory(BOOLEAN_P init)
|
||||
if (next_message)
|
||||
next_message++;
|
||||
if (p)
|
||||
while (p >= retval && isspace(*p))
|
||||
while (p >= retval && isspace((uchar) *p))
|
||||
*p-- = (char) 0; /* delete trailing whitespace */
|
||||
return retval;
|
||||
}
|
||||
@@ -2539,23 +2539,32 @@ mswin_color_from_string(char *colorstring, HBRUSH *brushptr,
|
||||
if (strlen(++colorstring) != 6)
|
||||
return;
|
||||
|
||||
red_value = (int) (index(hexadecimals, tolower(*colorstring++))
|
||||
red_value = (int) (index(hexadecimals, tolower((uchar) *colorstring))
|
||||
- hexadecimals);
|
||||
++colorstring;
|
||||
red_value *= 16;
|
||||
red_value += (int) (index(hexadecimals, tolower(*colorstring++))
|
||||
red_value += (int) (index(hexadecimals, tolower((uchar) *colorstring))
|
||||
- hexadecimals);
|
||||
++colorstring;
|
||||
|
||||
green_value = (int) (index(hexadecimals, tolower(*colorstring++))
|
||||
green_value = (int) (index(hexadecimals,
|
||||
tolower((uchar) *colorstring))
|
||||
- hexadecimals);
|
||||
++colorstring;
|
||||
green_value *= 16;
|
||||
green_value += (int) (index(hexadecimals, tolower(*colorstring++))
|
||||
green_value += (int) (index(hexadecimals,
|
||||
tolower((uchar) *colorstring))
|
||||
- hexadecimals);
|
||||
++colorstring;
|
||||
|
||||
blue_value = (int) (index(hexadecimals, tolower(*colorstring++))
|
||||
blue_value = (int) (index(hexadecimals, tolower((uchar) *colorstring))
|
||||
- hexadecimals);
|
||||
++colorstring;
|
||||
blue_value *= 16;
|
||||
blue_value += (int) (index(hexadecimals, tolower(*colorstring++))
|
||||
blue_value += (int) (index(hexadecimals,
|
||||
tolower((uchar) *colorstring))
|
||||
- hexadecimals);
|
||||
++colorstring;
|
||||
|
||||
*colorptr = RGB(red_value, green_value, blue_value);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user