1
0
mirror of git://git.code.sf.net/p/zsh/code synced 2024-09-21 19:31:50 +02:00

21701: Negative subscripts of scalars before start were broken

This commit is contained in:
Peter Stephenson 2005-09-06 15:28:17 +00:00
parent 394ab0aeb7
commit f2d873d811
3 changed files with 14 additions and 1 deletions

View File

@ -1,3 +1,8 @@
2005-09-06 Peter Stephenson <pws@csr.com>
* 21701: Src/params.c, Test/D06subscript.ztst: negative offsets
that indexed before the start of a scalar weren't handled properly.
2005-09-05 Peter Stephenson <pws@csr.com>
* 21698: Jean-Baptiste Quenot: Completion/Unix/Command/_ant:

View File

@ -1565,8 +1565,11 @@ getstrvalue(Value v)
if (v->start == 0 && v->end == -1)
return s;
if (v->start < 0)
if (v->start < 0) {
v->start += strlen(s);
if (v->start < 0)
v->start = 0;
}
if (v->end < 0)
v->end += strlen(s) + 1;
s = (v->start > (int)strlen(s)) ? dupstring("") : dupstring(s + v->start);

View File

@ -178,3 +178,8 @@
0:Keys with double quotes and the (P) expansion flag
>lower
>upper
typeset -a empty_array
echo X${${l##*}[-1]}X
0:Negative index applied to substition result from empty array
>XX