From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id 4F36E6DE1346 for ; Wed, 29 Mar 2017 17:46:11 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: -0.005 X-Spam-Level: X-Spam-Status: No, score=-0.005 tagged_above=-999 required=5 tests=[AWL=0.006, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01] 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 iaSW5W-4H2gp for ; Wed, 29 Mar 2017 17:46:10 -0700 (PDT) Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) by arlo.cworth.org (Postfix) with ESMTPS id 3D3366DE12C3 for ; Wed, 29 Mar 2017 17:46:10 -0700 (PDT) Received: from remotemail by fethera.tethera.net with local (Exim 4.84_2) (envelope-from ) id 1ctODN-0004Wo-9n; Wed, 29 Mar 2017 20:45:25 -0400 Received: (nullmailer pid 1578 invoked by uid 1000); Thu, 30 Mar 2017 00:46:08 -0000 From: David Bremner To: David Bremner , notmuch@notmuchmail.org Subject: v2 regexp search for mid/folder/path Date: Wed, 29 Mar 2017 21:46:02 -0300 Message-Id: <20170330004604.1504-1-david@tethera.net> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170324121436.28978-1-david@tethera.net> References: <20170324121436.28978-1-david@tethera.net> X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.22 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: Thu, 30 Mar 2017 00:46:11 -0000 This is mainly a rebase against current master, but also required an update to the (just pushed) empty query string handling Apparently there's at least 4 ways to test a C++ string for being empty, so here I try a different way of writing it. Interdiff follows: diff --git a/lib/regexp-fields.cc b/lib/regexp-fields.cc index 26b22fe2..1598c17f 100644 --- a/lib/regexp-fields.cc +++ b/lib/regexp-fields.cc @@ -156,12 +156,17 @@ RegexpFieldProcessor::RegexpFieldProcessor (std::string prefix, Xapian::Query RegexpFieldProcessor::operator() (const std::string & str) { - if (str.size () == 0) - return Xapian::Query(Xapian::Query::OP_AND_NOT, + if (str.empty ()) { + if (options & NOTMUCH_FIELD_PROBABILISTIC) { + return Xapian::Query(Xapian::Query::OP_AND_NOT, Xapian::Query::MatchAll, Xapian::Query (Xapian::Query::OP_WILDCARD, term_prefix)); + } else { + return Xapian::Query (term_prefix); + } + } - if (str.length() > 0 && str.at (0) == '/') { + if (str.at (0) == '/') { if (str.length() > 1 && str.at (str.size () - 1) == '/'){ std::string regexp_str = str.substr(1,str.size () - 2); if (slot != Xapian::BAD_VALUENO) {