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

Re: Strange behavior of [[



On Mon, 22 Jun 2015 17:56:06 +0200
m0viefreak <m0viefreak.cm@xxxxxxxxxxxxxx> wrote:
> On 11.06.2015 18:59, Peter Stephenson wrote:
> > The change from mb_metacharinit() to mb_charinit() is a bit unsightly
> > but the name had got just plain confusing --- there's nothing meta about
> > it.  I never metacharacter I couldn't parse.
> > 
> > (No multibyte characters were harmed in the preparation of this email;
> > I've used $'\ua0'.)
> > 
> > pws
> > 
> > <path diff>
> > ...
> > </path diff>
> 
> This patch (f1923bdfa6300a0d32e3329eb2488447f76b8970) introduces another
> issue for me:
> 
> Regex evaluation using a conditional capture group crashes zsh when the
> pattern is not found:

This isn't fundamentally new, it's just a different response to an
unhandled condition.

-1 is consistent with what glob matches do.

pws

diff --git a/Src/Modules/regex.c b/Src/Modules/regex.c
index 94f523f..16cc77f 100644
--- a/Src/Modules/regex.c
+++ b/Src/Modules/regex.c
@@ -155,6 +155,11 @@ zcond_regex_match(char **a, int id)
 			 ++n, ++m, ++bptr, ++eptr)
 		    {
 			char buf[DIGBUFSIZE];
+			if (m->rm_so < 0 || m->rm_eo < 0) {
+			    *bptr = ztrdup("-1");
+			    *eptr = ztrdup("-1");
+			    continue;
+			}
 			ptr = lhstr;
 			leftlen = m->rm_so;
 			offs = 0;



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