]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
rule: don't print trailing statement whitespace
authorArturo Borrero <arturo.borrero.glez@gmail.com>
Wed, 23 Mar 2016 12:51:33 +0000 (13:51 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Tue, 29 Mar 2016 11:19:24 +0000 (13:19 +0200)
This trailing whitespace is annoying when working with the textual output
of nft.

Before:

table t {
chain c {
ct state new
    ^
}
}

After:

table t {
chain c {
ct state new
}
}

Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/rule.c

index 85987b9b5a09d74176797f7fcb2fb8896cbd3f2a..0ed77941e11d3425167352d5c278e9c4b441b570 100644 (file)
@@ -385,14 +385,15 @@ void rule_print(const struct rule *rule)
 
        list_for_each_entry(stmt, &rule->stmts, list) {
                stmt->ops->print(stmt);
-               printf(" ");
+               if (!list_is_last(&stmt->list, &rule->stmts))
+                       printf(" ");
        }
 
        if (rule->comment)
-               printf("comment \"%s\" ", rule->comment);
+               printf(" comment \"%s\"", rule->comment);
 
        if (handle_output > 0)
-               printf("# handle %" PRIu64, rule->handle.handle);
+               printf(" # handle %" PRIu64, rule->handle.handle);
 }
 
 struct scope *scope_init(struct scope *scope, const struct scope *parent)