sync parse.y changes from base; ok naddy@

original from naddy@:
> Don't declare variables as "unsigned char *" that are passed to
> functions that take "char *" arguments.  Where such chars are
> assigned to int or passed to ctype functions, explicitly cast them
> to unsigned char.
>
> For OpenBSD's clang, -Wpointer-sign has been disabled by default,
> but when the parse.y code was built elsewhere, the compiler would
> complain.
>
> With help from millert@
> ok benno@ deraadt@
This commit is contained in:
okan 2021-11-22 00:51:54 +00:00
parent 055b84f4d4
commit a9eeb04606

28
parse.y
View File

@ -361,9 +361,9 @@ lookup(char *s)
#define MAXPUSHBACK 128 #define MAXPUSHBACK 128
u_char *parsebuf; char *parsebuf;
int parseindex; int parseindex;
u_char pushback_buffer[MAXPUSHBACK]; char pushback_buffer[MAXPUSHBACK];
int pushback_index = 0; int pushback_index = 0;
int int
@ -374,7 +374,7 @@ lgetc(int quotec)
if (parsebuf) { if (parsebuf) {
/* Read character from the parsebuffer instead of input. */ /* Read character from the parsebuffer instead of input. */
if (parseindex >= 0) { if (parseindex >= 0) {
c = parsebuf[parseindex++]; c = (unsigned char)parsebuf[parseindex++];
if (c != '\0') if (c != '\0')
return (c); return (c);
parsebuf = NULL; parsebuf = NULL;
@ -383,7 +383,7 @@ lgetc(int quotec)
} }
if (pushback_index) if (pushback_index)
return (pushback_buffer[--pushback_index]); return ((unsigned char)pushback_buffer[--pushback_index]);
if (quotec) { if (quotec) {
if ((c = getc(file->stream)) == EOF) { if ((c = getc(file->stream)) == EOF) {
@ -424,10 +424,10 @@ lungetc(int c)
if (parseindex >= 0) if (parseindex >= 0)
return (c); return (c);
} }
if (pushback_index < MAXPUSHBACK-1) if (pushback_index + 1 >= MAXPUSHBACK)
return (pushback_buffer[pushback_index++] = c);
else
return (EOF); return (EOF);
pushback_buffer[pushback_index++] = c;
return (c);
} }
int int
@ -440,7 +440,7 @@ findeol(void)
/* skip to either EOF or the first real EOL */ /* skip to either EOF or the first real EOL */
while (1) { while (1) {
if (pushback_index) if (pushback_index)
c = pushback_buffer[--pushback_index]; c = (unsigned char)pushback_buffer[--pushback_index];
else else
c = lgetc(0); c = lgetc(0);
if (c == '\n') { if (c == '\n') {
@ -456,8 +456,8 @@ findeol(void)
int int
yylex(void) yylex(void)
{ {
u_char buf[8096]; char buf[8096];
u_char *p; char *p;
int quotec, next, c; int quotec, next, c;
int token; int token;
@ -514,7 +514,7 @@ yylex(void)
if (c == '-' || isdigit(c)) { if (c == '-' || isdigit(c)) {
do { do {
*p++ = c; *p++ = c;
if ((unsigned)(p-buf) >= sizeof(buf)) { if ((size_t)(p-buf) >= sizeof(buf)) {
yyerror("string too long"); yyerror("string too long");
return (findeol()); return (findeol());
} }
@ -537,8 +537,8 @@ yylex(void)
} else { } else {
nodigits: nodigits:
while (p > buf + 1) while (p > buf + 1)
lungetc(*--p); lungetc((unsigned char)*--p);
c = *--p; c = (unsigned char)*--p;
if (c == '-') if (c == '-')
return (c); return (c);
} }
@ -553,7 +553,7 @@ nodigits:
if (isalnum(c) || c == ':' || c == '_' || c == '*' || c == '/') { if (isalnum(c) || c == ':' || c == '_' || c == '*' || c == '/') {
do { do {
*p++ = c; *p++ = c;
if ((unsigned)(p-buf) >= sizeof(buf)) { if ((size_t)(p-buf) >= sizeof(buf)) {
yyerror("string too long"); yyerror("string too long");
return (findeol()); return (findeol());
} }