1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-09-29 19:00:57 +02:00

23696: x=x; x[-10]=y did bad things

This commit is contained in:
Peter Stephenson 2007-07-25 09:26:51 +00:00
parent 9084df4dc3
commit 4fab17e62a
3 changed files with 27 additions and 1 deletions

View file

@ -1,3 +1,9 @@
2007-07-25 Peter Stephenson <pws@csr.com>
* 23696: Src/params.c, Test/D04parameter.ztst: assignment
to negative subscripts in scalars before the start was broken.
Now adds at start.
2007-07-24 Peter Stephenson <pws@csr.com>
* 23694: Src/cond.c: change of infix condition features to C:

View file

@ -2076,8 +2076,11 @@ setstrvalue(Value v, char *val)
}
if (v->start > zlen)
v->start = zlen;
if (v->end < 0)
if (v->end < 0) {
v->end += zlen + 1;
if (v->end < 0)
v->end = 0;
}
else if (v->end > zlen)
v->end = zlen;
x = (char *) zalloc(v->start + strlen(val) + zlen - v->end + 1);

View file

@ -920,3 +920,20 @@
0:Numeric sorting
>a6 a17 a117 b6 b17 b117
>b117 b17 b6 a117 a17 a6
x=sprodj
x[-10]=scrumf
print $x
0:Out of range negative scalar subscripts
>scrumfsprodj
a=(some sunny day)
a[-10]=(we\'ll meet again)
print -l $a
0:Out of range negative array subscripts
>we'll
>meet
>again
>some
>sunny
>day