From: Timo Sirainen Date: Sun, 24 Mar 2013 16:13:53 +0000 (+0200) Subject: doveadm: Table formatter now hides the titles if all of them are marked hidden. X-Git-Tag: 2.2.rc4~78 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0fa3852d310cf4d42a67fc53c955a14bd327ad8e;p=thirdparty%2Fdovecot%2Fcore.git doveadm: Table formatter now hides the titles if all of them are marked hidden. --- diff --git a/src/doveadm/doveadm-print-table.c b/src/doveadm/doveadm-print-table.c index 7a86571d16..168167dfe0 100644 --- a/src/doveadm/doveadm-print-table.c +++ b/src/doveadm/doveadm-print-table.c @@ -135,16 +135,20 @@ static void doveadm_print_next(const char *value) } } -static void doveadm_buffer_flush(void) +static void doveadm_print_headers(void) { const struct doveadm_print_table_header *headers; - const char *const *valuep; unsigned int i, count; - doveadm_calc_header_length(); - headers = array_get(&ctx->headers, &count); + /* if all headers are hidden, don't print any of them */ for (i = 0; i < count; i++) { + if ((headers[i].flags & DOVEADM_PRINT_HEADER_FLAG_HIDE_TITLE) == 0) + break; + } + if (i == count) + return; + for (; i < count; i++) { if (i > 0) fprintf(stderr, " "); if ((headers[i].flags & @@ -157,6 +161,14 @@ static void doveadm_buffer_flush(void) } } fprintf(stderr, "\n"); +} + +static void doveadm_buffer_flush(void) +{ + const char *const *valuep; + + doveadm_calc_header_length(); + doveadm_print_headers(); array_foreach(&ctx->buffered_values, valuep) doveadm_print_next(*valuep);