]> git.draconx.ca Git - cdecl99.git/commitdiff
libcdecl: Fix crash when bootstrapped w/ old Bison.
authorNick Bowler <nbowler@draconx.ca>
Thu, 20 Jul 2023 00:22:32 +0000 (20:22 -0400)
committerNick Bowler <nbowler@draconx.ca>
Thu, 20 Jul 2023 00:22:32 +0000 (20:22 -0400)
We are comparing the packed token value to check whether this is an
identifier or a keyword against the true value.  This happens to work
on new Bison (when using api.token.raw) as these values are the same,
but on old Bison the result is never true.

Thus, the scanner fails to assign the "strval" for identifier tokens
and the result fails very badly.  Easy enough to fix.

src/scan.l

index 90f5ad9de3b88af33fc145f76181a4c9e32ef653..767ba2263aca0eea2fe0888ff0c2e4dd4207e767 100644 (file)
@@ -173,7 +173,7 @@ INTEGER 0x[[:xdigit:]]+|0[0-7]+|[[:digit:]]+
        int tok;
 
        yylval->spectype = UNPACK_SPEC(x & 0xff);
-       if ((tok = (x >> 8)) == T_IDENT) {
+       if ((tok = (x >> 8)) == PACK_TOKEN(T_IDENT)) {
                /*
                 * Our IDENT pattern includes hyphens so we can match
                 * "variable-length" as a keyword.  In all other cases a