From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 7705E429E30 for ; Sat, 28 May 2011 14:52:24 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -1.921 X-Spam-Level: X-Spam-Status: No, score=-1.921 tagged_above=-999 required=5 tests=[NO_DNS_FOR_FROM=0.379, RCVD_IN_DNSWL_MED=-2.3] 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 oHP4-bdxzcLG for ; Sat, 28 May 2011 14:52:23 -0700 (PDT) Received: from outgoing-mail.its.caltech.edu (outgoing-mail.its.caltech.edu [131.215.239.19]) by olra.theworths.org (Postfix) with ESMTP id 12104429E35 for ; Sat, 28 May 2011 14:52:15 -0700 (PDT) Received: from fire-doxen.imss.caltech.edu (localhost [127.0.0.1]) by fire-doxen-postvirus (Postfix) with ESMTP id 62B182E50EF0; Sat, 28 May 2011 14:45:47 -0700 (PDT) X-Spam-Scanned: at Caltech-IMSS on fire-doxen by amavisd-new Received: from servo.finestructure.net (cpe-98-149-172-122.socal.res.rr.com [98.149.172.122]) (Authenticated sender: jrollins) by fire-doxen-submit (Postfix) with ESMTP id BD582328121; Sat, 28 May 2011 14:45:42 -0700 (PDT) Received: by servo.finestructure.net (Postfix, from userid 1000) id 2465578A; Sat, 28 May 2011 14:52:05 -0700 (PDT) From: Jameson Graef Rollins To: Notmuch Mail Subject: [PATCH 05/25] fix trailing newlines in notmuch search Date: Sat, 28 May 2011 14:51:40 -0700 Message-Id: <1306619520-25730-6-git-send-email-jrollins@finestructure.net> X-Mailer: git-send-email 1.7.4.4 In-Reply-To: <1306619520-25730-5-git-send-email-jrollins@finestructure.net> References: <1306619520-25730-1-git-send-email-jrollins@finestructure.net> <1306619520-25730-2-git-send-email-jrollins@finestructure.net> <1306619520-25730-3-git-send-email-jrollins@finestructure.net> <1306619520-25730-4-git-send-email-jrollins@finestructure.net> <1306619520-25730-5-git-send-email-jrollins@finestructure.net> 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: Sat, 28 May 2011 21:52:24 -0000 A previous commit to fix json formatting for null results (0b1ddc5f6652bde99d63d9d553777b3d926694cf) 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. --- notmuch-search.c | 18 +++++++++++++++--- 1 files changed, 15 insertions(+), 3 deletions(-) diff --git a/notmuch-search.c b/notmuch-search.c index 8b90121..69af617 100644 --- a/notmuch-search.c +++ b/notmuch-search.c @@ -48,6 +48,7 @@ typedef struct search_format { const char *item_sep; const char *item_end; const char *results_end; + const char *results_null; } search_format_t; static void @@ -72,6 +73,7 @@ static const search_format_t format_text = { "%s", " ", ")", "\n", "", + "\n", "", }; @@ -98,6 +100,7 @@ static const search_format_t format_json = { "]", ",\n", "}", "]\n", + "]\n", }; static void @@ -236,7 +239,10 @@ do_search_threads (const search_format_t *format, notmuch_thread_destroy (thread); } - fputs (format->results_end, stdout); + if (first_thread) + fputs (format->results_null, stdout); + else + fputs (format->results_end, stdout); return 0; } @@ -280,7 +286,10 @@ do_search_messages (const search_format_t *format, notmuch_messages_destroy (messages); - fputs (format->results_end, stdout); + if (first_message) + fputs (format->results_null, stdout); + else + fputs (format->results_end, stdout); return 0; } @@ -329,7 +338,10 @@ do_search_tags (notmuch_database_t *notmuch, if (messages) notmuch_messages_destroy (messages); - fputs (format->results_end, stdout); + if (first_tag) + fputs (format->results_null, stdout); + else + fputs (format->results_end, stdout); return 0; } -- 1.7.4.4