From: Austin Clements Date: Fri, 3 Aug 2012 01:14:57 +0000 (+2000) Subject: [PATCH v3 11/13] show: Convert show_message to use sprinter X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=85749c27bcacf18f0731553eceeb8a4906e8741b;p=notmuch-archives.git [PATCH v3 11/13] show: Convert show_message to use sprinter --- diff --git a/b0/9058710c8f5a9cc746d58af61b04c751fe7dbb b/b0/9058710c8f5a9cc746d58af61b04c751fe7dbb new file mode 100644 index 000000000..aaf4166e8 --- /dev/null +++ b/b0/9058710c8f5a9cc746d58af61b04c751fe7dbb @@ -0,0 +1,162 @@ +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 C2C41431E64 + for ; Thu, 2 Aug 2012 18:15:39 -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 RNQy8KKnnp0Z for ; + Thu, 2 Aug 2012 18:15:38 -0700 (PDT) +Received: from dmz-mailsec-scanner-1.mit.edu (DMZ-MAILSEC-SCANNER-1.MIT.EDU + [18.9.25.12]) + by olra.theworths.org (Postfix) with ESMTP id 26EF9429E48 + for ; Thu, 2 Aug 2012 18:15:12 -0700 (PDT) +X-AuditID: 1209190c-b7f806d000006b87-21-501b261f92e1 +Received: from mailhub-auth-1.mit.edu ( [18.9.21.35]) + by dmz-mailsec-scanner-1.mit.edu (Symantec Messaging Gateway) with SMTP + id DC.2B.27527.F162B105; Thu, 2 Aug 2012 21:15:11 -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 q731FBmV012774; + Thu, 2 Aug 2012 21:15:11 -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 q731F4ld002794 + (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); + Thu, 2 Aug 2012 21:15:05 -0400 (EDT) +Received: from amthrax by drake.dyndns.org with local (Exim 4.77) + (envelope-from ) + id 1Sx6To-0003wa-Gv; Thu, 02 Aug 2012 21:15:04 -0400 +From: Austin Clements +To: notmuch@notmuchmail.org +Subject: [PATCH v3 11/13] show: Convert show_message to use sprinter +Date: Thu, 2 Aug 2012 21:14:57 -0400 +Message-Id: <1343956499-14543-12-git-send-email-amdragon@mit.edu> +X-Mailer: git-send-email 1.7.10 +In-Reply-To: <1343956499-14543-1-git-send-email-amdragon@mit.edu> +References: <1343956499-14543-1-git-send-email-amdragon@mit.edu> +X-Brightmail-Tracker: + H4sIAAAAAAAAA+NgFjrGIsWRmVeSWpSXmKPExsUixCmqrCuvJh1gsL3D3GL1XB6L6zdnMlu8 + WTmP1YHZY+esu+weh78uZPF4tuoWcwBzFJdNSmpOZllqkb5dAlfGg3uXmQq6RCqOrbnF1sD4 + lL+LkZNDQsBE4vOnL2wQtpjEhXvrwWwhgX2MEhdveXYxcgHZ6xklrixYwALhPGSSmPPiKxOE + M5dR4vuG04wgLWwCGhLb9i8Hs0UEpCV23p3NCmIzC8RJbJnyHywuLOAi8XHVarA4i4CqxM3P + m8HivAKOEld//GCFOENe4un9PrAzOIHir9++YoQ4yUFieVs36wRG/gWMDKsYZVNyq3RzEzNz + ilOTdYuTE/PyUot0DfVyM0v0UlNKNzGCg0uSZwfjm4NKhxgFOBiVeHhviUkHCLEmlhVX5h5i + lORgUhLlZVYCCvEl5adUZiQWZ8QXleakFh9ilOBgVhLhrVoiFSDEm5JYWZValA+TkuZgURLn + vZxy019IID2xJDU7NbUgtQgmK8PBoSTBO18FaKhgUWp6akVaZk4JQpqJgxNkOA/Q8GMgNbzF + BYm5xZnpEPlTjIpS4ryLQC4SAElklObB9cKi/xWjONArwrxTQdp5gIkDrvsV0GAmoMF2ZiBX + F5ckIqSkGhhlL8aor1m4p3HyxzkLLix88fJrwJSqDawCZwrPTV29/H/l5LDPAp/sdOIOpcWf + alv0u7vCMDl73y8ej2XPBMNU8v6FfN12YceZRbe6nog6Hd75+4mrXnGQ8NuPay9UPmKzrzT/ + 4apd+d063vkik+1k8z1Ltk5/t2dejnxORJeA8pTDlpsM8yx9lFiKMxINtZiLihMBYsFgotkC AAA= +Cc: tomi.ollila@iki.fi +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: Fri, 03 Aug 2012 01:15:40 -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 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; + } +-- +1.7.10 +