From: David Bremner Date: Sun, 27 Sep 2015 02:50:13 +0000 (+2100) Subject: [Patch v3 4/4] ruby: use new count API X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=e7e66274f8ac00bf535a131be5185c293e50a30b;p=notmuch-archives.git [Patch v3 4/4] ruby: use new count API --- diff --git a/f8/f97e4d936d1bdc77e87013c7c468610e10861d b/f8/f97e4d936d1bdc77e87013c7c468610e10861d new file mode 100644 index 000000000..4e5306b86 --- /dev/null +++ b/f8/f97e4d936d1bdc77e87013c7c468610e10861d @@ -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 EF0066DE176C + for ; Sat, 26 Sep 2015 19:52:07 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at cworth.org +X-Spam-Flag: NO +X-Spam-Score: 0.112 +X-Spam-Level: +X-Spam-Status: No, score=0.112 tagged_above=-999 required=5 tests=[AWL=0.112] + 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 j9LxVyVnEY-A for ; + Sat, 26 Sep 2015 19:52:06 -0700 (PDT) +Received: from gitolite.debian.net (gitolite.debian.net [87.98.215.224]) + by arlo.cworth.org (Postfix) with ESMTPS id 3BA966DE141E + for ; Sat, 26 Sep 2015 19:52:06 -0700 (PDT) +Received: from remotemail by gitolite.debian.net with local (Exim 4.80) + (envelope-from ) + id 1Zg23f-0005bX-SW; Sun, 27 Sep 2015 02:51:23 +0000 +Received: (nullmailer pid 31139 invoked by uid 1000); Sun, 27 Sep 2015 + 02:50:26 -0000 +From: David Bremner +To: notmuch@notmuchmail.org +Subject: [Patch v3 4/4] ruby: use new count API +Date: Sat, 26 Sep 2015 23:50:13 -0300 +Message-Id: <1443322213-31075-5-git-send-email-david@tethera.net> +X-Mailer: git-send-email 2.5.3 +In-Reply-To: <1443322213-31075-1-git-send-email-david@tethera.net> +References: <1443322213-31075-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 02:52:08 -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 +