v2 regexp search for mid/folder/path

David Bremner david at tethera.net
Wed Mar 29 17:46:02 PDT 2017


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) {



More information about the notmuch mailing list