From: Luis Ressel <aranea@aixah.de>
To: notmuch@notmuchmail.org
Subject: [PATCH 2/2] Prepend regerror() messages with "regexp error: "
Date: Mon, 11 Mar 2019 18:14:49 +0100 [thread overview]
Message-ID: <20190311171449.28507-2-aranea@aixah.de> (raw)
In-Reply-To: <20190311171449.28507-1-aranea@aixah.de>
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 <<EOF > 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
next prev parent reply other threads:[~2019-03-11 17:15 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-11 17:14 [PATCH 1/2] test/T030-config: Separate stdout and stderr output Luis Ressel
2019-03-11 17:14 ` Luis Ressel [this message]
2019-03-12 10:53 ` David Bremner
2019-03-13 20:19 ` Tomi Ollila
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190311171449.28507-2-aranea@aixah.de \
--to=aranea@aixah.de \
--cc=notmuch@notmuchmail.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).