]> git.notmuchmail.org Git - notmuch/commitdiff
lib/sexp: special case "" as an argument in lastmod ranges.
authorDavid Bremner <david@tethera.net>
Sat, 4 Jun 2022 21:53:57 +0000 (18:53 -0300)
committerDavid Bremner <david@tethera.net>
Sat, 25 Jun 2022 22:49:55 +0000 (19:49 -0300)
Support this syntax for constincy with (data from to) ranges.

lib/parse-sexp.cc
test/T081-sexpr-search.sh

index 08fd703708e86e6c75d960f19e2a404f46bcd20c..6282a4560983e40492d5b5625096a9b336df1feb 100644 (file)
@@ -504,14 +504,20 @@ _sexp_parse_range (notmuch_database_t *notmuch,  const _sexp_prefix_t *prefix,
        long from_idx, to_idx;
 
        try {
-           from_idx = std::stol (from);
+           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;
        }
 
        try {
-           to_idx = std::stol (to);
+           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;
index 31169fb5a46d2f72bad049fc0c1cc8126e507e78..896ffe5dc679fd9c2c4131257f719d18b700e87e 100755 (executable)
@@ -932,13 +932,11 @@ notmuch search --query=sexp  "(and (lastmod $revision $revision2))" | notmuch_se
 test_expect_equal_file EXPECTED OUTPUT
 
 test_begin_subtest "lastmod query, lower bound only"
-test_subtest_known_broken
 notmuch search lastmod:$revision.. | notmuch_search_sanitize > EXPECTED
 notmuch search --query=sexp  "(lastmod $revision \"\")" | notmuch_search_sanitize > OUTPUT
 test_expect_equal_file_nonempty EXPECTED OUTPUT
 
 test_begin_subtest "lastmod query, upper bound only"
-test_subtest_known_broken
 notmuch search lastmod:..$revision2 | notmuch_search_sanitize > EXPECTED
 notmuch search --query=sexp  "(lastmod \"\" $revision2)" | notmuch_search_sanitize > OUTPUT
 test_expect_equal_file_nonempty EXPECTED OUTPUT