diff options
author | Jan Engelhardt <jengelh@medozas.de> | 2010-12-18 02:04:59 +0100 |
---|---|---|
committer | Jan Engelhardt <jengelh@medozas.de> | 2011-01-31 03:05:34 +0100 |
commit | 73866357e4a7a0fdc1b293bf8863fee2bd56da9e (patch) | |
tree | 1890725e5f327ba14ccf452ff9e5916954d7908f /extensions/libxt_dccp.c | |
parent | bb8be30857edd501e701c2f22db6c59bd6839c87 (diff) |
iptables: do not print trailing whitespaces
Due to the use of printf("foobar "), iptables emits spaces at the
end-of-line, which looks odd to some users because it causes the
terminal to wrap even if there is seemingly nothing to print.
It may also have other points of annoyance, such as mailers
interpreting a trailing space as an indicator that the paragraph
continues when format=flowed is also on.
And git highlights trailing spaces in red, so let's avoid :)
Preexisting inconsistencies in outputting spaces in the right
spot are also addressed right away.
References: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=429579
Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
Diffstat (limited to 'extensions/libxt_dccp.c')
-rw-r--r-- | extensions/libxt_dccp.c | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/extensions/libxt_dccp.c b/extensions/libxt_dccp.c index 7a0e96b5..3b2dc6b8 100644 --- a/extensions/libxt_dccp.c +++ b/extensions/libxt_dccp.c @@ -216,7 +216,7 @@ print_ports(const char *name, uint16_t min, uint16_t max, const char *inv = invert ? "!" : ""; if (min != 0 || max != 0xFFFF || invert) { - printf("%s", name); + printf(" %s", name); if (min == max) { printf(":%s", inv); print_port(min, numeric); @@ -226,7 +226,6 @@ print_ports(const char *name, uint16_t min, uint16_t max, printf(":"); print_port(max, numeric); } - printf(" "); } } @@ -236,8 +235,9 @@ print_types(uint16_t types, int inverted, int numeric) int have_type = 0; if (inverted) - printf("! "); + printf(" !"); + printf(" "); while (types) { unsigned int i; @@ -261,7 +261,7 @@ static void print_option(uint8_t option, int invert, int numeric) { if (option || invert) - printf("option=%s%u ", invert ? "!" : "", option); + printf(" option=%s%u", invert ? "!" : "", option); } static void @@ -270,7 +270,7 @@ dccp_print(const void *ip, const struct xt_entry_match *match, int numeric) const struct xt_dccp_info *einfo = (const struct xt_dccp_info *)match->data; - printf("dccp "); + printf(" dccp"); if (einfo->flags & XT_DCCP_SRC_PORTS) { print_ports("spt", einfo->spts[0], einfo->spts[1], @@ -303,31 +303,31 @@ static void dccp_save(const void *ip, const struct xt_entry_match *match) if (einfo->flags & XT_DCCP_SRC_PORTS) { if (einfo->invflags & XT_DCCP_SRC_PORTS) - printf("! "); + printf(" !"); if (einfo->spts[0] != einfo->spts[1]) - printf("--sport %u:%u ", + printf(" --sport %u:%u", einfo->spts[0], einfo->spts[1]); else - printf("--sport %u ", einfo->spts[0]); + printf(" --sport %u", einfo->spts[0]); } if (einfo->flags & XT_DCCP_DEST_PORTS) { if (einfo->invflags & XT_DCCP_DEST_PORTS) - printf("! "); + printf(" !"); if (einfo->dpts[0] != einfo->dpts[1]) - printf("--dport %u:%u ", + printf(" --dport %u:%u", einfo->dpts[0], einfo->dpts[1]); else - printf("--dport %u ", einfo->dpts[0]); + printf(" --dport %u", einfo->dpts[0]); } if (einfo->flags & XT_DCCP_TYPE) { - printf("--dccp-type "); + printf(" --dccp-type"); print_types(einfo->typemask, einfo->invflags & XT_DCCP_TYPE,0); } if (einfo->flags & XT_DCCP_OPTION) { - printf("--dccp-option %s%u ", + printf(" --dccp-option %s%u", einfo->typemask & XT_DCCP_OPTION ? "! " : "", einfo->option); } |