From: Paul Smith Date: Sun, 3 May 2020 18:54:56 +0000 (-0400) Subject: [SV 57930] Cast char to unsigned char to call ctype functions X-Git-Tag: 4.3.90~219 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=177054021733fde825184b29f7b9435027d255ef;p=thirdparty%2Fmake.git [SV 57930] Cast char to unsigned char to call ctype functions This cast was already done almost everywhere: fix some stragglers. * src/load.c (load_file): Cast char to unsigned char. * src/misc.c (strcasecmp, strncasecmp): [!POSIX] Ditto. * src/dir.c (vms_hash): [VMS] Ditto. * src/vms_progname.c (set_program_name): [VMS] Ditto. * src/vms_jobs.c (posix_parse_dq): [VMS] Ditto. (posix_parse_dollar): [VMS] Ditto. (build_vms_cmd): [VMS] Ditto. (child_execute_job): [VMS] Ditto. --- diff --git a/src/dir.c b/src/dir.c index 2b2abf33..a9c12ebd 100644 --- a/src/dir.c +++ b/src/dir.c @@ -175,7 +175,7 @@ vms_hash (const char *name) while (*name) { - unsigned char uc = *name; + unsigned char uc = (unsigned char) *name; int g; #ifdef HAVE_CASE_INSENSITIVE_FS h = (h << 4) + (isupper (uc) ? tolower (uc) : uc); diff --git a/src/load.c b/src/load.c index 27f5899f..5d57b688 100644 --- a/src/load.c +++ b/src/load.c @@ -195,7 +195,7 @@ load_file (const floc *flocp, const char **ldname, int noerror) fp = *ldname; else ++fp; - while (isalnum (*fp) || *fp == '_') + while (isalnum ((unsigned char) *fp) || *fp == '_') *(p++) = *(fp++); strcpy (p, SYMBOL_EXTENSION); symname = new; diff --git a/src/misc.c b/src/misc.c index de19e375..bc5060a3 100644 --- a/src/misc.c +++ b/src/misc.c @@ -535,8 +535,8 @@ strcasecmp (const char *s1, const char *s2) { while (1) { - int c1 = (int) *(s1++); - int c2 = (int) *(s2++); + int c1 = (unsigned char) *(s1++); + int c2 = (unsigned char) *(s2++); if (isalpha (c1)) c1 = tolower (c1); @@ -560,8 +560,8 @@ strncasecmp (const char *s1, const char *s2, int n) { while (n-- > 0) { - int c1 = (int) *(s1++); - int c2 = (int) *(s2++); + int c1 = (unsigned char) *(s1++); + int c2 = (unsigned char) *(s2++); if (isalpha (c1)) c1 = tolower (c1); diff --git a/src/vms_progname.c b/src/vms_progname.c index dcb25aaf..fb5d5f2b 100644 --- a/src/vms_progname.c +++ b/src/vms_progname.c @@ -409,7 +409,7 @@ set_program_name (const char *argv0) int i; i = 1; - while (isdigit (lastdot[i])) { + while (isdigit ((unsigned char) lastdot[i])) { i++; } if (lastdot[i] == 0) { diff --git a/src/vmsjobs.c b/src/vmsjobs.c index 89dddf54..3588f4ad 100644 --- a/src/vmsjobs.c +++ b/src/vmsjobs.c @@ -367,7 +367,7 @@ posix_parse_dq (struct token_info *token) } INC_TOKEN_LEN_OR_BREAK; } - else if (*p == '$' && isalpha (p[1])) + else if (*p == '$' && isalpha ((unsigned char) p[1])) { /* A symbol we should be able to substitute */ *q++ = '\''; @@ -506,7 +506,7 @@ posix_parse_dollar (struct token_info *token) *q++ = '\''; INC_TOKEN_LEN_OR_RETURN (p); - while ((isalnum (*p)) || (*p == '_')) + while ((isalnum ((unsigned char) *p)) || (*p == '_')) { *q++ = *p++; INC_TOKEN_LEN_OR_BREAK; @@ -707,7 +707,7 @@ build_vms_cmd (char **cmd_tokens, } /* Optional whitespace */ - if (isspace (cmd_tokens[cmd_tkn_index][0])) + if (isspace ((unsigned char) cmd_tokens[cmd_tkn_index][0])) { strcpy (&cmd[cmd_len], cmd_tokens[cmd_tkn_index]); cmd_len += strlen (cmd_tokens[cmd_tkn_index]); @@ -789,7 +789,7 @@ build_vms_cmd (char **cmd_tokens, if (cmd_tkn_index == append_token) { free (cmd_tokens[cmd_tkn_index++]); - if (isspace (cmd_tokens[cmd_tkn_index][0])) + if (isspace ((unsigned char) cmd_tokens[cmd_tkn_index][0])) free (cmd_tokens[cmd_tkn_index++]); free (cmd_tokens[cmd_tkn_index++]); } @@ -987,7 +987,7 @@ child_execute_job (struct childbase *child, int good_stdin UNUSED, char *argv) /* TODO: Should we diagnose if paren_level goes negative? */ break; case '&': - if (isalpha (p[1]) && !vms_unix_simulation) + if (isalpha ((unsigned char) p[1]) && !vms_unix_simulation) { /* VMS symbol substitution */ p = parse_text (&token, 0); @@ -1061,7 +1061,7 @@ child_execute_job (struct childbase *child, int good_stdin UNUSED, char *argv) UPDATE_TOKEN; break; case ':': - if ((p[1] == 0) || isspace (p[1])) + if ((p[1] == 0) || isspace ((unsigned char) p[1])) { /* Unix Null command - treat as comment until next command */ unix_echo_cmd = 0; @@ -1115,7 +1115,7 @@ child_execute_job (struct childbase *child, int good_stdin UNUSED, char *argv) break; default: /* Skip repetitive whitespace */ - if (isspace (*p)) + if (isspace ((unsigned char) *p)) { p = parse_char (&token, 1); @@ -1125,7 +1125,7 @@ child_execute_job (struct childbase *child, int good_stdin UNUSED, char *argv) token_str[0] = ' '; UPDATE_TOKEN; - while (isspace (*p)) + while (isspace ((unsigned char) *p)) p++; if (assignment_hack != 0) assignment_hack++; @@ -1176,7 +1176,7 @@ child_execute_job (struct childbase *child, int good_stdin UNUSED, char *argv) char * raw_append_file; file_token = append_token; file_token++; - if (isspace (cmd_tokens[file_token][0])) + if (isspace ((unsigned char) cmd_tokens[file_token][0])) file_token++; raw_append_file = vmsify (cmd_tokens[file_token], 0); /* VMS DCL needs a trailing dot if null file extension */