Add more (unsigned char) casts to ctype macros

Fix casetable usage in the same manner too
This commit is contained in:
Andrey A. Chernov 1997-10-23 02:03:43 +00:00
parent 483b9871ba
commit 833c9488dd
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=30656
7 changed files with 28 additions and 28 deletions

View File

@ -231,7 +231,7 @@ NODE *tree;
while (l1 > 0) {
if (l2 > l1)
break;
if (casetable[(int)*p1] == casetable[(int)*p2]
if (casetable[(unsigned char)*p1] == casetable[(unsigned char)*p2]
&& (l2 == 1 || strncasecmp(p1, p2, l2) == 0)) {
ret = 1 + s1->stlen - l1;
break;
@ -2038,7 +2038,7 @@ size_t len;
}
} else if (*str == '0') {
for (; len > 0; len--) {
if (! isdigit(*str) || *str == '8' || *str == '9')
if (! isdigit((unsigned char)*str) || *str == '8' || *str == '9')
goto done;
retval = (retval * 8) + (*str - '0');
str++;

View File

@ -736,9 +736,9 @@ lex()
setbit(c3, ccl);
if (case_fold)
if (ISUPPER(c3))
setbit(tolower(c3), ccl);
setbit(tolower((unsigned char)c3), ccl);
else if (ISLOWER(c3))
setbit(toupper(c3), ccl);
setbit(toupper((unsigned char)c3), ccl);
}
}
#else
@ -747,9 +747,9 @@ lex()
setbit(c, ccl);
if (case_fold)
if (ISUPPER(c))
setbit(tolower(c), ccl);
setbit(tolower((unsigned char)c), ccl);
else if (ISLOWER(c))
setbit(toupper(c), ccl);
setbit(toupper((unsigned char)c), ccl);
++c;
}
#endif
@ -773,10 +773,10 @@ lex()
{
zeroset(ccl);
setbit(c, ccl);
if (isupper(c))
setbit(tolower(c), ccl);
if (isupper((unsigned char)c))
setbit(tolower((unsigned char)c), ccl);
else
setbit(toupper(c), ccl);
setbit(toupper((unsigned char)c), ccl);
return lasttok = CSET + charclass_index(ccl);
}
return c;
@ -2047,7 +2047,7 @@ dfacomp(s, len, d, searchflag)
case_fold = 0;
for (i = 0; i < len; ++i)
if (ISUPPER(s[i]))
lcopy[i] = tolower(s[i]);
lcopy[i] = tolower((unsigned char)s[i]);
else
lcopy[i] = s[i];

View File

@ -1652,13 +1652,13 @@ NODE *n;
return 0;
while (*p && strchr(" +-#", *p) != NULL) /* flags */
p++;
while (*p && isdigit(*p)) /* width - %*.*g is NOT allowed */
while (*p && isdigit((unsigned char)*p)) /* width - %*.*g is NOT allowed */
p++;
if (*p == '\0' || (*p != '.' && ! isdigit(*p)))
if (*p == '\0' || (*p != '.' && ! isdigit((unsigned char)*p)))
return 0;
if (*p == '.')
p++;
while (*p && isdigit(*p)) /* precision */
while (*p && isdigit((unsigned char)*p)) /* precision */
p++;
if (*p == '\0' || strchr("efgEG", *p) == NULL)
return 0;

View File

@ -550,9 +550,9 @@ NODE *n;
else
fschar = fs->stptr[0];
onecase = (IGNORECASE && isalpha(fschar));
onecase = (IGNORECASE && isalpha((unsigned char)fschar));
if (onecase)
fschar = casetable[(int) fschar];
fschar = casetable[(unsigned char) fschar];
/* before doing anything save the char at *end */
sav = *end;
@ -562,7 +562,7 @@ NODE *n;
for (; nf < up_to;) {
field = scan;
if (onecase) {
while (casetable[(int) *scan] != fschar)
while (casetable[(unsigned char) *scan] != fschar)
scan++;
} else {
while (*scan != fschar)

View File

@ -1540,9 +1540,9 @@ int *errcode; /* pointer to error variable */
else
rs = (char) grRS;
onecase = (IGNORECASE && isalpha(rs));
onecase = (IGNORECASE && isalpha((unsigned char)rs));
if (onecase)
rs = casetable[rs];
rs = casetable[(unsigned char)rs];
/* set up sentinel */
if (iop->buf) {
@ -1703,7 +1703,7 @@ int *errcode; /* pointer to error variable */
}
/* search for RS, #2, RS = <single char> */
if (onecase) {
while (casetable[(int) *bp++] != rs)
while (casetable[(unsigned char) *bp++] != rs)
continue;
} else {
while (*bp++ != rs)
@ -1732,7 +1732,7 @@ int *errcode; /* pointer to error variable */
bstart = iop->off = bp;
bp--;
if (onecase ? casetable[(int) *bp] != rs : *bp != rs) {
if (onecase ? casetable[(unsigned char) *bp] != rs : *bp != rs) {
bp++;
bstart = bp;
}
@ -1816,9 +1816,9 @@ int *errcode; /* pointer to error variable */
else
rs = (char) grRS;
onecase = (IGNORECASE && isalpha(rs));
onecase = (IGNORECASE && isalpha((unsigned char)rs));
if (onecase)
rs = casetable[rs];
rs = casetable[(unsigned char)rs];
/* if RS = "", skip leading newlines at the front of the file */
if (grRS == FALSE && iop->off == iop->buf) {
@ -1891,7 +1891,7 @@ int *errcode; /* pointer to error variable */
*/
/* search for RS, #2, RS = <single char> */
if (onecase) {
while (bp < end && casetable[*bp++] != rs)
while (bp < end && casetable[(unsigned char)*bp++] != rs)
continue;
} else {
while (bp < end && *bp++ != rs)

View File

@ -644,11 +644,11 @@ char *arg;
*cp++ = '\0';
/* first check that the variable name has valid syntax */
badvar = FALSE;
if (! isalpha(arg[0]) && arg[0] != '_')
if (! isalpha((unsigned char)arg[0]) && arg[0] != '_')
badvar = TRUE;
else
for (cp2 = arg+1; *cp2; cp2++)
if (! isalnum(*cp2) && *cp2 != '_') {
if (! isalnum((unsigned char)*cp2) && *cp2 != '_') {
badvar = TRUE;
break;
}

View File

@ -61,9 +61,9 @@ register NODE *n;
return 0.0;
cpend = cp + n->stlen;
while (cp < cpend && isspace(*cp))
while (cp < cpend && isspace((unsigned char)*cp))
cp++;
if (cp == cpend || isalpha(*cp))
if (cp == cpend || isalpha((unsigned char)*cp))
return 0.0;
if (n->flags & MAYBE_NUM) {
@ -489,7 +489,7 @@ char **string_ptr;
}
if (do_posix)
return ('x');
if (! isxdigit((*string_ptr)[0])) {
if (! isxdigit((unsigned char)(*string_ptr)[0])) {
warning("no hex digits in \\x escape sequence");
return ('x');
}