aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarel Zak <kzak@redhat.com>2024-04-15 14:14:53 +0200
committerKarel Zak <kzak@redhat.com>2024-04-15 14:14:53 +0200
commit1c1073e0dccef02d45818403244832d8044d08ff (patch)
treec0b5894794ab8ab6f2e768fbc6395c570e4644cb
parentdd5099b12a2c8ebc2995c01c00b6ca244266b737 (diff)
downloadutil-linux-1c1073e0dccef02d45818403244832d8044d08ff.tar.gz
libsmartcols: (filter) emulate YYerror for old Bison
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>
-rw-r--r--libsmartcols/src/filter-parser.y6
-rw-r--r--libsmartcols/src/filter-scanner.l4
2 files changed, 7 insertions, 3 deletions
diff --git a/libsmartcols/src/filter-parser.y b/libsmartcols/src/filter-parser.y
index c368c952c2..5104227370 100644
--- a/libsmartcols/src/filter-parser.y
+++ b/libsmartcols/src/filter-parser.y
@@ -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() */
+ }
;
diff --git a/libsmartcols/src/filter-scanner.l b/libsmartcols/src/filter-scanner.l
index 3b1d0b0fcc..892fca12b8 100644
--- a/libsmartcols/src/filter-scanner.l
+++ b/libsmartcols/src/filter-scanner.l
@@ -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;