From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id 6OK/FWL3A2FIgwEAgWs5BA (envelope-from ) for ; Fri, 30 Jul 2021 14:58:10 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id QOBfEWL3A2E8NgAAbx9fmQ (envelope-from ) for ; Fri, 30 Jul 2021 12:58:10 +0000 Received: from mail.notmuchmail.org (nmbug.tethera.net [144.217.243.247]) (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 E4D1210E8A for ; Fri, 30 Jul 2021 14:58:09 +0200 (CEST) Received: from nmbug.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id D9D0329241; Fri, 30 Jul 2021 08:57:02 -0400 (EDT) Received: from fethera.tethera.net (fethera.tethera.net [IPv6:2607:5300:60:c5::1]) by mail.notmuchmail.org (Postfix) with ESMTP id A682229200 for ; Fri, 30 Jul 2021 08:56:31 -0400 (EDT) Received: by fethera.tethera.net (Postfix, from userid 1001) id BBD495FD17; Fri, 30 Jul 2021 08:56:30 -0400 (EDT) Received: (nullmailer pid 2166918 invoked by uid 1000); Fri, 30 Jul 2021 12:56:10 -0000 From: David Bremner To: notmuch@notmuchmail.org Cc: David Bremner Subject: [PATCH 26/27] lib: factor out expansion of saved queries. Date: Fri, 30 Jul 2021 09:56:06 -0300 Message-Id: <20210730125607.2165433-27-david@tethera.net> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210730125607.2165433-1-david@tethera.net> References: <20210730125607.2165433-1-david@tethera.net> MIME-Version: 1.0 Message-ID-Hash: YX5OJS7OYB2BN6OYK5JVZIX5HQN5EM3D X-Message-ID-Hash: YX5OJS7OYB2BN6OYK5JVZIX5HQN5EM3D 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=1627649890; 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=CI4JbTEhFYeXH9qmxZ61GBH1uLfZSx5pvKhxyOCBawQ=; b=XkU1aFqXLqOcYHzj32hUAbvuUtRCbjOcpDkrb++rMAERlNo7V2Hc8/1+imMnIH1dsWuvSr tQiDcDskzZg+KAo3JvVWxxlYxJg7eL34Gp364XnH2vyDBd4R3RrKXA34Dh1g9pXvvZsZQe F69miI18/qOM8dS81RetC9H81upT2R+55kyxdvYKRmEo49AOcb6Ug+2g6Fl5FHpSDJs6gD znNmPf3GnKCOLpwBP6OMTyQToeYLPNsB1KKE7IBjarEpabHLL6m6lq3gXIMUJ04IcrSV5j eNjTjYg1kicH316Uhkk262D0HOo6+uv9pWMgwVV7VsARtTzovuq4rtx+cLPTVQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1627649890; a=rsa-sha256; cv=none; b=IBqNiBiMXOGkP9QjRXJlINVQBlCyLfnkJ8TTQ4/erloaPskwFNCeOC3iCySlXlzCf8XYHF AbYKihPVoSehMQcgAVVsOtihQ9fDDku+LWBUFq92UgI4lkYgpgC/SFFtNkRkQHMi9jh37n /iiKLyTjBsIwveudyenpx7QhHWjKwxXw5s6eXocRdu/8mCBN8IGkrWN1dKtGuAGUISMhai a8NbAFnHWjwgYKlr86t+I5wbUG1XsBQHYvb8mGfpea99jL4rbeOoLDnZJmSULbVHQx9lSc x6oKTbEgHiMb/LkyLV9doWVyKYZHeg5/X5mJp8nr6JcBBR0WIX+9gAyxJ0JKnw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 144.217.243.247 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Spam-Score: 0.49 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 144.217.243.247 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Queue-Id: E4D1210E8A X-Spam-Score: 0.49 X-Migadu-Scanner: scn0.migadu.com X-TUID: o8sFLvExPjcl 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.30.2