1 Return-Path: <bremner@tesseract.cs.unb.ca>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by olra.theworths.org (Postfix) with ESMTP id 1A935431FCF
\r
6 for <notmuch@notmuchmail.org>; Sat, 7 Mar 2015 00:44:59 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=2.438 tagged_above=-999 required=5
\r
12 tests=[DNS_FROM_AHBL_RHSBL=2.438] autolearn=disabled
\r
13 Received: from olra.theworths.org ([127.0.0.1])
\r
14 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id Wlteh8kQsmYF for <notmuch@notmuchmail.org>;
\r
16 Sat, 7 Mar 2015 00:44:58 -0800 (PST)
\r
17 Received: from mx.xen14.node3324.gplhost.com (gitolite.debian.net
\r
19 (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits))
\r
20 (No client certificate requested)
\r
21 by olra.theworths.org (Postfix) with ESMTPS id 7C58B431FBD
\r
22 for <notmuch@notmuchmail.org>; Sat, 7 Mar 2015 00:44:58 -0800 (PST)
\r
23 Received: from remotemail by mx.xen14.node3324.gplhost.com with local (Exim
\r
24 4.80) (envelope-from <bremner@tesseract.cs.unb.ca>)
\r
25 id 1YUALJ-0002K4-5y; Sat, 07 Mar 2015 08:44:17 +0000
\r
26 Received: (nullmailer pid 20410 invoked by uid 1000); Sat, 07 Mar 2015
\r
28 From: David Bremner <david@tethera.net>
\r
29 To: notmuch@notmuchmail.org
\r
30 Subject: [PATCH 2/4] cli: update to use new count API
\r
31 Date: Sat, 7 Mar 2015 09:43:15 +0100
\r
32 Message-Id: <1425717797-19990-3-git-send-email-david@tethera.net>
\r
33 X-Mailer: git-send-email 2.1.4
\r
34 In-Reply-To: <1425717797-19990-1-git-send-email-david@tethera.net>
\r
35 References: <1419971380-10307-6-git-send-email-david@tethera.net>
\r
36 <1425717797-19990-1-git-send-email-david@tethera.net>
\r
37 X-BeenThere: notmuch@notmuchmail.org
\r
38 X-Mailman-Version: 2.1.13
\r
40 List-Id: "Use and development of the notmuch mail system."
\r
41 <notmuch.notmuchmail.org>
\r
42 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
43 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
44 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
45 List-Post: <mailto:notmuch@notmuchmail.org>
\r
46 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
47 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
48 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
49 X-List-Received-Date: Sat, 07 Mar 2015 08:44:59 -0000
\r
51 Essentially replace each call to notmuch_count_* with an if block.
\r
53 notmuch-count.c | 14 ++++++++++++--
\r
54 notmuch-reply.c | 8 +++++++-
\r
55 notmuch-search.c | 14 ++++++++++++--
\r
56 notmuch-show.c | 8 +++++++-
\r
57 4 files changed, 38 insertions(+), 6 deletions(-)
\r
59 diff --git a/notmuch-count.c b/notmuch-count.c
\r
60 index 6058f7c..cd6b0c9 100644
\r
61 --- a/notmuch-count.c
\r
62 +++ b/notmuch-count.c
\r
63 @@ -71,6 +71,8 @@ print_count (notmuch_database_t *notmuch, const char *query_str,
\r
65 notmuch_query_t *query;
\r
68 + notmuch_status_t status;
\r
70 query = notmuch_query_create (notmuch, query_str);
\r
71 if (query == NULL) {
\r
72 @@ -83,10 +85,18 @@ print_count (notmuch_database_t *notmuch, const char *query_str,
\r
75 case OUTPUT_MESSAGES:
\r
76 - printf ("%u\n", notmuch_query_count_messages (query));
\r
77 + if ((status = notmuch_query_count_messages_st (query, &count))) {
\r
78 + fprintf (stderr, "Error: %s\n", notmuch_status_to_string (status));
\r
81 + printf ("%u\n", count);
\r
83 case OUTPUT_THREADS:
\r
84 - printf ("%u\n", notmuch_query_count_threads (query));
\r
85 + if ((status = notmuch_query_count_threads_st (query, &count))) {
\r
86 + fprintf (stderr, "Error: %s\n", notmuch_status_to_string (status));
\r
89 + printf ("%u\n", count);
\r
92 printf ("%u\n", count_files (query));
\r
93 diff --git a/notmuch-reply.c b/notmuch-reply.c
\r
94 index 7c1c809..0b3e5fd 100644
\r
95 --- a/notmuch-reply.c
\r
96 +++ b/notmuch-reply.c
\r
97 @@ -650,8 +650,14 @@ notmuch_reply_format_sprinter(void *ctx,
\r
98 notmuch_messages_t *messages;
\r
99 notmuch_message_t *message;
\r
102 + notmuch_status_t status;
\r
104 - if (notmuch_query_count_messages (query) != 1) {
\r
105 + if ((status = notmuch_query_count_messages_st (query, &count))) {
\r
106 + fprintf (stderr, "Error: %s.\n", notmuch_status_to_string (status));
\r
109 + if (count != 1) {
\r
110 fprintf (stderr, "Error: search term did not match precisely one message.\n");
\r
113 diff --git a/notmuch-search.c b/notmuch-search.c
\r
114 index a591d45..ba631c0 100644
\r
115 --- a/notmuch-search.c
\r
116 +++ b/notmuch-search.c
\r
117 @@ -113,7 +113,14 @@ do_search_threads (search_context_t *ctx)
\r
120 if (ctx->offset < 0) {
\r
121 - ctx->offset += notmuch_query_count_threads (ctx->query);
\r
123 + notmuch_status_t status;
\r
124 + if ((status = notmuch_query_count_threads_st (ctx->query, &count))) {
\r
125 + fprintf (stderr, "Error: %s\n", notmuch_status_to_string (status));
\r
129 + ctx->offset += count;
\r
130 if (ctx->offset < 0)
\r
133 @@ -414,7 +421,10 @@ do_search_messages (search_context_t *ctx)
\r
136 if (ctx->offset < 0) {
\r
137 - ctx->offset += notmuch_query_count_messages (ctx->query);
\r
139 + if (notmuch_query_count_messages_st (ctx->query, &count))
\r
141 + ctx->offset += count;
\r
142 if (ctx->offset < 0)
\r
145 diff --git a/notmuch-show.c b/notmuch-show.c
\r
146 index d416fbd..749b1af 100644
\r
147 --- a/notmuch-show.c
\r
148 +++ b/notmuch-show.c
\r
149 @@ -982,8 +982,14 @@ do_show_single (void *ctx,
\r
151 notmuch_messages_t *messages;
\r
152 notmuch_message_t *message;
\r
154 + notmuch_status_t status;
\r
155 + if ((status = notmuch_query_count_messages_st (query, &count))) {
\r
156 + fprintf (stderr, "Error: %s\n", notmuch_status_to_string (status));
\r
160 - if (notmuch_query_count_messages (query) != 1) {
\r
161 + if (count != 1) {
\r
162 fprintf (stderr, "Error: search term did not match precisely one message.\n");
\r