From: Arturo Borrero Date: Wed, 23 Mar 2016 12:51:33 +0000 (+0100) Subject: rule: don't print trailing statement whitespace X-Git-Tag: v0.6~78 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=89e3001be44aa2f25e51b139f044328230cbb098;p=thirdparty%2Fnftables.git rule: don't print trailing statement whitespace 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 Signed-off-by: Pablo Neira Ayuso --- diff --git a/src/rule.c b/src/rule.c index 85987b9b..0ed77941 100644 --- a/src/rule.c +++ b/src/rule.c @@ -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)