Skip to contentSkip to conversation

scanner: Introduce numberstring

PATCH In review Phil Sutter 2 participants 2 messages Nov 15, 2019 – Nov 18, 2019 netfilter

lore
Share & tools
lore

Phil Sutter

author reviewer
#0 lore raw

PATCH 1/1 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.

---
 src/scanner.l | 13 ++-----------
 1 file changed, 2 insertions(+), 11 deletions(-)
src/scanner.l +2 -11
index 3de5a9e0426e6..80b5a5f0dafcf 100644
@@ -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) {
Signature · 1 line
2.24.0