Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: Re: splitting with empty separator.
- X-seq: zsh-workers 11368
- From: Sven Wischnowsky <wischnow@xxxxxxxxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxxxxxx
- Subject: PATCH: Re: splitting with empty separator.
- Date: Mon, 15 May 2000 12:59:07 +0200 (MET DST)
- In-reply-to: Tanaka Akira's message of 14 May 2000 07:50:25 +0900
- Mailing-list: contact zsh-workers-help@xxxxxxxxxxxxxx; run by ezmlm
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