diff mbox series

[nft] scanner: Introduce numberstring

Message ID 20191115183813.25085-1-phil@nwl.cc
State Accepted
Delegated to: Pablo Neira
Headers show
Series [nft] scanner: Introduce numberstring | expand

Commit Message

Phil Sutter Nov. 15, 2019, 6:38 p.m. UTC
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>
---
 src/scanner.l | 13 ++-----------
 1 file changed, 2 insertions(+), 11 deletions(-)

Comments

Pablo Neira Ayuso Nov. 18, 2019, 6:35 p.m. UTC | #1
On Fri, Nov 15, 2019 at 07:38:13PM +0100, Phil Sutter wrote:
> 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>
diff mbox series

Patch

diff --git a/src/scanner.l b/src/scanner.l
index 3de5a9e0426e6..80b5a5f0dafcf 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) {