It's already kindof gross that this is hardcoded in two different places. We will also need these later in field processors calling back into the query parser. --- lib/database-private.h | 4 ++++ lib/query.cc | 16 ++-------------- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/lib/database-private.h b/lib/database-private.h index 30a045e..59708d0 100644 --- a/lib/database-private.h +++ b/lib/database-private.h @@ -144,6 +144,10 @@ operator&=(_notmuch_features &a, _notmuch_features b) return a; } +#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 | Xapian::QueryParser::FLAG_PURE_NOT) + #if HAVE_XAPIAN_FIELD_PROCESSOR class DateFieldProcessor; #endif diff --git a/lib/query.cc b/lib/query.cc index e627bfc..972a389 100644 --- a/lib/query.cc +++ b/lib/query.cc @@ -212,12 +212,6 @@ notmuch_query_search_messages_st (notmuch_query_t *query, Xapian::Query string_query, final_query, exclude_query; Xapian::MSet mset; Xapian::MSetIterator iterator; - unsigned int flags = (Xapian::QueryParser::FLAG_BOOLEAN | - Xapian::QueryParser::FLAG_PHRASE | - Xapian::QueryParser::FLAG_LOVEHATE | - Xapian::QueryParser::FLAG_BOOLEAN_ANY_CASE | - Xapian::QueryParser::FLAG_WILDCARD | - Xapian::QueryParser::FLAG_PURE_NOT); if (strcmp (query_string, "") == 0 || strcmp (query_string, "*") == 0) @@ -225,7 +219,7 @@ notmuch_query_search_messages_st (notmuch_query_t *query, final_query = mail_query; } else { string_query = notmuch->query_parser-> - parse_query (query_string, flags); + parse_query (query_string, NOTMUCH_QUERY_PARSER_FLAGS); final_query = Xapian::Query (Xapian::Query::OP_AND, mail_query, string_query); } @@ -565,12 +559,6 @@ notmuch_query_count_messages_st (notmuch_query_t *query, unsigned *count_out) "mail")); Xapian::Query string_query, final_query, exclude_query; Xapian::MSet mset; - unsigned int flags = (Xapian::QueryParser::FLAG_BOOLEAN | - Xapian::QueryParser::FLAG_PHRASE | - Xapian::QueryParser::FLAG_LOVEHATE | - Xapian::QueryParser::FLAG_BOOLEAN_ANY_CASE | - Xapian::QueryParser::FLAG_WILDCARD | - Xapian::QueryParser::FLAG_PURE_NOT); if (strcmp (query_string, "") == 0 || strcmp (query_string, "*") == 0) @@ -578,7 +566,7 @@ notmuch_query_count_messages_st (notmuch_query_t *query, unsigned *count_out) final_query = mail_query; } else { string_query = notmuch->query_parser-> - parse_query (query_string, flags); + parse_query (query_string, NOTMUCH_QUERY_PARSER_FLAGS); final_query = Xapian::Query (Xapian::Query::OP_AND, mail_query, string_query); } -- 2.7.0