]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
expr: relational: don't surpress '==' for LHS binops in output
authorPatrick McHardy <kaber@trash.net>
Wed, 15 Jan 2014 15:39:10 +0000 (15:39 +0000)
committerPatrick McHardy <kaber@trash.net>
Wed, 15 Jan 2014 15:39:10 +0000 (15:39 +0000)
This patch changes the output of relational expressions to not surpress
the '==' when the LHS is a binop, f.i.

... meta mark & 0x00000003 0x00000001

becomes

... meta mark & 0x00000003 == 0x00000001

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

index 71154cc6c0a96d4beae486de4a04d24899ed072b..518f71c8ba15d133a7423b599abb520bc0b58104 100644 (file)
@@ -356,7 +356,7 @@ const char *expr_op_symbols[] = {
        [OP_XOR]        = "^",
        [OP_LSHIFT]     = "<<",
        [OP_RSHIFT]     = ">>",
-       [OP_EQ]         = NULL,
+       [OP_EQ]         = "==",
        [OP_NEQ]        = "!=",
        [OP_LT]         = "<",
        [OP_GT]         = ">",
@@ -407,7 +407,9 @@ struct expr *unary_expr_alloc(const struct location *loc,
 static void binop_expr_print(const struct expr *expr)
 {
        expr_print(expr->left);
-       if (expr_op_symbols[expr->op] != NULL)
+       if (expr_op_symbols[expr->op] &&
+           (expr->op != OP_EQ ||
+            expr->left->ops->type == EXPR_BINOP))
                printf(" %s ", expr_op_symbols[expr->op]);
        else
                printf(" ");