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 C0F9C431FC7
\r
6 for <notmuch@notmuchmail.org>; Sat, 7 Mar 2015 11:25:03 -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 oD1XawhP3BP6 for <notmuch@notmuchmail.org>;
\r
16 Sat, 7 Mar 2015 11:25:02 -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 C991E431FBD
\r
22 for <notmuch@notmuchmail.org>; Sat, 7 Mar 2015 11:25:01 -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 1YUKKi-0004Dj-7c; Sat, 07 Mar 2015 19:24:20 +0000
\r
26 Received: (nullmailer pid 28729 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 5/5] cli: update to use new count API
\r
31 Date: Sat, 7 Mar 2015 20:23:02 +0100
\r
32 Message-Id: <1425756182-28468-6-git-send-email-david@tethera.net>
\r
33 X-Mailer: git-send-email 2.1.4
\r
34 In-Reply-To: <1425756182-28468-1-git-send-email-david@tethera.net>
\r
35 References: <1425756182-28468-1-git-send-email-david@tethera.net>
\r
36 X-BeenThere: notmuch@notmuchmail.org
\r
37 X-Mailman-Version: 2.1.13
\r
39 List-Id: "Use and development of the notmuch mail system."
\r
40 <notmuch.notmuchmail.org>
\r
41 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
42 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
43 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
44 List-Post: <mailto:notmuch@notmuchmail.org>
\r
45 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
46 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
47 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
48 X-List-Received-Date: Sat, 07 Mar 2015 19:25:03 -0000
\r
50 Essentially replace each call to notmuch_count_* with an if block.
\r
52 notmuch-count.c | 16 ++++++++++++++--
\r
53 notmuch-reply.c | 11 ++++++++++-
\r
54 notmuch-search.c | 17 +++++++++++++++--
\r
55 notmuch-show.c | 11 ++++++++++-
\r
56 4 files changed, 49 insertions(+), 6 deletions(-)
\r
58 diff --git a/notmuch-count.c b/notmuch-count.c
\r
59 index d555bf1..b475495 100644
\r
60 --- a/notmuch-count.c
\r
61 +++ b/notmuch-count.c
\r
62 @@ -72,6 +72,8 @@ print_count (notmuch_database_t *notmuch, const char *query_str,
\r
64 notmuch_query_t *query;
\r
67 + notmuch_status_t status;
\r
69 query = notmuch_query_create (notmuch, query_str);
\r
70 if (query == NULL) {
\r
71 @@ -84,10 +86,20 @@ print_count (notmuch_database_t *notmuch, const char *query_str,
\r
74 case OUTPUT_MESSAGES:
\r
75 - printf ("%u\n", notmuch_query_count_messages (query));
\r
76 + 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 + status = notmuch_query_count_threads_st (query, &count);
\r
87 + fprintf (stderr, "Error: %s\n", notmuch_status_to_string (status));
\r
90 + printf ("%u\n", count);
\r
93 printf ("%u\n", count_files (query));
\r
94 diff --git a/notmuch-reply.c b/notmuch-reply.c
\r
95 index dca4e42..88998c3 100644
\r
96 --- a/notmuch-reply.c
\r
97 +++ b/notmuch-reply.c
\r
98 @@ -657,8 +657,17 @@ notmuch_reply_format_sprinter(void *ctx,
\r
99 notmuch_messages_t *messages;
\r
100 notmuch_message_t *message;
\r
103 + notmuch_status_t status;
\r
105 + status = notmuch_query_count_messages_st (query, &count);
\r
108 + fprintf (stderr, "Error: %s.\n", notmuch_status_to_string (status));
\r
112 - if (notmuch_query_count_messages (query) != 1) {
\r
113 + if (count != 1) {
\r
114 fprintf (stderr, "Error: search term did not match precisely one message.\n");
\r
117 diff --git a/notmuch-search.c b/notmuch-search.c
\r
118 index 20feda4..d8020f2 100644
\r
119 --- a/notmuch-search.c
\r
120 +++ b/notmuch-search.c
\r
121 @@ -114,7 +114,15 @@ do_search_threads (search_context_t *ctx)
\r
122 notmuch_status_t status;
\r
124 if (ctx->offset < 0) {
\r
125 - ctx->offset += notmuch_query_count_threads (ctx->query);
\r
127 + notmuch_status_t status;
\r
128 + status = notmuch_query_count_threads_st (ctx->query, &count);
\r
130 + fprintf (stderr, "Error: %s\n", notmuch_status_to_string (status));
\r
134 + ctx->offset += count;
\r
135 if (ctx->offset < 0)
\r
138 @@ -418,7 +426,12 @@ do_search_messages (search_context_t *ctx)
\r
139 notmuch_status_t status;
\r
141 if (ctx->offset < 0) {
\r
142 - ctx->offset += notmuch_query_count_messages (ctx->query);
\r
144 + notmuch_status_t status;
\r
145 + status = notmuch_query_count_messages_st (ctx->query, &count);
\r
148 + ctx->offset += count;
\r
149 if (ctx->offset < 0)
\r
152 diff --git a/notmuch-show.c b/notmuch-show.c
\r
153 index af8741d..834ed89 100644
\r
154 --- a/notmuch-show.c
\r
155 +++ b/notmuch-show.c
\r
156 @@ -982,8 +982,17 @@ do_show_single (void *ctx,
\r
158 notmuch_messages_t *messages;
\r
159 notmuch_message_t *message;
\r
161 + notmuch_status_t status;
\r
163 + status = notmuch_query_count_messages_st (query, &count);
\r
166 + fprintf (stderr, "Error: %s\n", notmuch_status_to_string (status));
\r
170 - if (notmuch_query_count_messages (query) != 1) {
\r
171 + if (count != 1) {
\r
172 fprintf (stderr, "Error: search term did not match precisely one message.\n");
\r