indent(1): limit character classification functions' input to unsigned char
This commit is contained in:
parent
95b813e501
commit
e1baf57e4b
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=334568
@ -217,7 +217,7 @@ scan_profile(FILE *f)
|
||||
} else if (i == '/' && comment && p > buf && p[-1] == '*') {
|
||||
p = buf + comment - 1;
|
||||
comment = 0;
|
||||
} else if (isspace(i)) {
|
||||
} else if (isspace((unsigned char)i)) {
|
||||
if (p > buf && !comment)
|
||||
break;
|
||||
} else {
|
||||
@ -321,7 +321,7 @@ set_option(char *arg)
|
||||
break;
|
||||
|
||||
case PRO_INT:
|
||||
if (!isdigit(*param_start)) {
|
||||
if (!isdigit((unsigned char)*param_start)) {
|
||||
need_param:
|
||||
errx(1, "%s: ``%s'' requires a parameter", option_source, p->p_name);
|
||||
}
|
||||
|
@ -402,7 +402,7 @@ main(int argc, char **argv)
|
||||
* if there was a newline resulting from the "{" before,
|
||||
* it must be scanned now and ignored.
|
||||
*/
|
||||
while (isspace((int)*buf_ptr)) {
|
||||
while (isspace((unsigned char)*buf_ptr)) {
|
||||
if (++buf_ptr >= buf_end)
|
||||
fill_buffer();
|
||||
if (*buf_ptr == '\n')
|
||||
@ -429,7 +429,7 @@ main(int argc, char **argv)
|
||||
ps.search_brace = false;
|
||||
goto check_type;
|
||||
}
|
||||
while (sc_end > save_com && isblank((int)sc_end[-1])) {
|
||||
while (sc_end > save_com && isblank((unsigned char)sc_end[-1])) {
|
||||
sc_end--;
|
||||
}
|
||||
if (swallow_optional_blanklines ||
|
||||
@ -1070,7 +1070,7 @@ main(int argc, char **argv)
|
||||
e_code = chfont(&bodyf, &keywordf, e_code);
|
||||
for (t_ptr = token; *t_ptr; ++t_ptr) {
|
||||
CHECK_SIZE_CODE;
|
||||
*e_code++ = keywordf.allcaps && islower(*t_ptr)
|
||||
*e_code++ = keywordf.allcaps && islower((unsigned char)*t_ptr)
|
||||
? toupper(*t_ptr) : *t_ptr;
|
||||
}
|
||||
e_code = chfont(&keywordf, &bodyf, e_code);
|
||||
|
@ -243,7 +243,7 @@ dump_line(void)
|
||||
cur_col = 1;
|
||||
++ps.out_lines;
|
||||
}
|
||||
while (e_com > com_st && isspace(e_com[-1]))
|
||||
while (e_com > com_st && isspace((unsigned char)e_com[-1]))
|
||||
e_com--;
|
||||
(void)pad_output(cur_col, target);
|
||||
fwrite(com_st, e_com - com_st, 1, output);
|
||||
@ -638,9 +638,9 @@ parsefont(struct fstate *f, const char *s0)
|
||||
|
||||
memset(f, '\0', sizeof(*f));
|
||||
while (*s) {
|
||||
if (isdigit(*s))
|
||||
if (isdigit((unsigned char)*s))
|
||||
f->size = f->size * 10 + *s - '0';
|
||||
else if (isupper(*s))
|
||||
else if (isupper((unsigned char)*s))
|
||||
if (f->font[0])
|
||||
f->font[1] = *s;
|
||||
else
|
||||
|
@ -173,13 +173,15 @@ lexi(struct parser_state *state)
|
||||
}
|
||||
|
||||
/* Scan an alphanumeric token */
|
||||
if (chartype[(int)*buf_ptr] == alphanum || (buf_ptr[0] == '.' && isdigit(buf_ptr[1]))) {
|
||||
if (chartype[*buf_ptr & 127] == alphanum ||
|
||||
(buf_ptr[0] == '.' && isdigit((unsigned char)buf_ptr[1]))) {
|
||||
/*
|
||||
* we have a character or number
|
||||
*/
|
||||
struct templ *p;
|
||||
|
||||
if (isdigit(*buf_ptr) || (buf_ptr[0] == '.' && isdigit(buf_ptr[1]))) {
|
||||
if (isdigit((unsigned char)*buf_ptr) ||
|
||||
(buf_ptr[0] == '.' && isdigit((unsigned char)buf_ptr[1]))) {
|
||||
enum base {
|
||||
BASE_2, BASE_8, BASE_10, BASE_16
|
||||
};
|
||||
@ -193,7 +195,7 @@ lexi(struct parser_state *state)
|
||||
in_base = BASE_2;
|
||||
else if (buf_ptr[1] == 'x' || buf_ptr[1] == 'X')
|
||||
in_base = BASE_16;
|
||||
else if (isdigit(buf_ptr[1]))
|
||||
else if (isdigit((unsigned char)buf_ptr[1]))
|
||||
in_base = BASE_8;
|
||||
}
|
||||
switch (in_base) {
|
||||
@ -215,7 +217,7 @@ lexi(struct parser_state *state)
|
||||
case BASE_16:
|
||||
*e_token++ = *buf_ptr++;
|
||||
*e_token++ = *buf_ptr++;
|
||||
while (isxdigit(*buf_ptr)) {
|
||||
while (isxdigit((unsigned char)*buf_ptr)) {
|
||||
CHECK_SIZE_TOKEN;
|
||||
*e_token++ = *buf_ptr++;
|
||||
}
|
||||
@ -230,7 +232,7 @@ lexi(struct parser_state *state)
|
||||
}
|
||||
CHECK_SIZE_TOKEN;
|
||||
*e_token++ = *buf_ptr++;
|
||||
if (!isdigit(*buf_ptr) && *buf_ptr != '.') {
|
||||
if (!isdigit((unsigned char)*buf_ptr) && *buf_ptr != '.') {
|
||||
if ((*buf_ptr != 'E' && *buf_ptr != 'e') || seenexp)
|
||||
break;
|
||||
else {
|
||||
@ -264,7 +266,7 @@ lexi(struct parser_state *state)
|
||||
}
|
||||
}
|
||||
else
|
||||
while (chartype[(int)*buf_ptr] == alphanum || *buf_ptr == BACKSLASH) {
|
||||
while (chartype[*buf_ptr & 127] == alphanum || *buf_ptr == BACKSLASH) {
|
||||
/* fill_buffer() terminates buffer with newline */
|
||||
if (*buf_ptr == BACKSLASH) {
|
||||
if (*(buf_ptr + 1) == '\n') {
|
||||
@ -557,7 +559,7 @@ lexi(struct parser_state *state)
|
||||
if (state->in_or_st)
|
||||
state->block_init = 1;
|
||||
#ifdef undef
|
||||
if (chartype[*buf_ptr] == opchar) { /* we have two char assignment */
|
||||
if (chartype[*buf_ptr & 127] == opchar) { /* we have two char assignment */
|
||||
e_token[-1] = *buf_ptr++;
|
||||
if ((e_token[-1] == '<' || e_token[-1] == '>') && e_token[-1] == *buf_ptr)
|
||||
*e_token++ = *buf_ptr++;
|
||||
|
Loading…
Reference in New Issue
Block a user