From: Peter Stephenson <p.w.stephenson@ntlworld.com>
To: zsh-users@zsh.org
Subject: Re: ${(s::)VAR} vs "${(s::)VAR}"
Date: Sun, 29 Apr 2012 19:41:50 +0100 [thread overview]
Message-ID: <20120429194150.56ad549a@pws-pc.ntlworld.com> (raw)
In-Reply-To: <120427195048.ZM10479@torch.brasslantern.com>
Aha, I have however worked out what's wrong with what I did:
% foo=":bar:"
% print -l "${(s.:.)foo}"
foo
%
There should be an extra empty element, as there used to be. So I think
I need the following instead... Possibly this explains why mul was
relegated to the end in that why.
Index: Src/utils.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/utils.c,v
retrieving revision 1.268
diff -p -u -r1.268 utils.c
--- Src/utils.c 16 Apr 2012 11:26:10 -0000 1.268
+++ Src/utils.c 29 Apr 2012 18:39:39 -0000
@@ -3114,7 +3114,7 @@ wordcount(char *s, char *sep, int mul)
r = 1;
sl = strlen(sep);
for (; (c = findsep(&s, sep, 0)) >= 0; s += sl)
- if ((c && *(s + sl)) || mul)
+ if ((c || mul) && (sl || *(s + sl)))
r++;
} else {
char *t = s;
Index: Test/D04parameter.ztst
===================================================================
RCS file: /cvsroot/zsh/zsh/Test/D04parameter.ztst,v
retrieving revision 1.67
diff -p -u -r1.67 D04parameter.ztst
--- Test/D04parameter.ztst 22 Apr 2012 18:39:53 -0000 1.67
+++ Test/D04parameter.ztst 29 Apr 2012 18:39:39 -0000
@@ -1292,7 +1292,7 @@
>in
>it
- foo="line:with::missing::fields:in:it"
+ foo="line:with::missing::fields:in:it:"
print -l "${(@s.:.)foo}"
0:Retention of empty fields in quoted splitting with "@"
>line
@@ -1303,6 +1303,20 @@
>fields
>in
>it
+>
+
+ str=abcd
+ print -l ${(s..)str}
+ print -l "${(s..)str}"
+0:splitting of strings into characters
+>a
+>b
+>c
+>d
+>a
+>b
+>c
+>d
array=('%' '$' 'j' '*' '$foo')
print ${array[(i)*]} "${array[(i)*]}"
--
Peter Stephenson <p.w.stephenson@ntlworld.com>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/
prev parent reply other threads:[~2012-04-29 18:42 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-26 20:48 Kynn Jones
2012-04-27 20:38 ` Peter Stephenson
2012-04-28 2:50 ` Bart Schaefer
2012-04-29 18:22 ` Peter Stephenson
2012-04-29 18:41 ` Peter Stephenson [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120429194150.56ad549a@pws-pc.ntlworld.com \
--to=p.w.stephenson@ntlworld.com \
--cc=zsh-users@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).