zsh-workers
 help / color / mirror / code / Atom feed
* [PATCH] improve pcre error message
@ 2024-03-09 10:06 Stephane Chazelas
  0 siblings, 0 replies; only message in thread
From: Stephane Chazelas @ 2024-03-09 10:06 UTC (permalink / raw)
  To: Zsh hackers list

$ 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)


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-03-09 10:06 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-09 10:06 [PATCH] improve pcre error message Stephane Chazelas

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).