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

Re: pcre_match() option "-n" broken under zsh 5.0.6



On Sep 7,  1:39am, Sess wrote:
} 
} zsh 5.0.6 appears to have broken pcre_match() with respect to option "-n".

Damn.  Misplaced paren.

Here it is with a regression test (the multibyte characters in the test
preceding may cause the patch not to apply from the email).

diff --git a/Src/Modules/pcre.c b/Src/Modules/pcre.c
index 040a33f..2393cd1 100644
--- a/Src/Modules/pcre.c
+++ b/Src/Modules/pcre.c
@@ -289,7 +289,7 @@ bin_pcre_match(char *nam, char **args, Options ops, UNUSED(int func))
 	matched_portion = OPT_ARG(ops,c);
     }
     if(OPT_HASARG(ops,c='n')) { /* The offset position to start the search, in bytes. */
-	if ((offset_start = getposint(OPT_ARG(ops,c), nam) < 0))
+	if ((offset_start = getposint(OPT_ARG(ops,c), nam)) < 0)
 	    return 1;
     }
     /* For the entire match, 'Return' the offset byte positions instead of the matched string */
diff --git a/Test/V07pcre.ztst b/Test/V07pcre.ztst
index f5b05de..3a65331 100644
--- a/Test/V07pcre.ztst
+++ b/Test/V07pcre.ztst
@@ -108,3 +108,12 @@
 >1
 >0 xoâ??t â??t
 >0 Xoâ??t â??t
+
+  string="The following zip codes: 78884 90210 99513"
+  pcre_compile -m "\d{5}"
+  pcre_match -b -- $string && print "$MATCH; ZPCRE_OP: $ZPCRE_OP"
+  pcre_match -b -n $ZPCRE_OP[(w)2] -- $string || print failed
+  print "$MATCH; ZPCRE_OP: $ZPCRE_OP"
+0:pcre_match -b and pcre_match -n
+>78884; ZPCRE_OP: 25 30
+>90210; ZPCRE_OP: 31 36



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