show: Support NULL values for message_set_{start, sep, end}

Many formats don't need these, so it's more convenient if they don't
have to set them at all.
This commit is contained in:
Austin Clements 2012-04-07 20:57:49 -04:00 committed by David Bremner
parent 9070e5cc43
commit 67da35222c

View file

@ -845,16 +845,18 @@ show_messages (void *ctx,
int next_indent; int next_indent;
notmuch_status_t status, res = NOTMUCH_STATUS_SUCCESS; notmuch_status_t status, res = NOTMUCH_STATUS_SUCCESS;
if (format->message_set_start)
fputs (format->message_set_start, stdout); fputs (format->message_set_start, stdout);
for (; for (;
notmuch_messages_valid (messages); notmuch_messages_valid (messages);
notmuch_messages_move_to_next (messages)) notmuch_messages_move_to_next (messages))
{ {
if (!first_set) if (!first_set && format->message_set_sep)
fputs (format->message_set_sep, stdout); fputs (format->message_set_sep, stdout);
first_set = 0; first_set = 0;
if (format->message_set_start)
fputs (format->message_set_start, stdout); fputs (format->message_set_start, stdout);
message = notmuch_messages_get (messages); message = notmuch_messages_get (messages);
@ -870,7 +872,7 @@ show_messages (void *ctx,
res = status; res = status;
next_indent = indent + 1; next_indent = indent + 1;
if (!status) if (!status && format->message_set_sep)
fputs (format->message_set_sep, stdout); fputs (format->message_set_sep, stdout);
} }
@ -884,9 +886,11 @@ show_messages (void *ctx,
notmuch_message_destroy (message); notmuch_message_destroy (message);
if (format->message_set_end)
fputs (format->message_set_end, stdout); fputs (format->message_set_end, stdout);
} }
if (format->message_set_end)
fputs (format->message_set_end, stdout); fputs (format->message_set_end, stdout);
return res; return res;
@ -933,6 +937,7 @@ do_show (void *ctx,
int first_toplevel = 1; int first_toplevel = 1;
notmuch_status_t status, res = NOTMUCH_STATUS_SUCCESS; notmuch_status_t status, res = NOTMUCH_STATUS_SUCCESS;
if (format->message_set_start)
fputs (format->message_set_start, stdout); fputs (format->message_set_start, stdout);
for (threads = notmuch_query_search_threads (query); for (threads = notmuch_query_search_threads (query);
@ -947,7 +952,7 @@ do_show (void *ctx,
INTERNAL_ERROR ("Thread %s has no toplevel messages.\n", INTERNAL_ERROR ("Thread %s has no toplevel messages.\n",
notmuch_thread_get_thread_id (thread)); notmuch_thread_get_thread_id (thread));
if (!first_toplevel) if (!first_toplevel && format->message_set_sep)
fputs (format->message_set_sep, stdout); fputs (format->message_set_sep, stdout);
first_toplevel = 0; first_toplevel = 0;
@ -959,6 +964,7 @@ do_show (void *ctx,
} }
if (format->message_set_end)
fputs (format->message_set_end, stdout); fputs (format->message_set_end, stdout);
return res != NOTMUCH_STATUS_SUCCESS; return res != NOTMUCH_STATUS_SUCCESS;