mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Fix double rounded by negative index
- Before patched:
```
$ mruby -e 'p (-12..-1).map { |i| "Hello"[i] }.join'
"HelloHello"
```
- After patched:
```
$ mruby -e 'p (-12..-1).map { |i| "Hello"[i] }.join'
"Hello"
```
This commit is contained in:
@@ -449,9 +449,6 @@ str_substr(mrb_state *mrb, mrb_value str, mrb_int beg, mrb_int len)
|
||||
if (clen == 0) {
|
||||
len = 0;
|
||||
}
|
||||
else if (beg < 0) {
|
||||
beg = clen + beg;
|
||||
}
|
||||
if (beg > clen) return mrb_nil_value();
|
||||
if (beg < 0) {
|
||||
beg += clen;
|
||||
|
||||
Reference in New Issue
Block a user