Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

[PATCH] improve pcre error message



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




Messages sorted by: Reverse Date, Date, Thread, Author