X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=lib%2Fparse-sexp.cc;h=9cadbc1359d3fcb2d3813bab7eae5d0a91d6f096;hb=93c602a82fdbd03e0104ea922d073b2b1aa6b241;hp=e9ef4268e5f4d2c951d58b0f3ea3064ed76db2af;hpb=606d9b02e46498874f6c3b5af18467c870e8658b;p=notmuch-old diff --git a/lib/parse-sexp.cc b/lib/parse-sexp.cc index e9ef4268..9cadbc13 100644 --- a/lib/parse-sexp.cc +++ b/lib/parse-sexp.cc @@ -563,38 +563,13 @@ _sexp_parse_range (notmuch_database_t *notmuch, const _sexp_prefix_t *prefix, } if (strcmp (prefix->name, "lastmod") == 0) { - long from_idx, to_idx; - - try { - if (EMPTY_STRING (from)) - from_idx = 0L; - else - from_idx = std::stol (from); - } catch (std::logic_error &e) { - _notmuch_database_log (notmuch, "bad 'from' revision: '%s'\n", from); - return NOTMUCH_STATUS_BAD_QUERY_SYNTAX; - } - - if (from_idx < 0) - from_idx += notmuch_database_get_revision (notmuch, NULL); - - try { - if (EMPTY_STRING (to)) - to_idx = LONG_MAX; - else - to_idx = std::stol (to); - } catch (std::logic_error &e) { - _notmuch_database_log (notmuch, "bad 'to' revision: '%s'\n", to); - return NOTMUCH_STATUS_BAD_QUERY_SYNTAX; + notmuch_status_t status; + status = _notmuch_lastmod_strings_to_query (notmuch, from, to, output, msg); + if (status) { + if (! msg.empty ()) + _notmuch_database_log (notmuch, "%s\n", msg.c_str ()); } - - if (to_idx < 0) - to_idx += notmuch_database_get_revision (notmuch, NULL); - - output = Xapian::Query (Xapian::Query::OP_VALUE_RANGE, NOTMUCH_VALUE_LAST_MOD, - Xapian::sortable_serialise (from_idx), - Xapian::sortable_serialise (to_idx)); - return NOTMUCH_STATUS_SUCCESS; + return status; } _notmuch_database_log (notmuch, "unimplimented range prefix: '%s'\n", prefix->name);