diff options
author | Austin Clements <amdragon@MIT.EDU> | 2012-08-02 21:14:57 -0400 |
---|---|---|
committer | David Bremner <bremner@debian.org> | 2012-08-03 20:37:20 -0300 |
commit | 305a7ade1e20e162ff71a007e414ca301e4b90f5 (patch) | |
tree | 4a2e6798d87ef20bf1e0b4a725db26a24080a3e8 | |
parent | 26ba4abe535f5757d280401bc7de1cfacbd081b5 (diff) |
show: Convert show_message to use sprinter
Unlike the previous patches, this function is used for all formats.
However, for formats other than the JSON format, the sprinter methods
used by show_message are all no-ops, so this code continues to
function correctly for all of the formats.
Converting show_message eliminates show_null_message in the process,
since this maps directly to an sprinter method.
-rw-r--r-- | notmuch-show.c | 31 |
1 files changed, 5 insertions, 26 deletions
diff --git a/notmuch-show.c b/notmuch-show.c index b9d9f5d..ec3e861 100644 --- a/notmuch-show.c +++ b/notmuch-show.c @@ -842,15 +842,6 @@ format_part_raw (unused (const void *ctx), unused (sprinter_t *sp), } static notmuch_status_t -show_null_message (const notmuch_show_format_t *format) -{ - /* Output a null message. Currently empty for all formats except Json */ - if (format->null_message) - printf ("%s", format->null_message); - return NOTMUCH_STATUS_SUCCESS; -} - -static notmuch_status_t show_message (void *ctx, const notmuch_show_format_t *format, sprinter_t *sp, @@ -884,23 +875,16 @@ show_messages (void *ctx, notmuch_message_t *message; notmuch_bool_t match; notmuch_bool_t excluded; - int first_set = 1; int next_indent; notmuch_status_t status, res = NOTMUCH_STATUS_SUCCESS; - if (format->message_set_start) - fputs (format->message_set_start, stdout); + sp->begin_list (sp); for (; notmuch_messages_valid (messages); notmuch_messages_move_to_next (messages)) { - if (!first_set && format->message_set_sep) - fputs (format->message_set_sep, stdout); - first_set = 0; - - if (format->message_set_start) - fputs (format->message_set_start, stdout); + sp->begin_list (sp); message = notmuch_messages_get (messages); @@ -915,12 +899,9 @@ show_messages (void *ctx, res = status; next_indent = indent + 1; } else { - status = show_null_message (format); + sp->null (sp); } - if (!status && format->message_set_sep) - fputs (format->message_set_sep, stdout); - status = show_messages (ctx, format, sp, notmuch_message_get_replies (message), @@ -931,12 +912,10 @@ show_messages (void *ctx, notmuch_message_destroy (message); - if (format->message_set_end) - fputs (format->message_set_end, stdout); + sp->end (sp); } - if (format->message_set_end) - fputs (format->message_set_end, stdout); + sp->end (sp); return res; } |