mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-10-30 05:40:58 +01:00
19707: negative index into arrays should return scalar and not one element array
This commit is contained in:
parent
43513b4288
commit
3023ddf132
3 changed files with 24 additions and 2 deletions
|
|
@ -1,3 +1,9 @@
|
||||||
|
2004-03-30 Oliver Kiddle <opk@zsh.org>
|
||||||
|
|
||||||
|
* 19707: Src/params.c, Test/D05array.ztst: fix bug where a
|
||||||
|
nagative index into an array returned a one element array
|
||||||
|
instead of a scalar
|
||||||
|
|
||||||
2004-03-25 Clint Adams <clint@zsh.org>
|
2004-03-25 Clint Adams <clint@zsh.org>
|
||||||
|
|
||||||
* 19691: Completion/Unix/Type/_diff_options: Allow more than
|
* 19691: Completion/Unix/Type/_diff_options: Allow more than
|
||||||
|
|
@ -65,7 +71,7 @@
|
||||||
the parameter was previously exported.
|
the parameter was previously exported.
|
||||||
|
|
||||||
* 19655: Src/params.c: the reverse pointer from a tied array
|
* 19655: Src/params.c: the reverse pointer from a tied array
|
||||||
to a tied scalar wasn't delete if the array was unset by unsetting
|
to a tied scalar wasn't deleted if the array was unset by unsetting
|
||||||
the scalar (or probably vice versa).
|
the scalar (or probably vice versa).
|
||||||
|
|
||||||
2004-03-17 Peter Stephenson <pws@csr.com>
|
2004-03-17 Peter Stephenson <pws@csr.com>
|
||||||
|
|
|
||||||
|
|
@ -1272,13 +1272,14 @@ getindex(char **pptr, Value v, int dq)
|
||||||
} else {
|
} else {
|
||||||
end = we ? we : start;
|
end = we ? we : start;
|
||||||
}
|
}
|
||||||
|
if (start != end) com = 1;
|
||||||
if (start > 0)
|
if (start > 0)
|
||||||
start--;
|
start--;
|
||||||
else if (start == 0 && end == 0)
|
else if (start == 0 && end == 0)
|
||||||
end++;
|
end++;
|
||||||
if (s == tbrack) {
|
if (s == tbrack) {
|
||||||
s++;
|
s++;
|
||||||
if (v->isarr && start == end-1 && !com &&
|
if (v->isarr && !com &&
|
||||||
(!(v->isarr & SCANPM_MATCHMANY) ||
|
(!(v->isarr & SCANPM_MATCHMANY) ||
|
||||||
!(v->isarr & (SCANPM_MATCHKEY | SCANPM_MATCHVAL |
|
!(v->isarr & (SCANPM_MATCHKEY | SCANPM_MATCHVAL |
|
||||||
SCANPM_KEYMATCH))))
|
SCANPM_KEYMATCH))))
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
%prep
|
%prep
|
||||||
|
|
||||||
foo=(a b c d e f g)
|
foo=(a b c d e f g)
|
||||||
|
arr=(foo bar baz)
|
||||||
mkdir array.tmp
|
mkdir array.tmp
|
||||||
touch array.tmp/{1..9}
|
touch array.tmp/{1..9}
|
||||||
|
|
||||||
|
|
@ -60,6 +61,20 @@
|
||||||
0:A slice with a negative start and end
|
0:A slice with a negative start and end
|
||||||
>.b c d e f.
|
>.b c d e f.
|
||||||
|
|
||||||
|
echo .${${arr[2]}[1]}.
|
||||||
|
echo .${${arr[-2]}[1]}.
|
||||||
|
echo .${${arr[2,2]}[1]}.
|
||||||
|
echo .${${arr[-2,-2]}[1]}.
|
||||||
|
echo .${${arr[2,-2]}[1]}.
|
||||||
|
echo .${${arr[-2,2]}[1]}.
|
||||||
|
0:Slices should return an array, elements a scalar
|
||||||
|
>.b.
|
||||||
|
>.b.
|
||||||
|
>.bar.
|
||||||
|
>.bar.
|
||||||
|
>.bar.
|
||||||
|
>.bar.
|
||||||
|
|
||||||
setopt ksh_arrays
|
setopt ksh_arrays
|
||||||
echo .${foo[1,2]}.
|
echo .${foo[1,2]}.
|
||||||
unsetopt ksh_arrays
|
unsetopt ksh_arrays
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue