]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libsmartcols: (filter) emulate YYerror for old Bison
authorKarel Zak <kzak@redhat.com>
Mon, 15 Apr 2024 12:14:53 +0000 (14:14 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 15 Apr 2024 12:14:53 +0000 (14:14 +0200)
The special YYerror token is supported in Bison 3.6 and above.
Fortunately, it is possible to emulate this functionality in older
versions as well.

Signed-off-by: Karel Zak <kzak@redhat.com>
libsmartcols/src/filter-parser.y
libsmartcols/src/filter-scanner.l

index c368c952c23ff821663310f3c7d11d604b62427d..5104227370ae148e4d497423547a89c9983f94e9 100644 (file)
@@ -55,6 +55,7 @@ void yyerror(yyscan_t *locp, struct libscols_filter *fltr, char const *fmt, ...)
 %left T_OR T_AND
 %left T_EQ T_NE T_LT T_LE T_GT T_GE T_REG T_NREG T_TRUE T_FALSE T_NEG
 
+%token T_INVALID_NUMBER
 
 %destructor {
                /* This destruct is called on error. The root node will be deallocated
@@ -111,7 +112,10 @@ param:
                bool x = false;
                $$ = filter_new_param(fltr, SCOLS_DATA_BOOLEAN, 0, (void *) &x);
        }
-
+       | T_INVALID_NUMBER {            /* YYerror token is unsupported in old Bisons */
+               ignore_result( $$ );    /* supress "unset value" warning */
+               YYERROR;                /* yyerror() already called by lex() */
+       }
 ;
 
 
index 3b1d0b0fcc8a5551a0a04745207daa8609994d26..892fca12b8fa300df69d77f76e6ad9eae91209f3 100644 (file)
@@ -59,12 +59,12 @@ true|TRUE   return T_TRUE;
                        yyerror(yyscanner, yyextra, "\"%s\" token error: %m", yytext);
                else
                        yyerror(yyscanner, yyextra, "\"%s\" token error", yytext);
-               return YYerror;
+               return T_INVALID_NUMBER;
        }
 
        if (res > ULLONG_MAX) {
                yyerror(yyscanner, yyextra, "\"%s\" number too large", yytext);
-               return YYerror;
+               return T_INVALID_NUMBER;
        }
 
        yylval->param_number = (unsigned long long) res;