tweaks: make sure calls to <ctype.h> functions/macros use "unsigned char"

The platform's default char type might be signed, which could cause
problems in 8-bit locales.

This addresses https://savannah.gnu.org/bugs/?50289.
Reported-by: Hans-Bernhard Broeker <HBBroeker@T-Online.de>
master
Hans-Bernhard Broeker 2017-02-12 18:58:48 +01:00 committed by Benno Schulenberg
parent 0176cb5b30
commit 636b7348a6
3 changed files with 12 additions and 12 deletions

View File

@ -736,7 +736,7 @@ char *mbrevstrpbrk(const char *s, const char *accept, const char
bool has_blank_chars(const char *s)
{
for (; *s != '\0'; s++) {
if (isblank(*s))
if (isblank((unsigned char)*s))
return TRUE;
}

View File

@ -424,7 +424,7 @@ void assign_keyinfo(sc *s, const char *keystring, const int keycode)
if (strcasecmp(keystring, "M-Space") == 0)
s->keycode = (int)' ';
else
s->keycode = tolower((int)keystring[2]);
s->keycode = tolower((unsigned char)keystring[2]);
} else if (keystring[0] == 'F')
s->keycode = KEY_F0 + atoi(&keystring[1]);
else if (!strcasecmp(keystring, "Ins"))

View File

@ -167,7 +167,7 @@ void rcfile_error(const char *msg, ...)
* returned pointer will point to '\0' if we hit the end of the line. */
char *parse_next_word(char *ptr)
{
while (!isblank(*ptr) && *ptr != '\0')
while (!isblank((unsigned char)*ptr) && *ptr != '\0')
ptr++;
if (*ptr == '\0')
@ -176,7 +176,7 @@ char *parse_next_word(char *ptr)
/* Null-terminate and advance ptr. */
*ptr++ = '\0';
while (isblank(*ptr))
while (isblank((unsigned char)*ptr))
ptr++;
return ptr;
@ -215,7 +215,7 @@ char *parse_argument(char *ptr)
ptr = last_quote + 1;
}
if (ptr != NULL)
while (isblank(*ptr))
while (isblank((unsigned char)*ptr))
ptr++;
return ptr;
}
@ -230,7 +230,7 @@ char *parse_next_regex(char *ptr)
/* Continue until the end of line, or until a " followed by a
* blank character or the end of line. */
while (*ptr != '\0' && (*ptr != '"' ||
(*(ptr + 1) != '\0' && !isblank(*(ptr + 1)))))
(*(ptr + 1) != '\0' && !isblank((unsigned char)ptr[1]))))
ptr++;
assert(*ptr == '"' || *ptr == '\0');
@ -244,7 +244,7 @@ char *parse_next_regex(char *ptr)
/* Null-terminate and advance ptr. */
*ptr++ = '\0';
while (isblank(*ptr))
while (isblank((unsigned char)*ptr))
ptr++;
return ptr;
@ -387,11 +387,11 @@ void parse_binding(char *ptr, bool dobind)
}
/* Uppercase only the first two or three characters of the key name. */
keycopy[0] = toupper(keycopy[0]);
keycopy[1] = toupper(keycopy[1]);
keycopy[0] = toupper((unsigned char)keycopy[0]);
keycopy[1] = toupper((unsigned char)keycopy[1]);
if (keycopy[0] == 'M' && keycopy[1] == '-') {
if (strlen(keycopy) > 2)
keycopy[2] = toupper(keycopy[2]);
keycopy[2] = toupper((unsigned char)keycopy[2]);
else {
rcfile_error(N_("Key name is too short"));
goto free_copy;
@ -401,7 +401,7 @@ void parse_binding(char *ptr, bool dobind)
/* Allow the codes for Insert and Delete to be rebound, but apart
* from those two only Control, Meta and Function sequences. */
if (!strcasecmp(keycopy, "Ins") || !strcasecmp(keycopy, "Del"))
keycopy[1] = tolower(keycopy[1]);
keycopy[1] = tolower((unsigned char)keycopy[1]);
else if (keycopy[0] != '^' && keycopy[0] != 'M' && keycopy[0] != 'F') {
rcfile_error(N_("Key name must begin with \"^\", \"M\", or \"F\""));
goto free_copy;
@ -966,7 +966,7 @@ void parse_rcfile(FILE *rcstream, bool syntax_only)
lineno++;
ptr = buf;
while (isblank(*ptr))
while (isblank((unsigned char)*ptr))
ptr++;
/* If we have a blank line or a comment, skip to the next