From: Andre Noll Date: Sat, 6 Apr 2013 19:25:18 +0000 (+0000) Subject: filter: Wrap lines in the available filter list. X-Git-Tag: v0.4.13~23^2~15 X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=commitdiff_plain;h=b59a3c41;hp=9e56d38942f4d2ec068a0ae81c6dd9349ac8d1c3;ds=sidebyside filter: Wrap lines in the available filter list. Currently para_filter -h and para_audiod -h print the available filters in a single line which exceeds 80 characters if many filters are supported. This patch makes printf_or_die() return the number of characters printed. This allows to add line breaks to format the filter list. --- diff --git a/filter_common.c b/filter_common.c index 907912fd..6eb550e8 100644 --- a/filter_common.c +++ b/filter_common.c @@ -105,12 +105,17 @@ int check_filter_arg(char *fa, void **conf) */ void print_filter_helps(int detailed) { - int i; + int i, num = 0; - printf_or_die("\nAvailable filters: \n\t"); - FOR_EACH_SUPPORTED_FILTER(i) - printf_or_die("%s%s", i? " " : "", filters[i].name); - printf_or_die("\n\n"); + printf_or_die("\nAvailable filters: "); + FOR_EACH_SUPPORTED_FILTER(i) { + if (num > 50) { + printf_or_die("\n "); + num = 0; + } + num += printf_or_die("%s%s", i? " " : "", filters[i].name); + } + printf_or_die("\n"); FOR_EACH_SUPPORTED_FILTER(i) { struct filter *f = filters + i; diff --git a/ggo.c b/ggo.c index b2e079ab..7f8eb760 100644 --- a/ggo.c +++ b/ggo.c @@ -15,7 +15,7 @@ * * \param fmt Usual format string. */ -__printf_1_2 void printf_or_die(const char *fmt, ...) +__printf_1_2 int printf_or_die(const char *fmt, ...) { va_list argp; int ret; @@ -24,7 +24,7 @@ __printf_1_2 void printf_or_die(const char *fmt, ...) ret = vprintf(fmt, argp); va_end(argp); if (ret >= 0) - return; + return ret; exit(EXIT_FAILURE); } diff --git a/ggo.h b/ggo.h index e81b10c6..be85a1b4 100644 --- a/ggo.h +++ b/ggo.h @@ -17,4 +17,4 @@ struct ggo_help { }; void ggo_print_help(struct ggo_help *help, int detailed_help); -__printf_1_2 void printf_or_die(const char *fmt, ...); +__printf_1_2 int printf_or_die(const char *fmt, ...);