]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libsmartcols; (filter) make libscols_filter accessible in lex
authorKarel Zak <kzak@redhat.com>
Mon, 15 Apr 2024 09:54:34 +0000 (11:54 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 15 Apr 2024 10:53:51 +0000 (12:53 +0200)
In the reentrant parser, we cannot easily extend the argument list for
yylex() using %lex-param. Instead, we must use a lex-extra pointer.

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

index 501b603b1da5cc99f66def71ef53634001f24f5f..5d2571d157d879e7a7c8d58dc8c60ad44ccf91e6 100644 (file)
@@ -1,9 +1,11 @@
 %{
 #include "smartcolsP.h"
 #include "filter-parser.h"     /* define tokens (T_*) */
+
 %}
 
 %option reentrant bison-bridge noyywrap noinput nounput
+%option extra-type="struct libscols_filter *"
 
 id     [a-zA-Z][a-zA-Z_.%:/\-0-9]*
 int    [0-9]+
index dccf05cf01394a0e57164594d8a544ff03f6c6eb..e0c1c7ae0b19cb2f2b93b153057d1944f224091b 100644 (file)
@@ -196,6 +196,7 @@ int scols_filter_parse_string(struct libscols_filter *fltr, const char *str)
                return -errno;
 
        yylex_init(&sc);
+       yylex_init_extra(fltr, &sc);
        yyset_in(fltr->src, sc);
 
        rc = yyparse(sc, fltr);