Skip to content

Commit

Permalink
Fix regression in Kernel#inspect encoding negotiation.
Browse files Browse the repository at this point in the history
headius committed Oct 31, 2016

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent a05168b commit 9eee303
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/RubyBasicObject.java
Original file line number Diff line number Diff line change
@@ -1176,7 +1176,7 @@ private RubyString inspectObj(final Ruby runtime, RubyString part) {

if (!first) encStrBufCat(runtime, part, INSPECT_COMMA);
encStrBufCat(runtime, part, INSPECT_SPACE);
encStrBufCat(runtime, part, entry.getKey().getBytes());
encStrBufCat(runtime, part, entry.getKey());
encStrBufCat(runtime, part, INSPECT_EQUALS);
encStrBufCat(runtime, part, sites(context).inspect.call(context, obj, obj).convertToString().getByteList());

10 changes: 10 additions & 0 deletions core/src/main/java/org/jruby/util/io/EncodingUtils.java
Original file line number Diff line number Diff line change
@@ -1647,25 +1647,35 @@ public static void encStrBufCat(Ruby runtime, RubyString str, ByteList ptr, Enco
encCrStrBufCat(runtime, str, ptr.getUnsafeBytes(), ptr.getBegin(), ptr.getRealSize(),
enc, StringSupport.CR_UNKNOWN, null);
}

public static void encStrBufCat(Ruby runtime, RubyString str, ByteList ptr) {
encCrStrBufCat(runtime, str, ptr.getUnsafeBytes(), ptr.getBegin(), ptr.getRealSize(),
ptr.getEncoding(), StringSupport.CR_UNKNOWN, null);
}

public static void encStrBufCat(Ruby runtime, RubyString str, byte[] ptrBytes) {
encCrStrBufCat(runtime, str, ptrBytes, 0, ptrBytes.length, USASCIIEncoding.INSTANCE, StringSupport.CR_UNKNOWN, null);
}

public static void encStrBufCat(Ruby runtime, RubyString str, byte[] ptrBytes, Encoding enc) {
encCrStrBufCat(runtime, str, ptrBytes, 0, ptrBytes.length, enc, StringSupport.CR_UNKNOWN, null);
}

public static void encStrBufCat(Ruby runtime, RubyString str, byte[] ptrBytes, int ptr, int len, Encoding enc) {
encCrStrBufCat(runtime, str, ptrBytes, ptr, len,
enc, StringSupport.CR_UNKNOWN, null);
}

public static void encStrBufCat(Ruby runtime, RubyString str, CharSequence cseq) {
byte[] utf8 = RubyEncoding.encodeUTF8(cseq.toString());
encCrStrBufCat(runtime, str, utf8, 0, utf8.length, UTF8Encoding.INSTANCE, StringSupport.CR_UNKNOWN, null);
}

// rb_enc_cr_str_buf_cat
public static void encCrStrBufCat(Ruby runtime, CodeRangeable str, ByteList ptr, Encoding ptrEnc, int ptr_cr, int[] ptr_cr_ret) {
encCrStrBufCat(runtime, str, ptr.getUnsafeBytes(), ptr.getBegin(), ptr.getRealSize(), ptrEnc, ptr_cr, ptr_cr_ret);
}

public static void encCrStrBufCat(Ruby runtime, CodeRangeable str, byte[] ptrBytes, int ptr, int len, Encoding ptrEnc, int ptr_cr, int[] ptr_cr_ret) {
Encoding strEnc = str.getByteList().getEncoding();
Encoding resEnc;

0 comments on commit 9eee303

Please sign in to comment.