From c5f1db34f3b074388fb76bcc97aa93704c2289a1 Mon Sep 17 00:00:00 2001 From: Jani Nikula Date: Mon, 5 Oct 2015 21:25:29 +0300 Subject: [PATCH] Re: [Patch v4 4/9] cli: update to use new count API --- af/80bde81e4504a83d9d8d1f3dc98e1d4e45bc3b | 198 ++++++++++++++++++++++ 1 file changed, 198 insertions(+) create mode 100644 af/80bde81e4504a83d9d8d1f3dc98e1d4e45bc3b diff --git a/af/80bde81e4504a83d9d8d1f3dc98e1d4e45bc3b b/af/80bde81e4504a83d9d8d1f3dc98e1d4e45bc3b new file mode 100644 index 000000000..47abe755f --- /dev/null +++ b/af/80bde81e4504a83d9d8d1f3dc98e1d4e45bc3b @@ -0,0 +1,198 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by arlo.cworth.org (Postfix) with ESMTP id 4D48E6DE1435 + for ; Mon, 5 Oct 2015 11:26:00 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at cworth.org +X-Spam-Flag: NO +X-Spam-Score: -0.159 +X-Spam-Level: +X-Spam-Status: No, score=-0.159 tagged_above=-999 required=5 + tests=[AWL=-0.183, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, + RCVD_IN_MSPIKE_WL=-0.01, URIBL_SBL=0.644, URIBL_SBL_A=0.1] + autolearn=disabled +Received: from arlo.cworth.org ([127.0.0.1]) + by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id G5bGjc4XXoRD for ; + Mon, 5 Oct 2015 11:25:58 -0700 (PDT) +Received: from mail-wi0-f173.google.com (mail-wi0-f173.google.com + [209.85.212.173]) + by arlo.cworth.org (Postfix) with ESMTPS id CF5546DE02D6 + for ; Mon, 5 Oct 2015 11:25:57 -0700 (PDT) +Received: by wicfx3 with SMTP id fx3so126874370wic.0 + for ; Mon, 05 Oct 2015 11:25:56 -0700 (PDT) +X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; + d=1e100.net; s=20130820; + h=x-gm-message-state:from:to:subject:in-reply-to:references + :user-agent:date:message-id:mime-version:content-type; + bh=sSbqIVc97hhuE0tZ1gNwZqnJb73F2sb18lkuzugx2+I=; + b=akx4w0czGWQu7fQ8fVSGitxUklY/nGt/yw5/ZKtpNVaxIaRqFkpYqZ4WdSDpb/Q8dc + mDV8KxtAhW32Eomw1ClNZRfxVmk5DDB4Qg0LU3wo2xPFhbB1PxOuAAvVcWiCkSY48QlX + ky1DmLW90flMqE43ZBdhKnt3+B3rR4hgCQ1BjnK/pdOGSZn9q9Rpo42tqC9OKaoxu1jW + u4dRIZ/Msa2sV/jxEn3Pl3946jTr+tPXo8x/YpH7LeIBFNcny10ZuleBQxted4xixM0M + /iS6XBZrs8MlWYK1tzJhir/pMRDafyP0blatTO5ZoTzDm+pgY26+JAHLjKjbfJwVJ1JL + ju5w== +X-Gm-Message-State: + ALoCoQl7KBseaUCcvVEPHyRVDu7m2nZW/fHYI9WWxbVLLyB3QMYQHEalCV+tlfxJthdtXN2jmlxZ +X-Received: by 10.194.117.164 with SMTP id kf4mr31923880wjb.9.1444069556218; + Mon, 05 Oct 2015 11:25:56 -0700 (PDT) +Received: from localhost (mobile-access-bcee9f-54.dhcp.inet.fi. + [188.238.159.54]) + by smtp.gmail.com with ESMTPSA id cc8sm14758342wjc.46.2015.10.05.11.25.55 + (version=TLSv1/SSLv3 cipher=OTHER); + Mon, 05 Oct 2015 11:25:55 -0700 (PDT) +From: Jani Nikula +To: David Bremner , notmuch@notmuchmail.org +Subject: Re: [Patch v4 4/9] cli: update to use new count API +In-Reply-To: <1443367923-11867-5-git-send-email-david@tethera.net> +References: <1443367923-11867-1-git-send-email-david@tethera.net> + <1443367923-11867-5-git-send-email-david@tethera.net> +User-Agent: Notmuch/0.20.2+101~g7b7dadb (http://notmuchmail.org) Emacs/24.4.1 + (x86_64-pc-linux-gnu) +Date: Mon, 05 Oct 2015 21:25:29 +0300 +Message-ID: <87egh9895y.fsf@nikula.org> +MIME-Version: 1.0 +Content-Type: text/plain +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.18 +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: Mon, 05 Oct 2015 18:26:00 -0000 + +On Sun, 27 Sep 2015, David Bremner wrote: +> Essentially replace each call to notmuch_count_* with the corresponding +> _st call, followed by print_status_query. + +LGTM. + +> --- +> notmuch-count.c | 12 ++++++++++-- +> notmuch-reply.c | 7 ++++++- +> notmuch-search.c | 16 ++++++++++++++-- +> notmuch-show.c | 7 ++++++- +> 4 files changed, 36 insertions(+), 6 deletions(-) +> +> diff --git a/notmuch-count.c b/notmuch-count.c +> index be3e236..0b6e6f5 100644 +> --- a/notmuch-count.c +> +++ b/notmuch-count.c +> @@ -75,9 +75,11 @@ print_count (notmuch_database_t *notmuch, const char *query_str, +> notmuch_query_t *query; +> size_t i; +> int count; +> + unsigned int ucount; +> unsigned long revision; +> const char *uuid; +> int ret = 0; +> + notmuch_status_t status; +> +> query = notmuch_query_create (notmuch, query_str); +> if (query == NULL) { +> @@ -90,10 +92,16 @@ print_count (notmuch_database_t *notmuch, const char *query_str, +> +> switch (output) { +> case OUTPUT_MESSAGES: +> - printf ("%u", notmuch_query_count_messages (query)); +> + status = notmuch_query_count_messages_st (query, &ucount); +> + if (print_status_query ("notmuch count", query, status)) +> + return -1; +> + printf ("%u", ucount); +> break; +> case OUTPUT_THREADS: +> - printf ("%u", notmuch_query_count_threads (query)); +> + status = notmuch_query_count_threads_st (query, &ucount); +> + if (print_status_query ("notmuch count", query, status)) +> + return -1; +> + printf ("%u", ucount); +> break; +> case OUTPUT_FILES: +> count = count_files (query); +> diff --git a/notmuch-reply.c b/notmuch-reply.c +> index fd6a1ec..1357142 100644 +> --- a/notmuch-reply.c +> +++ b/notmuch-reply.c +> @@ -655,9 +655,14 @@ notmuch_reply_format_sprinter(void *ctx, +> notmuch_messages_t *messages; +> notmuch_message_t *message; +> mime_node_t *node; +> + unsigned count; +> notmuch_status_t status; +> +> - if (notmuch_query_count_messages (query) != 1) { +> + status = notmuch_query_count_messages_st (query, &count); +> + if (print_status_query ("notmuch reply", query, status)) +> + return 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 44e582c..6d08c25 100644 +> --- a/notmuch-search.c +> +++ b/notmuch-search.c +> @@ -121,7 +121,13 @@ 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 (print_status_query ("notmuch search", ctx->query, status)) +> + return 1; +> + +> + ctx->offset += count; +> if (ctx->offset < 0) +> ctx->offset = 0; +> } +> @@ -521,7 +527,13 @@ 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 (print_status_query ("notmuch search", ctx->query, status)) +> + return 1; +> + +> + ctx->offset += count; +> if (ctx->offset < 0) +> ctx->offset = 0; +> } +> diff --git a/notmuch-show.c b/notmuch-show.c +> index e054808..5a83c60 100644 +> --- a/notmuch-show.c +> +++ b/notmuch-show.c +> @@ -896,8 +896,13 @@ do_show_single (void *ctx, +> notmuch_messages_t *messages; +> notmuch_message_t *message; +> notmuch_status_t status; +> + unsigned int count; +> +> - if (notmuch_query_count_messages (query) != 1) { +> + status = notmuch_query_count_messages_st (query, &count); +> + if (print_status_query ("notmuch show", query, status)) +> + return 1; +> + +> + if (count != 1) { +> fprintf (stderr, "Error: search term did not match precisely one message.\n"); +> return 1; +> } +> -- +> 2.5.3 +> +> _______________________________________________ +> notmuch mailing list +> notmuch@notmuchmail.org +> http://notmuchmail.org/mailman/listinfo/notmuch -- 2.26.2