aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarel Zak <kzak@redhat.com>2024-04-15 11:54:34 +0200
committerKarel Zak <kzak@redhat.com>2024-04-15 12:53:51 +0200
commit1c48fbaf2af691f9484dd988afd62044fa797f42 (patch)
treed27a83330f3e02f4691b66fa75366c38d61ec181
parent5aa0c75c78dfb6a0c9851b348ba778149a4550a5 (diff)
downloadutil-linux-1c48fbaf2af691f9484dd988afd62044fa797f42.tar.gz
libsmartcols; (filter) make libscols_filter accessible in lex
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>
-rw-r--r--libsmartcols/src/filter-scanner.l2
-rw-r--r--libsmartcols/src/filter.c1
2 files changed, 3 insertions, 0 deletions
diff --git a/libsmartcols/src/filter-scanner.l b/libsmartcols/src/filter-scanner.l
index 501b603b1d..5d2571d157 100644
--- a/libsmartcols/src/filter-scanner.l
+++ b/libsmartcols/src/filter-scanner.l
@@ -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]+
diff --git a/libsmartcols/src/filter.c b/libsmartcols/src/filter.c
index dccf05cf01..e0c1c7ae0b 100644
--- a/libsmartcols/src/filter.c
+++ b/libsmartcols/src/filter.c
@@ -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);