=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/awk/maketab.c,v retrieving revision 1.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- src/usr.bin/awk/maketab.c 2020/06/10 21:05:02 1.17 +++ src/usr.bin/awk/maketab.c 2020/06/10 21:05:50 1.18 @@ -1,4 +1,4 @@ -/* $OpenBSD: maketab.c,v 1.17 2020/06/10 21:05:02 millert Exp $ */ +/* $OpenBSD: maketab.c,v 1.18 2020/06/10 21:05:50 millert Exp $ */ /**************************************************************** Copyright (C) Lucent Technologies 1997 All Rights Reserved @@ -119,6 +119,7 @@ char c; FILE *fp; char buf[200], name[200], def[200]; + enum { TOK_UNKNOWN, TOK_ENUM, TOK_DEFINE } tokentype = TOK_UNKNOWN; printf("#include \n"); printf("#include \"awk.h\"\n"); @@ -136,12 +137,28 @@ i = 0; while (fgets(buf, sizeof buf, fp) != NULL) { // 199 is sizeof(def) - 1 - n = sscanf(buf, "%1c %199s %199s %d", &c, def, name, &tok); - if (n != 4 || c != '#' || strcmp(def, "define") != 0) - continue; /* not a valid #define */ - if (strcmp(name, "YYSTYPE_IS_DECLARED") == 0) + if (tokentype != TOK_ENUM) { + n = sscanf(buf, "%1c %199s %199s %d", &c, def, name, + &tok); + if (n == 4 && c == '#' && strcmp(def, "define") == 0) { + tokentype = TOK_DEFINE; + } else if (tokentype != TOK_UNKNOWN) { + continue; + } + } + if (tokentype != TOK_DEFINE) { + /* not a valid #define, bison uses enums now */ + n = sscanf(buf, "%199s = %d,\n", name, &tok); + if (n != 2) + continue; + tokentype = TOK_ENUM; + } + if (strcmp(name, "YYSTYPE_IS_DECLARED") == 0) { + tokentype = TOK_UNKNOWN; continue; + } if (tok < FIRSTTOKEN || tok > LASTTOKEN) { + tokentype = TOK_UNKNOWN; /* fprintf(stderr, "maketab: funny token %d %s ignored\n", tok, buf); */ continue; }