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

PATCH: Re: splitting with empty separator.



Tanaka Akira wrote:

> Z(4):akr@serein% zsh -f
> serein% a=$'\0'; b=(${(s::)a}); print $#b
> 2
> serein% print -lr - $b[1] 
>  s::-lr
> serein% 
> 
> Hm.  Splitting with empty separator generates curious result.
> Maybe a metafied character is splitted?

Yes, seems as if it was only missing for the special case of a given
but empty separator string.

Bye
 Sven

Index: Src/utils.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/utils.c,v
retrieving revision 1.4
diff -u -r1.4 utils.c
--- Src/utils.c	2000/05/08 15:56:37	1.4
+++ Src/utils.c	2000/05/15 10:58:27
@@ -1764,7 +1764,14 @@
 	return i;
     }
     if (!sep[0]) {
-	return **s ? ++*s, 1 : -1;
+	if (**s) {
+	    if (**s == Meta)
+		*s += 2;
+	    else
+		++*s;
+	    return 1;
+	}
+	return -1;
     }
     for (i = 0; **s; i++) {
 	for (t = sep, tt = *s; *t && *tt && *t == *tt; t++, tt++);

--
Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx



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