Skip to content

Commit

Permalink
[Truffle] Fixed a failing case with String#[](Regexp).
Browse files Browse the repository at this point in the history
  • Loading branch information
nirvdrum committed Mar 3, 2015
1 parent 1b9fded commit 17ae6b4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 0 additions & 3 deletions spec/truffle/tags/core/string/slice_tags.txt
@@ -1,6 +1,4 @@
fails:String#slice with index, length returns subclass instances
fails:String#slice with Range returns an empty string if range.begin is inside self and > real end
fails:String#slice with Range always taints resulting strings when self is tainted
fails:String#slice with Range returns subclass instances
fails:String#slice with Range calls to_int on range arguments
fails:String#slice with Range works with Range subclasses
Expand All @@ -21,7 +19,6 @@ fails:String#slice! with index, length always taints resulting strings when self
fails:String#slice! with index, length calls to_int on idx and length
fails:String#slice! with index, length returns subclass instances
fails:String#slice! with index, length returns the substring given by the character offsets
fails:String#slice! Range deletes and return the substring given by the offsets of the range
fails:String#slice! Range returns subclass instances
fails:String#slice! Range calls to_int on range arguments
fails:String#slice! Range works with Range subclasses
Expand Down
Expand Up @@ -336,6 +336,10 @@ public Object slice(RubyString string, RubyRange.IntegerFixnumRange range, @Supp
final int end = string.normalizeIndex(range.getEnd());
final int excludingEnd = string.clampExclusiveIndex(range.doesExcludeEnd() ? end : end+1);

if (begin > excludingEnd) {
return getContext().makeString("");
}

return getContext().makeString(javaString.substring(begin, excludingEnd), string.getByteList().getEncoding());
}
}
Expand Down

0 comments on commit 17ae6b4

Please sign in to comment.