mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-01-31 23:35:17 +08:00
parent
44f2f37bd4
commit
897dba9f07
|
@ -650,7 +650,7 @@ static size_t parse_slice(const wchar_t *in, wchar_t **end_ptr, std::vector<long
|
|||
}
|
||||
// debug( 0, L"Push idx %d", tmp );
|
||||
|
||||
long i1 = tmp > -1 ? tmp : (long)array_size + tmp + 1;
|
||||
long i1 = tmp > -1 ? tmp : size + tmp + 1;
|
||||
pos = end - in;
|
||||
while (in[pos] == INTERNAL_SEPARATOR) pos++;
|
||||
if (in[pos] == L'.' && in[pos + 1] == L'.') {
|
||||
|
@ -667,6 +667,13 @@ static size_t parse_slice(const wchar_t *in, wchar_t **end_ptr, std::vector<long
|
|||
|
||||
// debug( 0, L"Push range %d %d", tmp, tmp1 );
|
||||
long i2 = tmp1 > -1 ? tmp1 : size + tmp1 + 1;
|
||||
// Clamp to array size, but only when doing a range,
|
||||
// and only when just one is too high.
|
||||
if (i1 > size && i2 > size) {
|
||||
continue;
|
||||
}
|
||||
i1 = i1 < size ? i1 : size;
|
||||
i2 = i2 < size ? i2 : size;
|
||||
// debug( 0, L"Push range idx %d %d", i1, i2 );
|
||||
short direction = i2 < i1 ? -1 : 1;
|
||||
for (long jjj = i1; jjj * direction <= i2 * direction; jjj += direction) {
|
||||
|
|
|
@ -80,6 +80,10 @@ show "$foo[1 2]"
|
|||
show $foo[1 2]
|
||||
show "$foo[2 1]"
|
||||
show $foo[2 1]
|
||||
set -l foo a b c
|
||||
show $foo[17]
|
||||
show $foo[-17]
|
||||
show $foo[17..18]
|
||||
|
||||
echo "$foo[d]"
|
||||
echo $foo[d]
|
||||
|
|
|
@ -52,5 +52,8 @@
|
|||
0
|
||||
1
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
|
||||
Catch your breath
|
||||
|
|
Loading…
Reference in New Issue
Block a user