From: Stephane Chazelas <stephane@chazelas.org>
To: Zsh hackers list <zsh-workers@zsh.org>
Subject: [PATCH] improve pcre error message
Date: Sat, 9 Mar 2024 10:06:07 +0000 [thread overview]
Message-ID: <20240309100607.avfimrgvlaleipjf@chazelas.org> (raw)
$ pcre_compile .
$ pcre_match $'\xff'
pcre_match: error in pcre matching for /\M-^?/: UTF-8 error: illegal byte (0xfe or 0xff)
$ pcre_match $'\x87'
pcre_match: error in pcre matching for /*/: UTF-8 error: isolated byte with 0x80 bit set
Those /.../ are misleading as it's the subject we're talking
of here, not the regexp and there's a missing metafy (or
unwanted unmetafy) for the argument passed to zwarn (another of
those moles that need to be whacked).
The patch below changes it to:
$ pcre_match $'\xff'
pcre_match: error in pcre matching for \M-^?: UTF-8 error: illegal byte (0xfe or 0xff)
$ pcre_match $'\x87'
pcre_match: error in pcre matching for \M-^G: UTF-8 error: isolated byte with 0x80 bit set
diff --git a/Src/Modules/pcre.c b/Src/Modules/pcre.c
index a49d1a307..67157cc01 100644
--- a/Src/Modules/pcre.c
+++ b/Src/Modules/pcre.c
@@ -405,7 +405,7 @@ bin_pcre_match(char *nam, char **args, Options ops, UNUSED(int func))
else {
PCRE2_UCHAR buffer[256];
pcre2_get_error_message(ret, buffer, sizeof(buffer));
- zwarnnam(nam, "error in pcre matching for /%s/: %s", plaintext, buffer);
+ zwarnnam(nam, "error in pcre matching for %s: %s", *args, buffer);
}
if (pcre_mdata)
reply other threads:[~2024-03-09 10:06 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240309100607.avfimrgvlaleipjf@chazelas.org \
--to=stephane@chazelas.org \
--cc=zsh-workers@zsh.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://git.vuxu.org/mirror/zsh/
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 NNTP newsgroup(s).