From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id AD2026DE106B for ; Mon, 11 Mar 2019 10:15:15 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: -0.334 X-Spam-Level: X-Spam-Status: No, score=-0.334 tagged_above=-999 required=5 tests=[AWL=-0.334, RCVD_IN_DNSWL_NONE=-0.0001] autolearn=disabled Received: from arlo.cworth.org ([127.0.0.1]) by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id VwBYPRLxpK_U for ; Mon, 11 Mar 2019 10:15:15 -0700 (PDT) Received: from wp260.webpack.hosteurope.de (wp260.webpack.hosteurope.de [80.237.133.29]) by arlo.cworth.org (Postfix) with ESMTPS id 04B386DE1062 for ; Mon, 11 Mar 2019 10:15:14 -0700 (PDT) Received: from p508bc35c.dip0.t-ipconnect.de ([80.139.195.92] helo=deneb.skynet.aixah.de); authenticated by wp260.webpack.hosteurope.de running ExIM with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) id 1h3OW8-00070h-1y; Mon, 11 Mar 2019 18:15:12 +0100 Received: by deneb.skynet.aixah.de (Postfix, from userid 1000) id 9D96AC02F8; Mon, 11 Mar 2019 18:15:11 +0100 (CET) From: Luis Ressel To: notmuch@notmuchmail.org Subject: [PATCH 2/2] Prepend regerror() messages with "regexp error: " Date: Mon, 11 Mar 2019 18:14:49 +0100 Message-Id: <20190311171449.28507-2-aranea@aixah.de> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190311171449.28507-1-aranea@aixah.de> References: <20190311171449.28507-1-aranea@aixah.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-bounce-key: webpack.hosteurope.de;aranea@aixah.de;1552324515;b9fdc1a4; X-HE-SMSGID: 1h3OW8-00070h-1y X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Mar 2019 17:15:15 -0000 The exact error messages returned by regerror() aren't standardized; relying on them isn't portable. Thus, add a a prefix to make clear that the subsequent message is a regexp parsing error, and only look for this prefix in the test suite, ignoring the rest of the message. --- lib/regexp-fields.cc | 4 ++-- test/T650-regexp-query.sh | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/regexp-fields.cc b/lib/regexp-fields.cc index 084bc8c0..f50da9a3 100644 --- a/lib/regexp-fields.cc +++ b/lib/regexp-fields.cc @@ -35,9 +35,9 @@ compile_regex (regex_t ®exp, const char *str) if (err != 0) { size_t len = regerror (err, ®exp, NULL, 0); char *buffer = new char[len]; - std::string msg; + std::string msg = "Regexp error: "; (void) regerror (err, ®exp, buffer, len); - msg.assign (buffer, len); + msg.append (buffer, len); delete[] buffer; throw Xapian::QueryParserError (msg); diff --git a/test/T650-regexp-query.sh b/test/T650-regexp-query.sh index 4085340f..31b3d036 100755 --- a/test/T650-regexp-query.sh +++ b/test/T650-regexp-query.sh @@ -137,10 +137,10 @@ EOF test_expect_equal_file EXPECTED OUTPUT test_begin_subtest "regexp error reporting" -notmuch search 'from:/unbalanced[/' 1>OUTPUT 2>&1 +notmuch search 'from:/unbalanced[/' 2>&1 | sed -e '/^A Xapian/ s/[^:]*$//' > OUTPUT cat < EXPECTED notmuch search: A Xapian exception occurred -A Xapian exception occurred parsing query: Invalid regular expression +A Xapian exception occurred parsing query: Regexp error: Query string was: from:/unbalanced[/ EOF test_expect_equal_file EXPECTED OUTPUT -- 2.21.0