From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id MHI3K4zUm2LHjgAAbAwnHQ (envelope-from ) for ; Sat, 04 Jun 2022 23:54:20 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id GPM3K4zUm2KHUAAA9RJhRA (envelope-from ) for ; Sat, 04 Jun 2022 23:54:20 +0200 Received: from mail.notmuchmail.org (yantan.tethera.net [135.181.149.255]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 88904C07B for ; Sat, 4 Jun 2022 23:54:20 +0200 (CEST) Received: from yantan.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 2BE045F7D2; Sat, 4 Jun 2022 21:54:10 +0000 (UTC) Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) by mail.notmuchmail.org (Postfix) with ESMTP id 88E875F7C3 for ; Sat, 4 Jun 2022 21:54:07 +0000 (UTC) Received: by fethera.tethera.net (Postfix, from userid 1001) id D30035FBD7; Sat, 4 Jun 2022 17:54:06 -0400 (EDT) Received: (nullmailer pid 1311971 invoked by uid 1000); Sat, 04 Jun 2022 21:54:03 -0000 From: David Bremner To: David Bremner , notmuch@notmuchmail.org Subject: [PATCH 2/4] lib/sexp: special case "" as an argument in lastmod ranges. Date: Sat, 4 Jun 2022 18:53:57 -0300 Message-Id: <20220604215359.1311950-2-david@tethera.net> X-Mailer: git-send-email 2.35.2 In-Reply-To: <20220604215359.1311950-1-david@tethera.net> References: <87v8v6mpvt.fsf@tethera.net> <20220604215359.1311950-1-david@tethera.net> MIME-Version: 1.0 Message-ID-Hash: DWVCMDCZPIRBWHYYOVBI3S6E3M6E65HJ X-Message-ID-Hash: DWVCMDCZPIRBWHYYOVBI3S6E3M6E65HJ X-MailFrom: bremner@tethera.net X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-notmuch.notmuchmail.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.3 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: DE ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1654379660; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-owner:list-unsubscribe:list-subscribe:list-post; bh=CPZ8EPmm5affjst/oyBlQp27vsnZ8ucfhaWHTQqQSdU=; b=bWJtgbpM31LqQXQgrtpT1BZ0bDhoAaoVFxJgquEAiKDLv+dWIB62WjwCbHuaaXOJU418dv j9siXy7Cow/SOOTP5yG4XgoZUG+YTTzgc9viGnetcSXCdZNXH9NJ+dHnv+VonQoHVr2XmK KIIbu3CUSHLqhEYltcoYxQvoCWD5zKFOmx9oChKSy2f+nxohmDCW3sNLZQWISzOr3PfQBd +jgaZkmcwKn5VlxRSuvxAp7ODS55T5MJF8XxZOUBV/ApUmltq7R55jVt48xEfQHz/Ro9oN byyKrByQ/s5fTqAMlAsnI2ZV5SC3VPDgdsa9b85uqnpLU6oYEqQA+OksfwyB7w== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1654379660; a=rsa-sha256; cv=none; b=O2W2M9CE6LJ8Mn+jP+XOgGK+VbzdByY/jSIUkQeQOg8nO/Y4GukAOwdcHUvUbt8X8swb1u 9pxm5iRj///tFZJYZdAEqkTTa3rzCe2lpgwmXFmVgxro5j7EHDJEBxtmmUcS53I2OP+Lg5 Oovfd0ZCISwKVDeZcago6oiZ2fUB2YCMNXAbOc7XIuPwlpYK7Odm9HAx2hyAI9h7jSbjRg KlnD7rrVg27Sgt6U5rlmAM58P8tmZUS+gfHmZbJqVTJL6fsua6xSJPklwkDhB34BCtLV+s nnmPdh43a9FST/HsMamoX/6RTEXI2O9F6txvWYKpZxzUz28m4DSLV1j1sw3gGA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 135.181.149.255 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Spam-Score: -1.05 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 135.181.149.255 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Queue-Id: 88904C07B X-Spam-Score: -1.05 X-Migadu-Scanner: scn1.migadu.com X-TUID: OsDG0IiQtvv7 Support this syntax for constincy with (data from to) ranges. --- lib/parse-sexp.cc | 10 ++++++++-- test/T081-sexpr-search.sh | 2 -- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/parse-sexp.cc b/lib/parse-sexp.cc index 08fd7037..6282a456 100644 --- a/lib/parse-sexp.cc +++ b/lib/parse-sexp.cc @@ -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; diff --git a/test/T081-sexpr-search.sh b/test/T081-sexpr-search.sh index 31169fb5..896ffe5d 100755 --- a/test/T081-sexpr-search.sh +++ b/test/T081-sexpr-search.sh @@ -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 -- 2.35.2