Skip to content

Commit 27bc873

Browse files
committed
handle off the end start in jvm's index/rindex
1 parent ce657bf commit 27bc873

File tree

1 file changed

+2
-0
lines changed
  • src/vm/jvm/runtime/org/perl6/nqp/runtime

1 file changed

+2
-0
lines changed

src/vm/jvm/runtime/org/perl6/nqp/runtime/Ops.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3548,6 +3548,7 @@ public static SixModelObject split(String delimiter, String string, ThreadContex
35483548
}
35493549

35503550
public static long indexfrom(String string, String pattern, long fromIndex) {
3551+
if (fromIndex > string.length()) { return -1; }
35513552
return string.indexOf(pattern, (int)fromIndex);
35523553
}
35533554

@@ -3556,6 +3557,7 @@ public static long rindexfromend(String string, String pattern) {
35563557
}
35573558

35583559
public static long rindexfrom(String string, String pattern, long fromIndex) {
3560+
if (fromIndex > string.length()) { return -1; }
35593561
return string.lastIndexOf(pattern, (int)fromIndex);
35603562
}
35613563

0 commit comments

Comments
 (0)