From: Elise Lennion Date: Thu, 2 Feb 2017 12:31:56 +0000 (-0200) Subject: src: Always print range expressions numerically X-Git-Tag: v0.8~248 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=85b1e3c0052ef;p=thirdparty%2Fnftables.git src: Always print range expressions numerically Because the rules are more legible this way. Also, the parser doesn't accept strings on ranges, so, printing ranges numerically better match the rules definition. Fixes(Bug 1046 - mobility header with range gives illegible rule). Signed-off-by: Elise Lennion Signed-off-by: Pablo Neira Ayuso --- diff --git a/src/datatype.c b/src/datatype.c index 1518606a..d697a075 100644 --- a/src/datatype.c +++ b/src/datatype.c @@ -175,9 +175,15 @@ void symbolic_constant_print(const struct symbol_table *tbl, return expr_basetype(expr)->print(expr); if (quotes) - printf("\"%s\"", s->identifier); + printf("\""); + + if (numeric_output > NUMERIC_ALL) + printf("%lu", val); else printf("%s", s->identifier); + + if (quotes) + printf("\""); } static void switch_byteorder(void *data, unsigned int len) diff --git a/src/expression.c b/src/expression.c index 1567870c..da94b79f 100644 --- a/src/expression.c +++ b/src/expression.c @@ -597,9 +597,11 @@ struct expr *relational_expr_alloc(const struct location *loc, enum ops op, static void range_expr_print(const struct expr *expr) { + numeric_output += NUMERIC_ALL + 1; expr_print(expr->left); printf("-"); expr_print(expr->right); + numeric_output -= NUMERIC_ALL + 1; } static void range_expr_clone(struct expr *new, const struct expr *expr)