As can be seen from the included tests, this currently only works for
fields without other field processors (in particular regex supporting
fields seem to break it).
---
lib/database-private.h | 8 ++++++-
test/T870-extended-wildcard.sh | 40 ++++++++++++++++++++++++++++++++++
2 files changed, 47 insertions(+), 1 deletion(-)
create mode 100755 test/T870-extended-wildcard.sh
diff --git a/lib/database-private.h b/lib/database-private.h
index 2959b3ac..776ebc48 100644
--- a/lib/database-private.h
+++ b/lib/database-private.h
@@ -185,11 +185,17 @@ operator& (notmuch_field_flag_t a, notmuch_field_flag_t b)
static_cast<unsigned>(a) & static_cast<unsigned>(b));
}
+#ifdef HAVE_XAPIAN_WILDCARD_GLOB
+#define NOTMUCH_XAPIAN_WILDCARD_FLAG Xapian::QueryParser::FLAG_WILDCARD_GLOB
+#else
+#define NOTMUCH_XAPIAN_WILDCARD_FLAG Xapian::QueryParser::FLAG_WILDCARD
+#endif
+
#define NOTMUCH_QUERY_PARSER_FLAGS (Xapian::QueryParser::FLAG_BOOLEAN | \
Xapian::QueryParser::FLAG_PHRASE | \
Xapian::QueryParser::FLAG_LOVEHATE | \
Xapian::QueryParser::FLAG_BOOLEAN_ANY_CASE
| \
- Xapian::QueryParser::FLAG_WILDCARD | \
+ NOTMUCH_XAPIAN_WILDCARD_FLAG | \
Xapian::QueryParser::FLAG_PURE_NOT)
/*
diff --git a/test/T870-extended-wildcard.sh b/test/T870-extended-wildcard.sh
new file mode 100755
index 00000000..16621ecf
--- /dev/null
+++ b/test/T870-extended-wildcard.sh
@@ -0,0 +1,40 @@
+#!/usr/bin/env bash
+test_description='extended wildcard support in Xapian query parser'
+. $(dirname "$0")/test-lib.sh || exit 1
+
+if [ "${NOTMUCH_HAVE_XAPIAN_WILDCARD_GLOB-0}" != "1" ]; then
+ printf "Skipping due to missing extended wildcard support\n"
+ test_done
+fi
+
+add_email_corpus
+
+count=0
+for field in "any" 'body' 'from' 'subject' 'to' ; do
+ for glob in 'm?tch' '?a?ch' 'm?tc?' '*atch' 'mat*' '*at*'; do
+ test_begin_subtest "field $field, glob $glob"
+ case $field in
+ from|subject)
+ test_subtest_known_broken
+ ;;
+ esac
+ count=$((count + 1))
+ cookie="match$count"
+ reversecookie="${count}match"
+ queryglob="$glob$count"
+ if [ $field == 'any' ]; then
+ msgfield='body'
+ queryprefix=''
+ else
+ msgfield=$field
+ queryprefix="$field:"
+ fi
+ reversequeryglob="$count$glob"
+ add_message "[$msgfield]=$cookie"
+ add_message "[$msgfield]=$reversecookie"
+ output=$(notmuch count "$queryprefix$queryglob")
+ output="$output $(notmuch count "$queryprefix$reversequeryglob")"
+ test_expect_equal "$output" "1 1"
+ done
+done
+test_done
--
2.51.0
_______________________________________________
notmuch mailing list -- [email protected]
To unsubscribe send an email to [email protected]