[PATCH 5/5] cli: update to use new count API
authorDavid Bremner <david@tethera.net>
Sat, 7 Mar 2015 19:23:02 +0000 (20:23 +0100)
committerW. Trevor King <wking@tremily.us>
Sat, 20 Aug 2016 21:48:22 +0000 (14:48 -0700)
93/590f02a59f52994b82c23d3039c8bd94c3e389 [new file with mode: 0644]

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