]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
scanner: Introduce numberstring
authorPhil Sutter <phil@nwl.cc>
Fri, 15 Nov 2019 18:11:32 +0000 (19:11 +0100)
committerPhil Sutter <phil@nwl.cc>
Tue, 19 Nov 2019 00:09:15 +0000 (01:09 +0100)
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>
src/scanner.l

index 3de5a9e0426e6853a98d114300e48b76155a38fc..80b5a5f0dafcfdcaa7df186481cc0ffc28ca3f7c 100644 (file)
@@ -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) {