Skip to content

Commit 62c76ac

Browse files
committed
Merge branch 'master' into truffle-head
Conflicts: truffle/src/main/java/org/jruby/truffle/nodes/RubyNode.java truffle/src/main/java/org/jruby/truffle/nodes/core/ArrayNodes.java
2 parents 86858cc + 44ab7cc commit 62c76ac

File tree

105 files changed

+317
-357
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

105 files changed

+317
-357
lines changed

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

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4148,39 +4148,19 @@ public IRubyObject chop_bang(ThreadContext context) {
41484148
public IRubyObject chop19(ThreadContext context) {
41494149
Ruby runtime = context.runtime;
41504150
if (value.getRealSize() == 0) return newEmptyString(runtime, getMetaClass(), value.getEncoding()).infectBy(this);
4151-
return makeShared19(runtime, 0, choppedLength19(runtime));
4151+
return makeShared19(runtime, 0, StringSupport.choppedLength19(this, runtime));
41524152
}
41534153

41544154
@JRubyMethod(name = "chop!")
41554155
public IRubyObject chop_bang19(ThreadContext context) {
41564156
modifyCheck();
41574157
Ruby runtime = context.runtime;
41584158
if (value.getRealSize() == 0) return runtime.getNil();
4159-
view(0, choppedLength19(runtime));
4159+
view(0, StringSupport.choppedLength19(this, runtime));
41604160
if (getCodeRange() != CR_7BIT) clearCodeRange();
41614161
return this;
41624162
}
41634163

4164-
private int choppedLength19(Ruby runtime) {
4165-
int p = value.getBegin();
4166-
int end = p + value.getRealSize();
4167-
4168-
if (p > end) return 0;
4169-
byte bytes[] = value.getUnsafeBytes();
4170-
Encoding enc = value.getEncoding();
4171-
4172-
int s = enc.prevCharHead(bytes, p, end, end);
4173-
if (s == -1) return 0;
4174-
if (s > p && codePoint(runtime, enc, bytes, s, end) == '\n') {
4175-
int s2 = enc.prevCharHead(bytes, p, s, end);
4176-
if (s2 != -1 && codePoint(runtime, enc, bytes, s2, end) == '\r') s = s2;
4177-
}
4178-
return s - p;
4179-
}
4180-
4181-
/** rb_str_chop
4182-
*
4183-
*/
41844164
public RubyString chomp(ThreadContext context) {
41854165
return chomp19(context);
41864166
}

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1324,4 +1324,25 @@ public static CodeRangeable delete_bangCommon19(CodeRangeable rubyString, Ruby r
13241324

13251325
return modify ? rubyString : null;
13261326
}
1327+
1328+
/**
1329+
* rb_str_chop
1330+
*/
1331+
public static int choppedLength19(CodeRangeable rubyString, Ruby runtime) {
1332+
final ByteList value = rubyString.getByteList();
1333+
int p = value.getBegin();
1334+
int end = p + value.getRealSize();
1335+
1336+
if (p > end) return 0;
1337+
byte bytes[] = value.getUnsafeBytes();
1338+
Encoding enc = value.getEncoding();
1339+
1340+
int s = enc.prevCharHead(bytes, p, end, end);
1341+
if (s == -1) return 0;
1342+
if (s > p && codePoint(runtime, enc, bytes, s, end) == '\n') {
1343+
int s2 = enc.prevCharHead(bytes, p, s, end);
1344+
if (s2 != -1 && codePoint(runtime, enc, bytes, s2, end) == '\r') s = s2;
1345+
}
1346+
return s - p;
1347+
}
13271348
}

lib/ruby/truffle/shims/stringio.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010

1111
class StringIO
1212

13-
def initialize(string, mode)
14-
@lines = string.split(/\n/).reject { |line| line.empty? }
13+
def initialize(string=nil, mode=nil)
14+
@lines = (string || '').split(/\n/).reject { |line| line.empty? }
1515
end
1616

1717
def gets

spec/truffle/tags/core/array/delete_at_tags.txt

Lines changed: 0 additions & 2 deletions
This file was deleted.
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
fails:Array#hash returns the same hash for equal recursive arrays
22
fails:Array#hash returns the same hash for equal recursive arrays through hashes
33
fails:Array#hash calls to_int on result of calling hash on each element
4-
fails:Array#hash returns same hash code for arrays with the same content
5-
fails:Array#hash returns the same value if arrays are #eql?
64
fails:Array#hash properly handles recursive arrays

spec/truffle/tags/core/array/sort_tags.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
fails:Array#sort sorts reverse-sorted Arrays
21
fails:Array#sort may take a block which is used to determine the order of objects a and b described as -1, 0 or +1
32
fails:Array#sort raises an error when a given block returns nil
43
fails:Array#sort completes when supplied a block that always returns the same result

spec/truffle/tags/core/array/to_h_tags.txt

Lines changed: 0 additions & 4 deletions
This file was deleted.
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
fails:BasicObject#instance_exec is a public instance method
21
fails:BasicObject#instance_exec sets self to the receiver in the context of the passed block
32
fails:BasicObject#instance_exec passes arguments to the block

spec/truffle/tags/core/enumerable/collect_concat_tags.txt

Lines changed: 0 additions & 4 deletions
This file was deleted.

spec/truffle/tags/core/enumerable/flat_map_tags.txt

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)