* PATCH: Re: splitting with empty separator.
@ 2000-05-15 10:59 Sven Wischnowsky
2000-05-15 11:31 ` Bart Schaefer
0 siblings, 1 reply; 5+ messages in thread
From: Sven Wischnowsky @ 2000-05-15 10:59 UTC (permalink / raw)
To: zsh-workers
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@informatik.hu-berlin.de
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: PATCH: Re: splitting with empty separator.
2000-05-15 10:59 PATCH: Re: splitting with empty separator Sven Wischnowsky
@ 2000-05-15 11:31 ` Bart Schaefer
2000-05-15 11:41 ` Peter Stephenson
0 siblings, 1 reply; 5+ messages in thread
From: Bart Schaefer @ 2000-05-15 11:31 UTC (permalink / raw)
To: Sven Wischnowsky, zsh-workers
On May 15, 12:59pm, Sven Wischnowsky wrote:
} Subject: PATCH: Re: splitting with empty separator.
}
} > 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.
Hm again.
Here's the 3.0.8 prelease with 11368 applied:
zagzig% a="$(print -P '\0')"
zagzig% b=(${(s::)a}); print $#b
1
zagzig% print -R - "$b" | cat -v
^@
Now here's 3.1.7-pre-3 with 11368 applied:
zagzig% a="$(print -P '\0')"
zagzig% b=(${(s::)a}); print $#b
2
zagzig% print -R - "$b" | cat -v
^@
zagzig% print -R - "$a" | cat -v
^@
What's the second character in $b in 3.1.7-pre-3?
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/barts http://www.brasslantern.com
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: PATCH: Re: splitting with empty separator.
2000-05-15 11:31 ` Bart Schaefer
@ 2000-05-15 11:41 ` Peter Stephenson
2000-05-15 11:50 ` Bart Schaefer
0 siblings, 1 reply; 5+ messages in thread
From: Peter Stephenson @ 2000-05-15 11:41 UTC (permalink / raw)
To: Zsh hackers list
Bart wrote:
> Now here's 3.1.7-pre-3 with 11368 applied:
>
> zagzig% a="$(print -P '\0')"
> zagzig% b=(${(s::)a}); print $#b
> 2
Are you quite sure you've applied the patch? I only get 1.
--
Peter Stephenson <pws@cambridgesiliconradio.com>
Cambridge Silicon Radio, Unit 300, Science Park, Milton Road,
Cambridge, CB4 0XL, UK Tel: +44 (0)1223 392070
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: PATCH: Re: splitting with empty separator.
2000-05-15 11:41 ` Peter Stephenson
@ 2000-05-15 11:50 ` Bart Schaefer
0 siblings, 0 replies; 5+ messages in thread
From: Bart Schaefer @ 2000-05-15 11:50 UTC (permalink / raw)
To: Zsh hackers list
On May 15, 12:41pm, Peter Stephenson wrote:
}
} Are you quite sure you've applied the patch?
Sigh, no. Apparently my "cvs update" from sourceforge went awry. Sorry.
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/barts http://www.brasslantern.com
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: PATCH: Re: splitting with empty separator.
@ 2000-05-15 11:40 Sven Wischnowsky
0 siblings, 0 replies; 5+ messages in thread
From: Sven Wischnowsky @ 2000-05-15 11:40 UTC (permalink / raw)
To: zsh-workers
Bart Schaefer wrote:
> ...
>
> Now here's 3.1.7-pre-3 with 11368 applied:
>
> zagzig% a="$(print -P '\0')"
> zagzig% b=(${(s::)a}); print $#b
> 2
> zagzig% print -R - "$b" | cat -v
> ^@
> zagzig% print -R - "$a" | cat -v
> ^@
>
> What's the second character in $b in 3.1.7-pre-3?
Eh?
% ./zsh -f
% a="$(print -P '\0')"
% b=(${(s::)a}); print $#b
1
% x="$b[1]"
% echo $#x
1
Does anyone else see the `2' (it would be `second element')?
Bye
Sven
--
Sven Wischnowsky wischnow@informatik.hu-berlin.de
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2000-05-15 11:50 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-05-15 10:59 PATCH: Re: splitting with empty separator Sven Wischnowsky
2000-05-15 11:31 ` Bart Schaefer
2000-05-15 11:41 ` Peter Stephenson
2000-05-15 11:50 ` Bart Schaefer
2000-05-15 11:40 Sven Wischnowsky
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).