From: Karel Zak Date: Mon, 15 Apr 2024 12:14:53 +0000 (+0200) Subject: libsmartcols: (filter) emulate YYerror for old Bison X-Git-Tag: v2.42-start~406 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1c1073e0dccef02d45818403244832d8044d08ff;p=thirdparty%2Futil-linux.git 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 --- diff --git a/libsmartcols/src/filter-parser.y b/libsmartcols/src/filter-parser.y index c368c952c..510422737 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 3b1d0b0fc..892fca12b 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;