Skip to content

Commit 2442c94

Browse files
committed
Merge remote-tracking branch 'origin/jruby-1_7'
2 parents c3d9dea + 899b638 commit 2442c94

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

core/src/main/java/org/jruby/RubyString.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1599,7 +1599,7 @@ private IRubyObject multiByteCasecmp(Ruby runtime, Encoding enc, ByteList value,
15991599
}
16001600

16011601
int cl, ocl;
1602-
if (Encoding.isAscii(c) && Encoding.isAscii(oc)) {
1602+
if (enc.isAsciiCompatible() && Encoding.isAscii(c) && Encoding.isAscii(oc)) {
16031603
byte uc = AsciiTables.ToUpperCaseTable[c];
16041604
byte uoc = AsciiTables.ToUpperCaseTable[oc];
16051605
if (uc != uoc) {

core/src/main/java/org/jruby/util/StringSupport.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ public static long getAscii(Encoding enc, byte[]bytes, int p, int end, int len)
381381

382382
public static int preciseCodePoint(Encoding enc, byte[]bytes, int p, int end) {
383383
int l = preciseLength(enc, bytes, p, end);
384-
if (l > 0) enc.mbcToCode(bytes, p, end);
384+
if (l > 0) return enc.mbcToCode(bytes, p, end);
385385
return -1;
386386
}
387387

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# https://github.com/jruby/jruby/issues/1675
2+
if RUBY_VERSION > '1.9'
3+
describe 'String#casecmp' do
4+
it 'returns correct value' do
5+
Encoding.name_list.each do |enc_name|
6+
if (enc_name != "UTF-7") && (enc_name != "CP65000")
7+
# this condition statement escape the following error:
8+
# Encoding::ConverterNotFoundError:
9+
# code converter not found for UTF-7
10+
11+
# using "UTF-16LE", "UTF-8", "Shift_JIS", and other available encodings
12+
a = 'ABC'.encode(enc_name)
13+
b = 'ABC'.encode(enc_name)
14+
b.casecmp(a).should be_true
15+
end
16+
end
17+
end
18+
end
19+
end

0 commit comments

Comments
 (0)