[nft PATCH] scanner: Introduce numberstring

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxx>
---
 src/scanner.l | 13 ++-----------
 1 file changed, 2 insertions(+), 11 deletions(-)

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) {
-- 
2.24.0




[Index of Archives]     [Netfitler Users]     [Berkeley Packet Filter]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux