diff options
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | Src/params.c | 10 | ||||
-rw-r--r-- | Test/D04parameter.ztst | 28 |
3 files changed, 45 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog index 8ecc79fe9..32bf838bf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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 $ ***************************************************** diff --git a/Src/params.c b/Src/params.c index 4767aaa34..0425e0700 100644 --- a/Src/params.c +++ b/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) diff --git a/Test/D04parameter.ztst b/Test/D04parameter.ztst index 358b46ef7..59fa3ac91 100644 --- a/Test/D04parameter.ztst +++ b/Test/D04parameter.ztst @@ -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 |