Skip to content

Commit 2982cfa

Browse files
mrannanjGitLab
authored andcommitted
doveadm: \f\n only between pages in pager
No more \f\n in the end.
1 parent ac9600e commit 2982cfa

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/doveadm/doveadm-print-pager.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ struct doveadm_print_pager_context {
1515
unsigned int header_idx;
1616

1717
unsigned int streaming:1;
18+
unsigned int first_page:1;
1819
};
1920

2021
static struct doveadm_print_pager_context *ctx;
@@ -32,7 +33,6 @@ static void pager_next_hdr(void)
3233
{
3334
if (++ctx->header_idx == array_count(&ctx->headers)) {
3435
ctx->header_idx = 0;
35-
o_stream_nsend(doveadm_print_ostream, "\f\n", 2);
3636
}
3737
}
3838

@@ -41,6 +41,10 @@ static void doveadm_print_pager_print(const char *value)
4141
const struct doveadm_print_pager_header *hdr =
4242
array_idx(&ctx->headers, ctx->header_idx);
4343

44+
if (ctx->header_idx == 0 && !ctx->first_page) {
45+
o_stream_nsend(doveadm_print_ostream, "\f\n", 2);
46+
}
47+
ctx->first_page = FALSE;
4448
o_stream_nsend_str(doveadm_print_ostream, hdr->title);
4549
o_stream_nsend(doveadm_print_ostream, ": ", 2);
4650
o_stream_nsend_str(doveadm_print_ostream, value);
@@ -73,6 +77,7 @@ static void doveadm_print_pager_init(void)
7377
pool = pool_alloconly_create("doveadm print pager", 1024);
7478
ctx = p_new(pool, struct doveadm_print_pager_context, 1);
7579
ctx->pool = pool;
80+
ctx->first_page = TRUE;
7681
p_array_init(&ctx->headers, pool, 16);
7782
}
7883

0 commit comments

Comments
 (0)