From: David Bremner Date: Sat, 7 Mar 2015 19:23:02 +0000 (+0100) Subject: [PATCH 5/5] cli: update to use new count API X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=afaf31c7b6816526ba2ff3d0f401d73e09a92c00;p=notmuch-archives.git [PATCH 5/5] cli: update to use new count API --- diff --git a/93/590f02a59f52994b82c23d3039c8bd94c3e389 b/93/590f02a59f52994b82c23d3039c8bd94c3e389 new file mode 100644 index 000000000..6f0728cdc --- /dev/null +++ b/93/590f02a59f52994b82c23d3039c8bd94c3e389 @@ -0,0 +1,177 @@ +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 C0F9C431FC7 + for ; Sat, 7 Mar 2015 11:25:03 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: 2.438 +X-Spam-Level: ** +X-Spam-Status: No, score=2.438 tagged_above=-999 required=5 + tests=[DNS_FROM_AHBL_RHSBL=2.438] 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 oD1XawhP3BP6 for ; + Sat, 7 Mar 2015 11:25:02 -0800 (PST) +Received: from mx.xen14.node3324.gplhost.com (gitolite.debian.net + [87.98.215.224]) + (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id C991E431FBD + for ; Sat, 7 Mar 2015 11:25:01 -0800 (PST) +Received: from remotemail by mx.xen14.node3324.gplhost.com with local (Exim + 4.80) (envelope-from ) + id 1YUKKi-0004Dj-7c; Sat, 07 Mar 2015 19:24:20 +0000 +Received: (nullmailer pid 28729 invoked by uid 1000); Sat, 07 Mar 2015 + 19:23:13 -0000 +From: David Bremner +To: notmuch@notmuchmail.org +Subject: [PATCH 5/5] cli: update to use new count API +Date: Sat, 7 Mar 2015 20:23:02 +0100 +Message-Id: <1425756182-28468-6-git-send-email-david@tethera.net> +X-Mailer: git-send-email 2.1.4 +In-Reply-To: <1425756182-28468-1-git-send-email-david@tethera.net> +References: <1425756182-28468-1-git-send-email-david@tethera.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, 07 Mar 2015 19:25:03 -0000 + +Essentially replace each call to notmuch_count_* with an if block. +--- + notmuch-count.c | 16 ++++++++++++++-- + notmuch-reply.c | 11 ++++++++++- + notmuch-search.c | 17 +++++++++++++++-- + notmuch-show.c | 11 ++++++++++- + 4 files changed, 49 insertions(+), 6 deletions(-) + +diff --git a/notmuch-count.c b/notmuch-count.c +index d555bf1..b475495 100644 +--- a/notmuch-count.c ++++ b/notmuch-count.c +@@ -72,6 +72,8 @@ print_count (notmuch_database_t *notmuch, const char *query_str, + { + notmuch_query_t *query; + size_t i; ++ unsigned count; ++ notmuch_status_t status; + + query = notmuch_query_create (notmuch, query_str); + if (query == NULL) { +@@ -84,10 +86,20 @@ print_count (notmuch_database_t *notmuch, const char *query_str, + + switch (output) { + case OUTPUT_MESSAGES: +- printf ("%u\n", notmuch_query_count_messages (query)); ++ status = notmuch_query_count_messages_st (query, &count); ++ if (status) { ++ fprintf (stderr, "Error: %s\n", notmuch_status_to_string (status)); ++ return 1; ++ } ++ printf ("%u\n", count); + break; + case OUTPUT_THREADS: +- printf ("%u\n", notmuch_query_count_threads (query)); ++ status = notmuch_query_count_threads_st (query, &count); ++ if (status) { ++ fprintf (stderr, "Error: %s\n", notmuch_status_to_string (status)); ++ return 1; ++ } ++ printf ("%u\n", count); + break; + case OUTPUT_FILES: + printf ("%u\n", count_files (query)); +diff --git a/notmuch-reply.c b/notmuch-reply.c +index dca4e42..88998c3 100644 +--- a/notmuch-reply.c ++++ b/notmuch-reply.c +@@ -657,8 +657,17 @@ notmuch_reply_format_sprinter(void *ctx, + notmuch_messages_t *messages; + notmuch_message_t *message; + mime_node_t *node; ++ unsigned count; ++ notmuch_status_t status; ++ ++ status = notmuch_query_count_messages_st (query, &count); ++ ++ if (status) { ++ fprintf (stderr, "Error: %s.\n", notmuch_status_to_string (status)); ++ return 1; ++ } + +- if (notmuch_query_count_messages (query) != 1) { ++ if (count != 1) { + fprintf (stderr, "Error: search term did not match precisely one message.\n"); + return 1; + } +diff --git a/notmuch-search.c b/notmuch-search.c +index 20feda4..d8020f2 100644 +--- a/notmuch-search.c ++++ b/notmuch-search.c +@@ -114,7 +114,15 @@ do_search_threads (search_context_t *ctx) + notmuch_status_t status; + + if (ctx->offset < 0) { +- ctx->offset += notmuch_query_count_threads (ctx->query); ++ unsigned count; ++ notmuch_status_t status; ++ status = notmuch_query_count_threads_st (ctx->query, &count); ++ if (status) { ++ fprintf (stderr, "Error: %s\n", notmuch_status_to_string (status)); ++ return 1; ++ } ++ ++ ctx->offset += count; + if (ctx->offset < 0) + ctx->offset = 0; + } +@@ -418,7 +426,12 @@ do_search_messages (search_context_t *ctx) + notmuch_status_t status; + + if (ctx->offset < 0) { +- ctx->offset += notmuch_query_count_messages (ctx->query); ++ unsigned count; ++ notmuch_status_t status; ++ status = notmuch_query_count_messages_st (ctx->query, &count); ++ if (status) ++ return 1; ++ ctx->offset += count; + if (ctx->offset < 0) + ctx->offset = 0; + } +diff --git a/notmuch-show.c b/notmuch-show.c +index af8741d..834ed89 100644 +--- a/notmuch-show.c ++++ b/notmuch-show.c +@@ -982,8 +982,17 @@ do_show_single (void *ctx, + { + notmuch_messages_t *messages; + notmuch_message_t *message; ++ unsigned count; ++ notmuch_status_t status; ++ ++ status = notmuch_query_count_messages_st (query, &count); ++ ++ if (status) { ++ fprintf (stderr, "Error: %s\n", notmuch_status_to_string (status)); ++ return 1; ++ } + +- if (notmuch_query_count_messages (query) != 1) { ++ if (count != 1) { + fprintf (stderr, "Error: search term did not match precisely one message.\n"); + return 1; + } +-- +2.1.4 +