diff options
author | Tanaka Akira <akr@users.sourceforge.net> | 1999-09-23 13:21:09 +0000 |
---|---|---|
committer | Tanaka Akira <akr@users.sourceforge.net> | 1999-09-23 13:21:09 +0000 |
commit | f0a1c1aafec9f704afe939710d6c2c8c3fd639ad (patch) | |
tree | c467744e948489d82d36dc65442b09827659ad86 /Src | |
parent | 8d679b92b47607a118c3555340e4f80b88548a53 (diff) | |
download | zsh-f0a1c1aafec9f704afe939710d6c2c8c3fd639ad.tar.gz zsh-f0a1c1aafec9f704afe939710d6c2c8c3fd639ad.tar.xz zsh-f0a1c1aafec9f704afe939710d6c2c8c3fd639ad.zip |
zsh-workers/8023
Diffstat (limited to 'Src')
-rw-r--r-- | Src/subst.c | 13 | ||||
-rw-r--r-- | Src/utils.c | 26 |
2 files changed, 28 insertions, 11 deletions
diff --git a/Src/subst.c b/Src/subst.c index 5b08d0bfb..45b58aef6 100644 --- a/Src/subst.c +++ b/Src/subst.c @@ -1618,8 +1618,8 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int ssub) opts[PROMPTPERCENT] = opp; } if (quotemod) { - if (--quotetype > 2) - quotetype = 2; + if (--quotetype > 3) + quotetype = 3; if (isarr) { char **ap; @@ -1628,7 +1628,10 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int ssub) ap = aval; if (quotemod > 0) { - if (quotetype) { + if (quotetype == 3) + for (; *ap; ap++) + *ap = nicedupstring(*ap); + else if (quotetype) { int sl; char *tmp; @@ -1665,7 +1668,9 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int ssub) if (!copied) val = dupstring(val), copied = 1; if (quotemod > 0) { - if (quotetype) { + if (quotetype == 3) + val = nicedupstring(val); + else if (quotetype) { int sl; char *tmp; diff --git a/Src/utils.c b/Src/utils.c index 38276faee..da4bcffaa 100644 --- a/Src/utils.c +++ b/Src/utils.c @@ -2867,12 +2867,12 @@ zputs(char const *s, FILE *stream) /* Create a visibly-represented duplicate of a string. */ /**/ -char * -niceztrdup(char const *s) +static char * +nicedup(char const *s, int heap) { int c, len = strlen(s) * 5; - char *buf = zalloc(len); - char *p = buf, *n, *ret; + VARARR(char, buf, len); + char *p = buf, *n; while ((c = *s++)) { if (itok(c)) { @@ -2887,9 +2887,21 @@ niceztrdup(char const *s) while(*n) *p++ = *n++; } - ret = metafy(buf, p - buf, META_DUP); - zfree(buf, len); - return ret; + return metafy(buf, p - buf, (heap ? META_HEAPDUP : META_DUP)); +} + +/**/ +char * +niceztrdup(char const *s) +{ + return nicedup(s, 0); +} + +/**/ +char * +nicedupstring(char const *s) +{ + return nicedup(s, 1); } /* Unmetafy and output a string, displaying special characters readably. */ |