Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: c9c239074447
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: b840fcb19a88
Choose a head ref
  • 3 commits
  • 2 files changed
  • 1 contributor

Commits on Jul 2, 2015

  1. [Truffle] Fixed the starting byte location being used in the wrong ar…

    …gument in the :string_character_byte_index primitive.
    nirvdrum committed Jul 2, 2015
    Copy the full SHA
    5ef6c72 View commit details
  2. [Truffle] The :string_character_byte_index primitive should always ta…

    …ke as input and return as output, zero-offset indices.
    
    ByteLists with 'begin' values > 0 are an implementation detail and should be handled internally only.
    nirvdrum committed Jul 2, 2015
    Copy the full SHA
    f49d172 View commit details
  3. [Truffle] Use unsafe bytes in the :regexp_search_region primitive to …

    …be consistent with the MatchData calculations.
    nirvdrum committed Jul 2, 2015
    Copy the full SHA
    b840fcb View commit details
Original file line number Diff line number Diff line change
@@ -138,19 +138,20 @@ public Object searchRegionInvalidEncoding(RubyRegexp regexp, RubyString string,
@TruffleBoundary
@Specialization(guards = { "isInitialized(regexp)", "isValidEncoding(string)" })
public Object searchRegion(RubyRegexp regexp, RubyString string, int start, int end, boolean forward) {
final ByteList stringBl = StringNodes.getByteList(string);
final ByteList bl = regexp.getSource();
final Encoding enc = regexp.checkEncoding(StringNodes.getCodeRangeable(string), true);
final ByteList preprocessed = RegexpSupport.preprocess(getContext().getRuntime(), bl, enc, new Encoding[]{null}, RegexpSupport.ErrorMode.RAISE);

final Regex r = new Regex(preprocessed.getUnsafeBytes(), preprocessed.getBegin(), preprocessed.getBegin() + preprocessed.getRealSize(), regexp.getRegex().getOptions(), regexp.checkEncoding(StringNodes.getCodeRangeable(string), true));
final Matcher matcher = r.matcher(StringNodes.getByteList(string).bytes());
final Matcher matcher = r.matcher(stringBl.getUnsafeBytes(), stringBl.begin(), stringBl.begin() + stringBl.realSize());

if (forward) {
// Search forward through the string.
return regexp.matchCommon(string, false, false, matcher, start, end);
return regexp.matchCommon(string, false, false, matcher, start + stringBl.begin(), end + stringBl.begin());
} else {
// Search backward through the string.
return regexp.matchCommon(string, false, false, matcher, end, start);
return regexp.matchCommon(string, false, false, matcher, end + stringBl.begin(), start + stringBl.begin());
}
}

Original file line number Diff line number Diff line change
@@ -648,8 +648,8 @@ public int stringCharacterByteIndex(RubyString string, int index, int start) {
public int stringCharacterByteIndexMultiByteEncoding(RubyString string, int index, int start) {
final ByteList bytes = StringNodes.getByteList(string);

return StringSupport.nth(bytes.getEncoding(), bytes.getUnsafeBytes(), bytes.getBegin(),
bytes.getBegin() + bytes.getRealSize(), start + index);
return StringSupport.nth(bytes.getEncoding(), bytes.getUnsafeBytes(), bytes.getBegin() + start,
bytes.getBegin() + bytes.getRealSize(), index) - bytes.begin();
}
}