From: David Bremner Date: Sun, 27 Sep 2015 15:31:59 +0000 (+2100) Subject: [Patch v4 5/9] ruby: use new count API X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=d0cd4ac09d4a991ca6814797e37e3278ab885c1f;p=notmuch-archives.git [Patch v4 5/9] ruby: use new count API --- diff --git a/f6/29f3e7a3c1037ab2489faa32827b8f92b37700 b/f6/29f3e7a3c1037ab2489faa32827b8f92b37700 new file mode 100644 index 000000000..0bcd84e9d --- /dev/null +++ b/f6/29f3e7a3c1037ab2489faa32827b8f92b37700 @@ -0,0 +1,101 @@ +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 2AB006DE0924 + for ; Sun, 27 Sep 2015 08:33:33 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at cworth.org +X-Spam-Flag: NO +X-Spam-Score: 0.109 +X-Spam-Level: +X-Spam-Status: No, score=0.109 tagged_above=-999 required=5 tests=[AWL=0.109] + 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 LYFi1AiZzGXb for ; + Sun, 27 Sep 2015 08:33:31 -0700 (PDT) +Received: from gitolite.debian.net (gitolite.debian.net [87.98.215.224]) + by arlo.cworth.org (Postfix) with ESMTPS id 6C6266DE0274 + for ; Sun, 27 Sep 2015 08:33:31 -0700 (PDT) +Received: from remotemail by gitolite.debian.net with local (Exim 4.80) + (envelope-from ) + id 1ZgDwX-0008Dg-8W; Sun, 27 Sep 2015 15:32:49 +0000 +Received: (nullmailer pid 11939 invoked by uid 1000); Sun, 27 Sep 2015 + 15:32:11 -0000 +From: David Bremner +To: notmuch@notmuchmail.org +Subject: [Patch v4 5/9] ruby: use new count API +Date: Sun, 27 Sep 2015 12:31:59 -0300 +Message-Id: <1443367923-11867-6-git-send-email-david@tethera.net> +X-Mailer: git-send-email 2.5.3 +In-Reply-To: <1443367923-11867-1-git-send-email-david@tethera.net> +References: <1443367923-11867-1-git-send-email-david@tethera.net> +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: Sun, 27 Sep 2015 15:33:33 -0000 + +This change of replacing ignoring errors with exceptions is intended, +and indeed one of the main motivations for the libnotmuch API changes. +--- + bindings/ruby/query.c | 24 ++++++++++++++---------- + 1 file changed, 14 insertions(+), 10 deletions(-) + +diff --git a/bindings/ruby/query.c b/bindings/ruby/query.c +index a7dacba..f87700a 100644 +--- a/bindings/ruby/query.c ++++ b/bindings/ruby/query.c +@@ -173,14 +173,16 @@ VALUE + notmuch_rb_query_count_messages (VALUE self) + { + notmuch_query_t *query; ++ notmuch_status_t status; ++ unsigned int count; + + Data_Get_Notmuch_Query (self, query); + +- /* Xapian exceptions are not handled properly. +- * (function may return 0 after printing a message) +- * Thus there is nothing we can do here... +- */ +- return UINT2NUM(notmuch_query_count_messages(query)); ++ status = notmuch_query_count_messages_st (query, &count); ++ if (status) ++ notmuch_rb_status_raise (status); ++ ++ return UINT2NUM(count); + } + + /* +@@ -192,12 +194,14 @@ VALUE + notmuch_rb_query_count_threads (VALUE self) + { + notmuch_query_t *query; ++ notmuch_status_t status; ++ unsigned int count; + + Data_Get_Notmuch_Query (self, query); + +- /* Xapian exceptions are not handled properly. +- * (function may return 0 after printing a message) +- * Thus there is nothing we can do here... +- */ +- return UINT2NUM(notmuch_query_count_threads(query)); ++ status = notmuch_query_count_threads_st (query, &count); ++ if (status) ++ notmuch_rb_status_raise (status); ++ ++ return UINT2NUM(count); + } +-- +2.5.3 +