mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-10-01 19:41:00 +02:00
18565: bug when ${(u)...} reduced array to length 1
This commit is contained in:
parent
6d9135befe
commit
c7a2d2225e
3 changed files with 34 additions and 11 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
2003-05-21 Peter Stephenson <pws@csr.com>
|
||||||
|
|
||||||
|
* 18565: Src/subst.c, Test/D04parameter.ztst: when ${(u)...}
|
||||||
|
reduced an array from more than one element to example one
|
||||||
|
stuff happened.
|
||||||
|
|
||||||
2003-05-19 Peter Stephenson <pws@csr.com>
|
2003-05-19 Peter Stephenson <pws@csr.com>
|
||||||
|
|
||||||
* 18548: Src/Zle/zle_main.c: memory leak when vared'ing arrays
|
* 18548: Src/Zle/zle_main.c: memory leak when vared'ing arrays
|
||||||
|
|
29
Src/subst.c
29
Src/subst.c
|
@ -1951,17 +1951,6 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int ssub)
|
||||||
int i;
|
int i;
|
||||||
LinkNode on = n;
|
LinkNode on = n;
|
||||||
|
|
||||||
if (!aval[0] && !plan9) {
|
|
||||||
if (aptr > (char *) getdata(n) &&
|
|
||||||
aptr[-1] == Dnull && *fstr == Dnull)
|
|
||||||
*--aptr = '\0', fstr++;
|
|
||||||
y = (char *) hcalloc((aptr - ostr) + strlen(fstr) + 1);
|
|
||||||
strcpy(y, ostr);
|
|
||||||
*str = y + (aptr - ostr);
|
|
||||||
strcpy(*str, fstr);
|
|
||||||
setdata(n, y);
|
|
||||||
return n;
|
|
||||||
}
|
|
||||||
if (unique) {
|
if (unique) {
|
||||||
if(!copied)
|
if(!copied)
|
||||||
aval = arrdup(aval);
|
aval = arrdup(aval);
|
||||||
|
@ -1970,6 +1959,24 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int ssub)
|
||||||
if (i > 1)
|
if (i > 1)
|
||||||
zhuniqarray(aval);
|
zhuniqarray(aval);
|
||||||
}
|
}
|
||||||
|
if ((!aval[0] || !aval[1]) && !plan9) {
|
||||||
|
int vallen;
|
||||||
|
if (aptr > (char *) getdata(n) &&
|
||||||
|
aptr[-1] == Dnull && *fstr == Dnull)
|
||||||
|
*--aptr = '\0', fstr++;
|
||||||
|
vallen = aval[0] ? strlen(aval[0]) : 0;
|
||||||
|
y = (char *) hcalloc((aptr - ostr) + vallen + strlen(fstr) + 1);
|
||||||
|
strcpy(y, ostr);
|
||||||
|
*str = y + (aptr - ostr);
|
||||||
|
if (vallen)
|
||||||
|
{
|
||||||
|
strcpy(*str, aval[0]);
|
||||||
|
*str += vallen;
|
||||||
|
}
|
||||||
|
strcpy(*str, fstr);
|
||||||
|
setdata(n, y);
|
||||||
|
return n;
|
||||||
|
}
|
||||||
if (sortit) {
|
if (sortit) {
|
||||||
if (!copied)
|
if (!copied)
|
||||||
aval = arrdup(aval);
|
aval = arrdup(aval);
|
||||||
|
|
|
@ -589,3 +589,13 @@
|
||||||
0:Parameters associated with (#m) flag
|
0:Parameters associated with (#m) flag
|
||||||
>MATCH 16 20 MATCH
|
>MATCH 16 20 MATCH
|
||||||
>5
|
>5
|
||||||
|
|
||||||
|
print -l JAMES${(u)${=:-$(echo yes yes)}}JOYCE
|
||||||
|
print -l JAMES${(u)${=:-$(echo yes yes she said yes i will yes)}}JOYCE
|
||||||
|
0:Bug with (u) flag reducing arrays to one element
|
||||||
|
>JAMESyesJOYCE
|
||||||
|
>JAMESyes
|
||||||
|
>she
|
||||||
|
>said
|
||||||
|
>i
|
||||||
|
>willJOYCE
|
||||||
|
|
Loading…
Reference in a new issue