Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 2E52E431FBD for ; Tue, 24 Jul 2012 19:35:12 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.7 X-Spam-Level: X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id JpdQAP6dVo-Z for ; Tue, 24 Jul 2012 19:35:10 -0700 (PDT) Received: from dmz-mailsec-scanner-2.mit.edu (DMZ-MAILSEC-SCANNER-2.MIT.EDU [18.9.25.13]) by olra.theworths.org (Postfix) with ESMTP id 586F8431FD4 for ; Tue, 24 Jul 2012 19:35:06 -0700 (PDT) X-AuditID: 1209190d-b7fd56d000000933-55-500f5b59cc32 Received: from mailhub-auth-1.mit.edu ( [18.9.21.35]) by dmz-mailsec-scanner-2.mit.edu (Symantec Messaging Gateway) with SMTP id 93.A4.02355.95B5F005; Tue, 24 Jul 2012 22:35:05 -0400 (EDT) Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103]) by mailhub-auth-1.mit.edu (8.13.8/8.9.2) with ESMTP id q6P2Z5hE011178; Tue, 24 Jul 2012 22:35:05 -0400 Received: from drake.dyndns.org (209-6-116-242.c3-0.arl-ubr1.sbo-arl.ma.cable.rcn.com [209.6.116.242]) (authenticated bits=0) (User authenticated as amdragon@ATHENA.MIT.EDU) by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q6P2Z2Bi025130 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); Tue, 24 Jul 2012 22:35:04 -0400 (EDT) Received: from amthrax by drake.dyndns.org with local (Exim 4.77) (envelope-from ) id 1StrRG-0004aE-Pg; Tue, 24 Jul 2012 22:35:02 -0400 From: Austin Clements To: notmuch@notmuchmail.org Subject: [PATCH 11/13] show: Convert show_message to use sprinter Date: Tue, 24 Jul 2012 22:34:51 -0400 Message-Id: <1343183693-17134-12-git-send-email-amdragon@mit.edu> X-Mailer: git-send-email 1.7.10 In-Reply-To: <1343183693-17134-1-git-send-email-amdragon@mit.edu> References: <1343183693-17134-1-git-send-email-amdragon@mit.edu> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrFIsWRmVeSWpSXmKPExsUixCmqrBsZzR9gsHiWhsXehnZGi+s3ZzI7 MHks3rSfzePZqlvMAUxRXDYpqTmZZalF+nYJXBnL78xgLOgSqZh1/w1TA+NT/i5GTg4JAROJ +90HGSFsMYkL99azgdhCAvsYJTZfKe5i5AKyNzBKXD4xlxUi8YhJ4t/8fAh7LqPExvkiIDab gIbEtv3LwQaJCEhL7Lw7G6yeWcBMYu7PiWBDhQUcJZ7PmccEYrMIqEp8u/YOKM7BwQsU39Wm B3GDvMTT+31g5ZxA4fNLFjJCrHKQ6Fl8jX0CI/8CRoZVjLIpuVW6uYmZOcWpybrFyYl5ealF ukZ6uZkleqkppZsYwUEkybuD8d1BpUOMAhyMSjy8v5/wBQixJpYVV+YeYpTkYFIS5a0I5g8Q 4kvKT6nMSCzOiC8qzUktPsQowcGsJMJbFAaU401JrKxKLcqHSUlzsCiJ815JuekvJJCeWJKa nZpakFoEk5Xh4FCS4N0fBdQoWJSanlqRlplTgpBm4uAEGc4DNHw3SA1vcUFibnFmOkT+FKOi lDjvXJCEAEgiozQPrhcW5a8YxYFeEYZo5wEmCLjuV0CDmYAGPw/jAxlckoiQkmpgNK5xnzd/ roiSx51lM1JEtR8d/FT58qV038Il85w6CgoOvGk/kG6wq/D83T3Lbkg27mc5HxyiFqIQIuyk E/r+3DRV2/KZDbI/qo3DHKc+/u6/497GlZ8FHty9GXTOc0eAag5H/ST13QLsnL0/dx2SOXTz /6w5up0cNxuiLbQ3cIdcCswSPTLjoxJLcUaioRZzUXEiALORs+LNAgAA X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Jul 2012 02:35:12 -0000 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. --- notmuch-show.c | 31 +++++-------------------------- 1 file changed, 5 insertions(+), 26 deletions(-) diff --git a/notmuch-show.c b/notmuch-show.c index fa1e6e9..5ee2156 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; } -- 1.7.10