]> git.ipfire.org Git - thirdparty/util-linux.git/blobdiff - libsmartcols/src/filter-scanner.l
libsmartcols: (filter) emulate YYerror for old Bison
[thirdparty/util-linux.git] / libsmartcols / src / filter-scanner.l
index 5d2571d157d879e7a7c8d58dc8c60ad44ccf91e6..892fca12b8fa300df69d77f76e6ad9eae91209f3 100644 (file)
@@ -2,6 +2,8 @@
 #include "smartcolsP.h"
 #include "filter-parser.h"     /* define tokens (T_*) */
 
+void yyerror(yyscan_t *locp, struct libscols_filter *fltr, char const *fmt, ...);
+
 %}
 
 %option reentrant bison-bridge noyywrap noinput nounput
@@ -46,6 +48,29 @@ true|TRUE    return T_TRUE;
        return T_FLOAT;
 }
 
+{int}+([KMGTPEZY](iB)?) {
+       uintmax_t res;
+       int e;
+
+       errno = 0;
+       e = strtosize(yytext, &res);
+       if (e < 0) {
+               if (errno)
+                       yyerror(yyscanner, yyextra, "\"%s\" token error: %m", yytext);
+               else
+                       yyerror(yyscanner, yyextra, "\"%s\" token error", yytext);
+               return T_INVALID_NUMBER;
+       }
+
+       if (res > ULLONG_MAX) {
+               yyerror(yyscanner, yyextra, "\"%s\" number too large", yytext);
+               return T_INVALID_NUMBER;
+       }
+
+       yylval->param_number = (unsigned long long) res;
+       return T_NUMBER;
+}
+
 {int}+ {
        yylval->param_number = (int64_t) strtoumax(yytext, NULL, 10);
        return T_NUMBER;