X-Git-Url: https://git.notmuchmail.org/git?a=blobdiff_plain;f=lib%2Fregexp-fields.cc;h=8e740a810064a8e80bae40ad75045b975c7c2286;hb=13a59c4a8fc4ee418424e0b7ee4c8bbd5aae5da2;hp=9873af8039919e07fd7e8c8fbdc3e36dd05b98f5;hpb=55524bb063c95ae51a1762eb0b1aacce6ca49223;p=notmuch diff --git a/lib/regexp-fields.cc b/lib/regexp-fields.cc index 9873af80..8e740a81 100644 --- a/lib/regexp-fields.cc +++ b/lib/regexp-fields.cc @@ -38,7 +38,7 @@ compile_regex (regex_t ®exp, const char *str) std::string msg; (void) regerror (err, ®exp, buffer, len); msg.assign (buffer, len); - delete buffer; + delete[] buffer; throw Xapian::QueryParserError (msg); } @@ -62,11 +62,6 @@ RegexpPostingSource::init (const Xapian::Database &db) it_ = db_.valuestream_begin (slot_); end_ = db.valuestream_end (slot_); started_ = false; - - /* make sure we start on a matching value */ - while (!at_end() && regexec (®exp_, (*it_).c_str (), 0, NULL, 0) != 0) { - ++it_; - } } Xapian::doccount @@ -113,6 +108,27 @@ RegexpPostingSource::next (unused (double min_wt)) } } +void +RegexpPostingSource::skip_to (Xapian::docid did, unused (double min_wt)) +{ + started_ = true; + it_.skip_to (did); + for (; ! at_end (); ++it_) { + std::string value = *it_; + if (regexec (®exp_, value.c_str (), 0, NULL, 0) == 0) + break; + } +} + +bool +RegexpPostingSource::check (Xapian::docid did, unused (double min_wt)) +{ + started_ = true; + if (!it_.check (did) || at_end ()) + return false; + return (regexec (®exp_, (*it_).c_str (), 0, NULL, 0) == 0); +} + static inline Xapian::valueno _find_slot (std::string prefix) { if (prefix == "from")