From: Peter Stephenson <p.stephenson@samsung.com>
To: zsh workers <zsh-workers@zsh.org>
Subject: Re: PATCH: Add :^ syntax for zipping two arrays
Date: Fri, 01 Aug 2014 16:02:47 +0100 [thread overview]
Message-ID: <20140801160247.7e071644@pwslap01u.europe.root.pri> (raw)
In-Reply-To: <CAHYJk3Rdc72OEZMf_F6eiYXA_6g203wS1twb4Zdx+4ps_F+MsQ@mail.gmail.com>
On Fri, 01 Aug 2014 16:46:57 +0200
Mikael Magnusson <mikachu@gmail.com> wrote:
> I modeled it loosely on the :| / :* code which is just below it, which
> uses mkarray, zhalloc and dupstring, which is... confusing.
That'll be one of them bug things people sometimes try to interest me
in.
pws
diff --git a/Src/subst.c b/Src/subst.c
index 4713502..d6be2f0 100644
--- a/Src/subst.c
+++ b/Src/subst.c
@@ -2935,7 +2935,7 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int pf_flags)
*/
if (!vunset) {
if (isarr) {
- aval = mkarray(NULL);
+ aval = hmkarray(NULL);
} else {
val = dupstring("");
}
diff --git a/Src/utils.c b/Src/utils.c
index aa978e6..998e46a 100644
--- a/Src/utils.c
+++ b/Src/utils.c
@@ -3372,6 +3372,17 @@ mkarray(char *s)
}
/**/
+mod_export char **
+hmkarray(char *s)
+{
+ char **t = (char **) zhalloc((s) ? (2 * sizeof s) : (sizeof s));
+
+ if ((*t = s))
+ t[1] = NULL;
+ return t;
+}
+
+/**/
mod_export void
zbeep(void)
{
next prev parent reply other threads:[~2014-08-01 15:02 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-31 17:45 Mikael Magnusson
2014-08-01 8:46 ` Peter Stephenson
2014-08-01 14:46 ` Mikael Magnusson
2014-08-01 15:02 ` Peter Stephenson [this message]
2014-08-01 15:20 ` Bart Schaefer
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=20140801160247.7e071644@pwslap01u.europe.root.pri \
--to=p.stephenson@samsung.com \
--cc=zsh-workers@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).