From: Patrick McHardy Date: Sat, 11 Apr 2015 13:54:19 +0000 (+0100) Subject: datatype: fix parsing of time type X-Git-Tag: v0.5~50^2~19 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=87908ff7a12c969ca21338ab7ed27ed93a9b09c3;p=thirdparty%2Fnftables.git datatype: fix parsing of time type Properly detect time strings in the lexer without quotation marks. Signed-off-by: Patrick McHardy --- diff --git a/src/datatype.c b/src/datatype.c index c93f76a3..0772b507 100644 --- a/src/datatype.c +++ b/src/datatype.c @@ -775,8 +775,6 @@ static void time_type_print(const struct expr *expr) minutes = seconds / 60; seconds %= 60; - printf("\""); - if (days > 0) printf("%"PRIu64"d", days); if (hours > 0) @@ -785,8 +783,6 @@ static void time_type_print(const struct expr *expr) printf("%"PRIu64"m", minutes); if (seconds > 0) printf("%"PRIu64"s", seconds); - - printf("\""); } enum { diff --git a/src/scanner.l b/src/scanner.l index 73c4f8b1..27d95bfc 100644 --- a/src/scanner.l +++ b/src/scanner.l @@ -117,6 +117,8 @@ quotedstring \"[^"]*\" comment #.*$ slash \/ +timestring ([0-9]+d)?([0-9]+h)?([0-9]+m)?([0-9]+s)? + hex4 ([[:xdigit:]]{1,4}) v680 (({hex4}:){7}{hex4}) v670 ((:)((:{hex4}){7})) @@ -457,6 +459,11 @@ addrstring ({macaddr}|{ip4addr}|{ip6addr}) return STRING; } +{timestring} { + yylval->string = xstrdup(yytext); + return STRING; + } + {decstring} { errno = 0; yylval->val = strtoull(yytext, NULL, 0);