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: 707142995357
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 6601be9dda32
Choose a head ref
  • 3 commits
  • 2 files changed
  • 1 contributor

Commits on Jan 10, 2017

  1. Copy the full SHA
    27b7557 View commit details
  2. Copy the full SHA
    b0cf77b View commit details
  3. [Truffle] Fix to yield only the invalid characters for ASCII-incompat…

    …ible encodings in String#scrub.
    
    * JRuby and MRI seem incorrect here, they completely ignore the block given to #scrub.
    eregon committed Jan 10, 2017
    Copy the full SHA
    6601be9 View commit details
Showing with 5 additions and 9 deletions.
  1. +1 −1 spec/ruby/core/string/scrub_spec.rb
  2. +4 −8 truffle/src/main/java/org/jruby/truffle/core/string/StringNodes.java
2 changes: 1 addition & 1 deletion spec/ruby/core/string/scrub_spec.rb
Original file line number Diff line number Diff line change
@@ -39,7 +39,7 @@
"abc\u3042#{x81}".scrub("*").should == "abc\u3042*"
end

it "replaces groups of sequences together with a single replacement" do
it "replaces and incomplete character at the end with a single replacement" do
xE3x80 = [0xE3, 0x80].pack('CC').force_encoding 'utf-8'
xE3x80.scrub("*").should == "*"
end
Original file line number Diff line number Diff line change
@@ -1415,8 +1415,7 @@ public DynamicObject scrubAsciiCompat(VirtualFrame frame, DynamicObject string,
}
}
}
Rope invalid = RopeOperations.create(ArrayUtils.extractRange(pBytes, p, p + clen), enc, CodeRange.CR_BROKEN);
DynamicObject repl = (DynamicObject) yield(frame, block, createString(invalid));
DynamicObject repl = (DynamicObject) yield(frame, block, createString(makeSubstringNode.executeMake(rope, p, clen)));
buf = makeConcatNode.executeMake(buf, rope(repl), enc);
p += clen;
p1 = p;
@@ -1431,8 +1430,7 @@ public DynamicObject scrubAsciiCompat(VirtualFrame frame, DynamicObject string,
buf = makeConcatNode.executeMake(buf, makeSubstringNode.executeMake(rope, p1, p - p1), enc);
}
if (p < e) {
Rope invalid = RopeOperations.create(ArrayUtils.extractRange(pBytes, p, e), enc, CodeRange.CR_BROKEN);
DynamicObject repl = (DynamicObject) yield(frame, block, createString(invalid));
DynamicObject repl = (DynamicObject) yield(frame, block, createString(makeSubstringNode.executeMake(rope, p, e - p)));
buf = makeConcatNode.executeMake(buf, rope(repl), enc);
}

@@ -1483,8 +1481,7 @@ public DynamicObject scrubAscciIncompatible(VirtualFrame frame, DynamicObject st
}
}

Rope invalid = RopeOperations.create(ArrayUtils.extractRange(pBytes, p, e), enc, CodeRange.CR_BROKEN);
DynamicObject repl = (DynamicObject) yield(frame, block, createString(invalid));
DynamicObject repl = (DynamicObject) yield(frame, block, createString(makeSubstringNode.executeMake(rope, p, clen)));
buf = makeConcatNode.executeMake(buf, rope(repl), enc);
p += clen;
p1 = p;
@@ -1494,8 +1491,7 @@ public DynamicObject scrubAscciIncompatible(VirtualFrame frame, DynamicObject st
buf = makeConcatNode.executeMake(buf, makeSubstringNode.executeMake(rope, p1, p - p1), enc);
}
if (p < e) {
Rope invalid = RopeOperations.create(ArrayUtils.extractRange(pBytes, p, e), enc, CodeRange.CR_BROKEN);
DynamicObject repl = (DynamicObject) yield(frame, block, createString(invalid));
DynamicObject repl = (DynamicObject) yield(frame, block, createString(makeSubstringNode.executeMake(rope, p, e - p)));
buf = makeConcatNode.executeMake(buf, rope(repl), enc);
}