mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-09-02 10:01:11 +02:00
27243: reverse indexing of arrays with beginning index out of range returned
wrong value
This commit is contained in:
parent
6d4d1261a5
commit
1acf23db3e
3 changed files with 45 additions and 1 deletions
|
@ -1,3 +1,9 @@
|
|||
2009-09-05 Peter Stephenson <p.w.stephenson@ntlworld.com>
|
||||
|
||||
* 27243: Src/params.c, Test/D04parameter.ztst: reverse
|
||||
indexing in array parameters with a beginning index out of range
|
||||
returned the wrong value.
|
||||
|
||||
2009-09-02 Peter Stephenson <pws@csr.com>
|
||||
|
||||
* 27240: Src/builtin.c: 27079 caused later use of tokstr and tok
|
||||
|
@ -12111,5 +12117,5 @@
|
|||
|
||||
*****************************************************
|
||||
* This is used by the shell to define $ZSH_PATCHLEVEL
|
||||
* $Revision: 1.4766 $
|
||||
* $Revision: 1.4767 $
|
||||
*****************************************************
|
||||
|
|
10
Src/params.c
10
Src/params.c
|
@ -1345,6 +1345,11 @@ getarg(char **str, int *inv, Value v, int a2, zlong *w,
|
|||
len = arrlen(ta);
|
||||
if (beg < 0)
|
||||
beg += len;
|
||||
if (down) {
|
||||
if (beg < 0)
|
||||
return 0;
|
||||
} else if (beg >= len)
|
||||
return len + 1;
|
||||
if (beg >= 0 && beg < len) {
|
||||
if (down) {
|
||||
if (!hasbeg)
|
||||
|
@ -1363,6 +1368,11 @@ getarg(char **str, int *inv, Value v, int a2, zlong *w,
|
|||
len = arrlen(ta);
|
||||
if (beg < 0)
|
||||
beg += len;
|
||||
if (down) {
|
||||
if (beg < 0)
|
||||
return 0;
|
||||
} else if (beg >= len)
|
||||
return len + 1;
|
||||
if (beg >= 0 && beg < len) {
|
||||
if (down) {
|
||||
if (!hasbeg)
|
||||
|
|
|
@ -998,6 +998,34 @@
|
|||
>sunny
|
||||
>day
|
||||
|
||||
# ' emacs likes this close quote
|
||||
|
||||
a=(sping spang spong bumble)
|
||||
print ${a[(i)spong]}
|
||||
print ${a[(i)spung]}
|
||||
print ${a[(ib.1.)spong]}
|
||||
print ${a[(ib.4.)spong]}
|
||||
print ${a[(ib.10.)spong]}
|
||||
0:In and out of range reverse matched indices without and with b: arrays
|
||||
>3
|
||||
>5
|
||||
>3
|
||||
>5
|
||||
>5
|
||||
|
||||
a="thrimblewuddlefrong"
|
||||
print ${a[(i)w]}
|
||||
print ${a[(i)x]}
|
||||
print ${a[(ib.3.)w]}
|
||||
print ${a[(ib.10.)w]}
|
||||
print ${a[(ib.30.)w]}
|
||||
0:In and out of range reverse matched indices without and with b: strings
|
||||
>9
|
||||
>20
|
||||
>9
|
||||
>20
|
||||
>20
|
||||
|
||||
foo="line:with::missing::fields:in:it"
|
||||
print -l ${(s.:.)foo}
|
||||
0:Removal of empty fields in unquoted splitting
|
||||
|
|
Loading…
Reference in a new issue