summaryrefslogtreecommitdiffstats
path: root/src/scanner.l
diff options
context:
space:
mode:
authorPhil Sutter <phil@nwl.cc>2019-11-15 19:11:32 +0100
committerPhil Sutter <phil@nwl.cc>2019-11-19 01:09:15 +0100
commit9f9930e774039c5487a9236a25d9dabd5df39355 (patch)
treea1f7e6600d064fd6e405bd032a02faec693cbc40 /src/scanner.l
parent82fe8e1ffd006d0f0fd3cdd2df5ca2514de10db9 (diff)
scanner: Introduce numberstring
This token combines decstring and hexstring. The latter two had identical action blocks (which were not completely trivial), this allows to merge them. Signed-off-by: Phil Sutter <phil@nwl.cc> Acked-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/scanner.l')
-rw-r--r--src/scanner.l13
1 files changed, 2 insertions, 11 deletions
diff --git a/src/scanner.l b/src/scanner.l
index 3de5a9e0..80b5a5f0 100644
--- a/src/scanner.l
+++ b/src/scanner.l
@@ -116,6 +116,7 @@ digit [0-9]
hexdigit [0-9a-fA-F]
decstring {digit}+
hexstring 0[xX]{hexdigit}+
+numberstring ({decstring}|{hexstring})
letter [a-zA-Z]
string ({letter}|[_.])({letter}|{digit}|[/\-_\.])*
quotedstring \"[^"]*\"
@@ -608,17 +609,7 @@ addrstring ({macaddr}|{ip4addr}|{ip6addr})
return STRING;
}
-{decstring} {
- errno = 0;
- yylval->val = strtoull(yytext, NULL, 0);
- if (errno != 0) {
- yylval->string = xstrdup(yytext);
- return STRING;
- }
- return NUM;
- }
-
-{hexstring} {
+{numberstring} {
errno = 0;
yylval->val = strtoull(yytext, NULL, 0);
if (errno != 0) {