mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-11-25 20:38:08 +01:00
Fix missing final newline in notmuch search output
A previous commit to fix json formatting for null results
(0b1ddc5f66
) accidentally introduced a
regression that removed trailing newlines for non-json output. (There
wasn't a good test for this previously, but there is now). The
problem is due to the fundamental differences in formatting between
the json and non-json outputs. The only way to fix this was to add a
new formatting field that represents the string to output at the end
of a null result.
All output formatting tests should pass now, (in particular, the 4
recent test failures introduced to show this bug).
This commit is contained in:
parent
593d96ff1d
commit
049ac914f9
1 changed files with 15 additions and 3 deletions
|
@ -48,6 +48,7 @@ typedef struct search_format {
|
||||||
const char *item_sep;
|
const char *item_sep;
|
||||||
const char *item_end;
|
const char *item_end;
|
||||||
const char *results_end;
|
const char *results_end;
|
||||||
|
const char *results_null;
|
||||||
} search_format_t;
|
} search_format_t;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -72,6 +73,7 @@ static const search_format_t format_text = {
|
||||||
"%s", " ",
|
"%s", " ",
|
||||||
")", "\n",
|
")", "\n",
|
||||||
"",
|
"",
|
||||||
|
"\n",
|
||||||
"",
|
"",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -98,6 +100,7 @@ static const search_format_t format_json = {
|
||||||
"]", ",\n",
|
"]", ",\n",
|
||||||
"}",
|
"}",
|
||||||
"]\n",
|
"]\n",
|
||||||
|
"]\n",
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -236,6 +239,9 @@ do_search_threads (const search_format_t *format,
|
||||||
notmuch_thread_destroy (thread);
|
notmuch_thread_destroy (thread);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (first_thread)
|
||||||
|
fputs (format->results_null, stdout);
|
||||||
|
else
|
||||||
fputs (format->results_end, stdout);
|
fputs (format->results_end, stdout);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -280,6 +286,9 @@ do_search_messages (const search_format_t *format,
|
||||||
|
|
||||||
notmuch_messages_destroy (messages);
|
notmuch_messages_destroy (messages);
|
||||||
|
|
||||||
|
if (first_message)
|
||||||
|
fputs (format->results_null, stdout);
|
||||||
|
else
|
||||||
fputs (format->results_end, stdout);
|
fputs (format->results_end, stdout);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -329,6 +338,9 @@ do_search_tags (notmuch_database_t *notmuch,
|
||||||
if (messages)
|
if (messages)
|
||||||
notmuch_messages_destroy (messages);
|
notmuch_messages_destroy (messages);
|
||||||
|
|
||||||
|
if (first_tag)
|
||||||
|
fputs (format->results_null, stdout);
|
||||||
|
else
|
||||||
fputs (format->results_end, stdout);
|
fputs (format->results_end, stdout);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in a new issue