From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id QK7TBpHUm2KpWQEAbAwnHQ (envelope-from ) for ; Sat, 04 Jun 2022 23:54:25 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id 4LfaBZHUm2KCcQAAG6o9tA (envelope-from ) for ; Sat, 04 Jun 2022 23:54:25 +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 C04B323130 for ; Sat, 4 Jun 2022 23:54:24 +0200 (CEST) Received: from yantan.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 81C375F7D5; Sat, 4 Jun 2022 21:54:12 +0000 (UTC) Received: from fethera.tethera.net (fethera.tethera.net [IPv6:2607:5300:60:c5::1]) by mail.notmuchmail.org (Postfix) with ESMTP id AD6505F7C3 for ; Sat, 4 Jun 2022 21:54:08 +0000 (UTC) Received: by fethera.tethera.net (Postfix, from userid 1001) id 143905FC01; Sat, 4 Jun 2022 17:54:07 -0400 (EDT) Received: (nullmailer pid 1311974 invoked by uid 1000); Sat, 04 Jun 2022 21:54:03 -0000 From: David Bremner To: David Bremner , notmuch@notmuchmail.org Subject: [PATCH 3/4] lib/sexp: allow * as alias for "" in range searches. Date: Sat, 4 Jun 2022 18:53:58 -0300 Message-Id: <20220604215359.1311950-3-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: 7H6J3DXVA3AVSBQW5ZX5NUJ3HYPLELDW X-Message-ID-Hash: 7H6J3DXVA3AVSBQW5ZX5NUJ3HYPLELDW 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=1654379664; 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=aP/eE9vuTn7sy8XyBHiX9IeoX+0Vo7VB4jSecfxTjHI=; b=ECt5aqm6/A/ouAlAyZjF7EXdIFPWzo2Q4A/la8gcJbF0swcQu0ipU0vS8XkAaIeUf3Fvpl 9WCsEfvTRTJjAbKzMpEcpOxrGuwwMgPOdTxG7jjurgeBA2CHZGiVmGxbChKh1imBeOXYPO j/Xj5/ZdM9OyMP4ItDMYP1ETLFCX/Ff8DdlyhSQD/FRn6ZcPY6IX9gmPtU3qm/JZFSvbmc h0W8nn4VqgfZTLWvbDBNKxmD9XaTWRU2v5O4SBarOpa8gqHfZRcKL3OLe1A0fxeSZCEtns UtXv3AF4VMPPnKnuFcyOLwCbzMLI3U+FeE7Wp3McADvEC38gSTlLWGC/L3LHEA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1654379664; a=rsa-sha256; cv=none; b=NDCYk6MEAu3UhZg7qSa0Gb6sZP0MvVIuAsR5MRA/qdsmMy+gUr0u2fIbfuKcVZLDyf4X/w HpCtxEGTgfM6IQ+aytLH7BWiP4nU4hoh9mm/bPjYodvRH5f69PiWKZRZ02lASQFyDCGv6T W250pQj8+iHauVBvsO1ODaJx4MMyJkNrobRkpZjpMLVLhj2r/kvRCMiz6vaxidUqOW0Ghf e5vl5B8mWNTEz9Eu8smZ+mQ019fyaT26pEvZFrp6xuLJ6ru7v5guRLyTYfYRvgaOl4TM62 x1+GTG2KuDTptFKzT2+0NICmq992xFvyourvkWyUEAPPkhGcCuyC+7nAmySwmw== 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: C04B323130 X-Spam-Score: -1.05 X-Migadu-Scanner: scn0.migadu.com X-TUID: T/hxWBtygkky It can be tedious to use "" inside of a string, e.g. in a shell script. --- lib/parse-sexp.cc | 5 +++++ test/T081-sexpr-search.sh | 20 ++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/lib/parse-sexp.cc b/lib/parse-sexp.cc index 6282a456..6814c9fc 100644 --- a/lib/parse-sexp.cc +++ b/lib/parse-sexp.cc @@ -473,6 +473,9 @@ _sexp_parse_range (notmuch_database_t *notmuch, const _sexp_prefix_t *prefix, } from = sx->val; + if (strcmp (from, "*") == 0) + from = ""; + to = from; if (sx->next) { @@ -488,6 +491,8 @@ _sexp_parse_range (notmuch_database_t *notmuch, const _sexp_prefix_t *prefix, } to = sx->next->val; + if (strcmp (to, "*") == 0) + to = ""; } if (strcmp (prefix->name, "date") == 0) { diff --git a/test/T081-sexpr-search.sh b/test/T081-sexpr-search.sh index 896ffe5d..1b036a0d 100755 --- a/test/T081-sexpr-search.sh +++ b/test/T081-sexpr-search.sh @@ -864,6 +864,16 @@ notmuch search date:..2009-11-17 and from:keithp | notmuch_search_sanitize > EXP notmuch search --query=sexp '(and (date "" 2009-11-17) (from keithp))' | notmuch_search_sanitize > OUTPUT test_expect_equal_file_nonempty EXPECTED OUTPUT +test_begin_subtest "date query, lower bound only, using *" +notmuch search date:2009-11-18.. and from:keithp | notmuch_search_sanitize > EXPECTED +notmuch search --query=sexp '(and (date 2009-11-18 *) (from keithp))' | notmuch_search_sanitize > OUTPUT +test_expect_equal_file_nonempty EXPECTED OUTPUT + +test_begin_subtest "date query, upper bound only, using *" +notmuch search date:..2009-11-17 and from:keithp | notmuch_search_sanitize > EXPECTED +notmuch search --query=sexp '(and (date * 2009-11-17) (from keithp))' | notmuch_search_sanitize > OUTPUT +test_expect_equal_file_nonempty EXPECTED OUTPUT + test_begin_subtest "date query, illegal nesting 1" notmuch search --query=sexp '(to (date))' > OUTPUT 2>&1 cat < EXPECTED @@ -941,6 +951,16 @@ 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 +test_begin_subtest "lastmod query, lower bound only, using *" +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, using *" +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 + test_begin_subtest "lastmod query, illegal nesting 1" notmuch search --query=sexp '(to (lastmod))' > OUTPUT 2>&1 cat < EXPECTED -- 2.35.2