From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id +BjvLEIOJWGI4wAAgWs5BA (envelope-from ) for ; Tue, 24 Aug 2021 17:20:34 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id 6A6aKEIOJWEgbAAAB5/wlQ (envelope-from ) for ; Tue, 24 Aug 2021 15:20:34 +0000 Received: from mail.notmuchmail.org (nmbug.tethera.net [IPv6:2607:5300:201:3100::1657]) (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 6CBFE8774 for ; Tue, 24 Aug 2021 17:20:34 +0200 (CEST) Received: from nmbug.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id C87852050E; Tue, 24 Aug 2021 11:20:19 -0400 (EDT) Received: from fethera.tethera.net (fethera.tethera.net [IPv6:2607:5300:60:c5::1]) by mail.notmuchmail.org (Postfix) with ESMTP id DA374204EB for ; Tue, 24 Aug 2021 11:20:13 -0400 (EDT) Received: by fethera.tethera.net (Postfix, from userid 1001) id D27AA5FD5C; Tue, 24 Aug 2021 11:20:13 -0400 (EDT) Received: (nullmailer pid 2942883 invoked by uid 1000); Tue, 24 Aug 2021 15:17:52 -0000 From: David Bremner To: notmuch@notmuchmail.org Cc: David Bremner Subject: [PATCH 27/36] lib: factor out expansion of saved queries. Date: Tue, 24 Aug 2021 08:17:36 -0700 Message-Id: <20210824151745.2941868-28-david@tethera.net> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210824151745.2941868-1-david@tethera.net> References: <20210824151745.2941868-1-david@tethera.net> MIME-Version: 1.0 Message-ID-Hash: LKNJWKA6E4VW2J777OL65SAIPVNC4DBI X-Message-ID-Hash: LKNJWKA6E4VW2J777OL65SAIPVNC4DBI 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; suspicious-header X-Mailman-Version: 3.2.1 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1629818434; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc: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-unsubscribe:list-subscribe:list-post; bh=jKboHgoXxuSDQhmGxVot9hGocoF3DE2RsSR6k1Sf3ZQ=; b=lHOIPc+LZJ9ixD44NJAw4li5HxqyTZuQspESGnOJ2VeIg8pO9IhN0vNu6uazbTCFlYJ4kc Y4no1dWOYZ7P6/7BzMW4HoCupMBmno05qtZ+Q74vyykQPB6ESVGWEUnKF2wSfrXwDATs1+ twsiKzea8fzfAVxkLzvVwb4384wiz88Ugt4E71NFaNrWiUtukBikcvpLkoVCd8snylwYNy FnovLlXV4reshFmL65/8+hNDM0scZOj0HXLSo7sXBuF99C6663PqWRHDJwN3QoADADEGH+ nESDUaAP12gFqQeO8LGVSNRB9mWRQYNADKAspMwPU89vu0ym7kCyOqKZ4oZTDw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1629818434; a=rsa-sha256; cv=none; b=HRH4683GOY+cbbcLdVOWirhVCFhq+Wig5zX0YZfUNdTmIBKuqlmg/Rd+pYvaWfG45hylsF ULTp52lwzNWkYVP2Qw/VzNa++dqmW9pRhP2xBq4TpMYUo4F0VEGU6rMhmljRdORJqU2gXw +otR651RipX/D/Dw2fA61dfJfkgNSqvpYUWxb3fDkD+ykFa6g04DFFT6aoK4oKWvp11yCB sa2/PqNMlIHqopRLTlQuvQa45tEB4DjmWD02lgQYKQrlEQOlRnuK6MSDsiDUW98xsJvZpz GFaFgNW4C13tYCwR2muwJnF/uI+O9f7IyqtnIQEVJrh+C6jAEJbZRkRescvuQQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 2607:5300:201:3100::1657 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Spam-Score: -0.93 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 2607:5300:201:3100::1657 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Queue-Id: 6CBFE8774 X-Spam-Score: -0.93 X-Migadu-Scanner: scn0.migadu.com X-TUID: ZtDjnyNQ/8AI This is intended to allow use outside of the Xapian query parser. --- lib/database-private.h | 5 +++++ lib/query-fp.cc | 22 +++++++++++++++++++--- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/lib/database-private.h b/lib/database-private.h index 9ee3b933..8b9d67fe 100644 --- a/lib/database-private.h +++ b/lib/database-private.h @@ -327,6 +327,11 @@ _notmuch_regexp_to_query (notmuch_database_t *notmuch, Xapian::valueno slot, std std::string regexp_str, Xapian::Query &output, std::string &msg); +/* thread-fp.cc */ +notmuch_status_t +_notmuch_query_name_to_query (notmuch_database_t *notmuch, const std::string name, + Xapian::Query &output); + #if HAVE_SFSEXP /* parse-sexp.cc */ notmuch_status_t diff --git a/lib/query-fp.cc b/lib/query-fp.cc index b980b7f0..75b1d875 100644 --- a/lib/query-fp.cc +++ b/lib/query-fp.cc @@ -24,17 +24,33 @@ #include "query-fp.h" #include -Xapian::Query -QueryFieldProcessor::operator() (const std::string & name) +notmuch_status_t +_notmuch_query_name_to_query (notmuch_database_t *notmuch, const std::string name, + Xapian::Query &output) { std::string key = "query." + name; char *expansion; notmuch_status_t status; status = notmuch_database_get_config (notmuch, key.c_str (), &expansion); + if (status) + return status; + + output = notmuch->query_parser->parse_query (expansion, NOTMUCH_QUERY_PARSER_FLAGS); + return NOTMUCH_STATUS_SUCCESS; +} + +Xapian::Query +QueryFieldProcessor::operator() (const std::string & name) +{ + notmuch_status_t status; + Xapian::Query output; + + status = _notmuch_query_name_to_query (notmuch, name, output); if (status) { throw Xapian::QueryParserError ("error looking up key" + name); } - return parser.parse_query (expansion, NOTMUCH_QUERY_PARSER_FLAGS); + return output; + } -- 2.32.0