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

Commits on Apr 7, 2015

  1. Copy the full SHA
    5e01376 View commit details
  2. Copy the full SHA
    8b29992 View commit details
  3. Copy the full SHA
    9bba871 View commit details

This file was deleted.

1 change: 0 additions & 1 deletion spec/truffle/tags/core/encoding/converter/convert_tags.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
fails:Encoding::Converter#convert raises UndefinedConversionError if the String contains characters invalid for the target encoding
fails:Encoding::Converter#convert raises an ArgumentError if called on a finished stream
2 changes: 0 additions & 2 deletions spec/truffle/tags/core/encoding/converter/last_error_tags.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
fails:Encoding::Converter#last_error returns an Encoding::InvalidByteSequenceError when #primitive_convert last returned :invalid_byte_sequence
fails:Encoding::Converter#last_error returns an Encoding::UndefinedConversionError when #primitive_convert last returned :undefined_conversion
fails:Encoding::Converter#last_error returns an Encoding::InvalidByteSequenceError when the last call to #convert produced one
fails:Encoding::Converter#last_error returns an Encoding::UndefinedConversionError when the last call to #convert produced one

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
fails:Encoding::UndefinedConversionError#error_char returns a String
fails:Encoding::UndefinedConversionError#error_char returns the one-character String that caused the exception
fails:Encoding::UndefinedConversionError#error_char uses the source encoding

This file was deleted.

This file was deleted.

8 changes: 4 additions & 4 deletions spec/truffle/tags/core/string/encode_tags.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
fails:String#encode given the :xml => :text option replaces undefined characters with their upper-case hexadecimal numeric character references
fails:String#encode given the :xml => :attr option replaces undefined characters with their upper-case hexadecimal numeric character references
fails:String#encode! given the :xml => :text option replaces undefined characters with their upper-case hexadecimal numeric character references
fails:String#encode! given the :xml => :attr option replaces undefined characters with their upper-case hexadecimal numeric character references
fails(inherited - rubinius):String#encode given the :xml => :text option replaces undefined characters with their upper-case hexadecimal numeric character references
fails(inherited - rubinius):String#encode given the :xml => :attr option replaces undefined characters with their upper-case hexadecimal numeric character references
fails(inherited - rubinius):String#encode! given the :xml => :text option replaces undefined characters with their upper-case hexadecimal numeric character references
fails(inherited - rubinius):String#encode! given the :xml => :attr option replaces undefined characters with their upper-case hexadecimal numeric character references
Original file line number Diff line number Diff line change
@@ -17,27 +17,20 @@
import org.jcodings.Encoding;
import org.jcodings.EncodingDB;
import org.jcodings.transcode.EConv;
import org.jcodings.transcode.Transcoder;
import org.jcodings.transcode.EConvFlags;
import org.jcodings.transcode.TranscoderDB;
import org.jcodings.util.CaseInsensitiveBytesHash;
import org.jcodings.util.Hash;
import org.jruby.Ruby;
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.Visibility;
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.truffle.nodes.dispatch.CallDispatchHeadNode;
import org.jruby.truffle.nodes.dispatch.DispatchHeadNodeFactory;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.UndefinedPlaceholder;
import org.jruby.truffle.runtime.core.*;
import org.jruby.truffle.runtime.hash.HashOperations;
import org.jruby.truffle.runtime.hash.KeyValue;
import org.jruby.util.ByteList;
import org.jruby.util.io.EncodingUtils;

import java.util.ArrayList;
import java.util.List;

@CoreClass(name = "Encoding::Converter")
public abstract class EncodingConverterNodes {

@@ -75,7 +68,7 @@ public RubyNilClass initialize(RubyEncodingConverter self, Object source, Object
// by Rubinius. Rubinius will do the heavy lifting of parsing the options hash and setting the `@options`
// ivar to the resulting int for EConv flags. Since we don't pass the proper data structures to EncodingUtils,
// we must override the flags after its had a pass in order to correct the bad flags value.
ecflags[0] = (int) self.getInstanceVariable("@options");
ecflags[0] = rubiniusToJRubyFlags((int) self.getInstanceVariable("@options"));

EConv econv = EncodingUtils.econvOpenOpts(runtime.getCurrentContext(), encNames[0], encNames[1], ecflags[0], ecopts[0]);

@@ -100,6 +93,23 @@ public RubyNilClass initialize(RubyEncodingConverter self, Object source, Object
return nil();
}

/**
* Rubinius and JRuby process Encoding::Converter options flags differently. Rubinius splits the processing
* between initial setup and the replacement value setup, whereas JRuby handles them all during initial setup.
* We figure out what flags JRuby additionally expects to be set and set them to satisfy EConv.
*/
private int rubiniusToJRubyFlags(int flags) {
if ((flags & EConvFlags.XML_TEXT_DECORATOR) != 0) {
flags |= EConvFlags.UNDEF_HEX_CHARREF;
}

if ((flags & EConvFlags.XML_ATTR_CONTENT_DECORATOR) != 0) {
flags |= EConvFlags.UNDEF_HEX_CHARREF;
}

return flags;
}

}

@RubiniusOnly