Commit 636b7348 authored by Hans-Bernhard Broeker's avatar Hans-Bernhard Broeker Committed by Benno Schulenberg
Browse files

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: default avatarHans-Bernhard Broeker <HBBroeker@T-Online.de>
parent 0176cb5b
Showing with 12 additions and 12 deletions
+12 -12
...@@ -736,7 +736,7 @@ char *mbrevstrpbrk(const char *s, const char *accept, const char ...@@ -736,7 +736,7 @@ char *mbrevstrpbrk(const char *s, const char *accept, const char
bool has_blank_chars(const char *s) bool has_blank_chars(const char *s)
{ {
for (; *s != '\0'; s++) { for (; *s != '\0'; s++) {
if (isblank(*s)) if (isblank((unsigned char)*s))
return TRUE; return TRUE;
} }
......
...@@ -424,7 +424,7 @@ void assign_keyinfo(sc *s, const char *keystring, const int keycode) ...@@ -424,7 +424,7 @@ void assign_keyinfo(sc *s, const char *keystring, const int keycode)
if (strcasecmp(keystring, "M-Space") == 0) if (strcasecmp(keystring, "M-Space") == 0)
s->keycode = (int)' '; s->keycode = (int)' ';
else else
s->keycode = tolower((int)keystring[2]); s->keycode = tolower((unsigned char)keystring[2]);
} else if (keystring[0] == 'F') } else if (keystring[0] == 'F')
s->keycode = KEY_F0 + atoi(&keystring[1]); s->keycode = KEY_F0 + atoi(&keystring[1]);
else if (!strcasecmp(keystring, "Ins")) else if (!strcasecmp(keystring, "Ins"))
......
...@@ -167,7 +167,7 @@ void rcfile_error(const char *msg, ...) ...@@ -167,7 +167,7 @@ void rcfile_error(const char *msg, ...)
* returned pointer will point to '\0' if we hit the end of the line. */ * returned pointer will point to '\0' if we hit the end of the line. */
char *parse_next_word(char *ptr) char *parse_next_word(char *ptr)
{ {
while (!isblank(*ptr) && *ptr != '\0') while (!isblank((unsigned char)*ptr) && *ptr != '\0')
ptr++; ptr++;
if (*ptr == '\0') if (*ptr == '\0')
...@@ -176,7 +176,7 @@ char *parse_next_word(char *ptr) ...@@ -176,7 +176,7 @@ char *parse_next_word(char *ptr)
/* Null-terminate and advance ptr. */ /* Null-terminate and advance ptr. */
*ptr++ = '\0'; *ptr++ = '\0';
while (isblank(*ptr)) while (isblank((unsigned char)*ptr))
ptr++; ptr++;
return ptr; return ptr;
...@@ -215,7 +215,7 @@ char *parse_argument(char *ptr) ...@@ -215,7 +215,7 @@ char *parse_argument(char *ptr)
ptr = last_quote + 1; ptr = last_quote + 1;
} }
if (ptr != NULL) if (ptr != NULL)
while (isblank(*ptr)) while (isblank((unsigned char)*ptr))
ptr++; ptr++;
return ptr; return ptr;
} }
...@@ -230,7 +230,7 @@ char *parse_next_regex(char *ptr) ...@@ -230,7 +230,7 @@ char *parse_next_regex(char *ptr)
/* Continue until the end of line, or until a " followed by a /* Continue until the end of line, or until a " followed by a
* blank character or the end of line. */ * blank character or the end of line. */
while (*ptr != '\0' && (*ptr != '"' || while (*ptr != '\0' && (*ptr != '"' ||
(*(ptr + 1) != '\0' && !isblank(*(ptr + 1))))) (*(ptr + 1) != '\0' && !isblank((unsigned char)ptr[1]))))
ptr++; ptr++;
assert(*ptr == '"' || *ptr == '\0'); assert(*ptr == '"' || *ptr == '\0');
...@@ -244,7 +244,7 @@ char *parse_next_regex(char *ptr) ...@@ -244,7 +244,7 @@ char *parse_next_regex(char *ptr)
/* Null-terminate and advance ptr. */ /* Null-terminate and advance ptr. */
*ptr++ = '\0'; *ptr++ = '\0';
while (isblank(*ptr)) while (isblank((unsigned char)*ptr))
ptr++; ptr++;
return ptr; return ptr;
...@@ -387,11 +387,11 @@ void parse_binding(char *ptr, bool dobind) ...@@ -387,11 +387,11 @@ void parse_binding(char *ptr, bool dobind)
} }
/* Uppercase only the first two or three characters of the key name. */ /* Uppercase only the first two or three characters of the key name. */
keycopy[0] = toupper(keycopy[0]); keycopy[0] = toupper((unsigned char)keycopy[0]);
keycopy[1] = toupper(keycopy[1]); keycopy[1] = toupper((unsigned char)keycopy[1]);
if (keycopy[0] == 'M' && keycopy[1] == '-') { if (keycopy[0] == 'M' && keycopy[1] == '-') {
if (strlen(keycopy) > 2) if (strlen(keycopy) > 2)
keycopy[2] = toupper(keycopy[2]); keycopy[2] = toupper((unsigned char)keycopy[2]);
else { else {
rcfile_error(N_("Key name is too short")); rcfile_error(N_("Key name is too short"));
goto free_copy; goto free_copy;
...@@ -401,7 +401,7 @@ void parse_binding(char *ptr, bool dobind) ...@@ -401,7 +401,7 @@ void parse_binding(char *ptr, bool dobind)
/* Allow the codes for Insert and Delete to be rebound, but apart /* Allow the codes for Insert and Delete to be rebound, but apart
* from those two only Control, Meta and Function sequences. */ * from those two only Control, Meta and Function sequences. */
if (!strcasecmp(keycopy, "Ins") || !strcasecmp(keycopy, "Del")) 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') { else if (keycopy[0] != '^' && keycopy[0] != 'M' && keycopy[0] != 'F') {
rcfile_error(N_("Key name must begin with \"^\", \"M\", or \"F\"")); rcfile_error(N_("Key name must begin with \"^\", \"M\", or \"F\""));
goto free_copy; goto free_copy;
...@@ -966,7 +966,7 @@ void parse_rcfile(FILE *rcstream, bool syntax_only) ...@@ -966,7 +966,7 @@ void parse_rcfile(FILE *rcstream, bool syntax_only)
lineno++; lineno++;
ptr = buf; ptr = buf;
while (isblank(*ptr)) while (isblank((unsigned char)*ptr))
ptr++; ptr++;
/* If we have a blank line or a comment, skip to the next /* If we have a blank line or a comment, skip to the next
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment