mirror of
git://git.code.sf.net/p/zsh/code
synced 2024-06-08 00:06:04 +02:00
users/15662: array slice assignment with one index positive and one negative.
This commit is contained in:
parent
d3ec328926
commit
bc1a12f91e
|
@ -1,3 +1,10 @@
|
|||
2010-12-21 Barton E. Schaefer <schaefer@zsh.org>
|
||||
|
||||
* users/15662: Src/params.c: fix array slice assignment with one
|
||||
index positive and one negative.
|
||||
|
||||
* unposted: Test/A06assign.ztst: tests for users/15662.
|
||||
|
||||
2010-12-21 Peter Stephenson <pws@csr.com>
|
||||
|
||||
* users/15663: Test/A06Assign.ztst: some (incomplete) array
|
||||
|
@ -14024,5 +14031,5 @@
|
|||
|
||||
*****************************************************
|
||||
* This is used by the shell to define $ZSH_PATCHLEVEL
|
||||
* $Revision: 1.5165 $
|
||||
* $Revision: 1.5166 $
|
||||
*****************************************************
|
||||
|
|
|
@ -2442,8 +2442,6 @@ setarrvalue(Value v, char **val)
|
|||
v->start--;
|
||||
v->end--;
|
||||
}
|
||||
if (v->end < v->start)
|
||||
v->end = v->start;
|
||||
q = old = v->pm->gsu.a->getfn(v->pm);
|
||||
n = arrlen(old);
|
||||
if (v->start < 0) {
|
||||
|
@ -2456,6 +2454,8 @@ setarrvalue(Value v, char **val)
|
|||
if (v->end < 0)
|
||||
v->end = 0;
|
||||
}
|
||||
if (v->end < v->start)
|
||||
v->end = v->start;
|
||||
|
||||
ll = v->start + arrlen(val);
|
||||
if (v->end <= n)
|
||||
|
|
|
@ -104,7 +104,29 @@
|
|||
0:Replacement off start doesn't leave gaps. Hope this is right.
|
||||
>43 1 2 3 4 5
|
||||
|
||||
# TODO: mixed indices [-num,num] and [num,-num]
|
||||
array=(1 2 3 4 5)
|
||||
array[1,-1]=(42 43)
|
||||
print $array
|
||||
array[-3,3]=(1 2 3 4 5)
|
||||
print $array
|
||||
0:Replacement of entire array, mixed indices
|
||||
>42 43
|
||||
>1 2 3 4 5
|
||||
|
||||
array=(1 2 3 4 5)
|
||||
array[-7,7]=(42 43)
|
||||
print $array
|
||||
0:Replacement of more than entire array, mixed indices
|
||||
>42 43
|
||||
|
||||
array=(1 2 3 4 5)
|
||||
array[3,-2]=(42 43 44)
|
||||
print $array
|
||||
array[-3,5]=(100 99)
|
||||
print $array
|
||||
0:Replacement of slice in middle, mixed indices
|
||||
>1 2 42 43 44 5
|
||||
>1 2 42 100 99 5
|
||||
|
||||
# tests of var+=scalar
|
||||
|
||||
|
|
Loading…
Reference in New Issue