]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
datatype: fix parsing of time type
authorPatrick McHardy <kaber@trash.net>
Sat, 11 Apr 2015 13:54:19 +0000 (14:54 +0100)
committerPatrick McHardy <kaber@trash.net>
Sun, 12 Apr 2015 18:59:27 +0000 (19:59 +0100)
Properly detect time strings in the lexer without quotation marks.

Signed-off-by: Patrick McHardy <kaber@trash.net>
src/datatype.c
src/scanner.l

index c93f76a3857a6fa5e3fefe5b5cd6efaf27b59b52..0772b5074b2a84d84210d18b784b04e68bd739bc 100644 (file)
@@ -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 {
index 73c4f8b1431e6a4aeafafef1fc79c55fad1199cd..27d95bfc3ff9d2f89fd3c89e96a9fc7b3f27699a 100644 (file)
@@ -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);