fix maketab non-bug

This commit is contained in:
Brian Kernighan 2018-10-25 13:28:54 -04:00
parent 2dc7e5ff1a
commit e8c280034f
3 changed files with 9 additions and 2 deletions

5
FIXES
View File

@ -25,6 +25,11 @@ THIS SOFTWARE.
This file lists all bug fixes, changes, etc., made since the AWK book This file lists all bug fixes, changes, etc., made since the AWK book
was sent to the printers in August, 1987. was sent to the printers in August, 1987.
Oct 25, 2018:
Added test in maketab.c to prevent generating a proctab entry
for YYSTYPE_IS_DEFINED. It was harmless but some gcc settings
generated a warning message. Thanks to Nan Xiao for report.
Aug 27, 2018: Aug 27, 2018:
Disallow '$' in printf formats; arguments evaluated in order Disallow '$' in printf formats; arguments evaluated in order
and printed in order. and printed in order.

View File

@ -34,8 +34,8 @@ CC = gcc -g -Wall -pedantic
# yacc options. pick one; this varies a lot by system. # yacc options. pick one; this varies a lot by system.
#YFLAGS = -d -S #YFLAGS = -d -S
#YACC = bison -d -y YACC = bison -d -y
YACC = yacc -d #YACC = yacc -d
# -S uses sprintf in yacc parser instead of sprint # -S uses sprintf in yacc parser instead of sprint
OFILES = b.o main.o parse.o proctab.o tran.o lib.o run.o lex.o OFILES = b.o main.o parse.o proctab.o tran.o lib.o run.o lex.o

View File

@ -135,6 +135,8 @@ int main(int argc, char *argv[])
n = sscanf(buf, "%1c %s %s %d", &c, def, name, &tok); n = sscanf(buf, "%1c %s %s %d", &c, def, name, &tok);
if (c != '#' || (n != 4 && strcmp(def,"define") != 0)) /* not a valid #define */ if (c != '#' || (n != 4 && strcmp(def,"define") != 0)) /* not a valid #define */
continue; continue;
if (strcmp(name, "YYSTYPE_IS_DECLARED") == 0)
continue;
if (tok < FIRSTTOKEN || tok > LASTTOKEN) { if (tok < FIRSTTOKEN || tok > LASTTOKEN) {
/* fprintf(stderr, "maketab funny token %d %s ignored\n", tok, buf); */ /* fprintf(stderr, "maketab funny token %d %s ignored\n", tok, buf); */
continue; continue;