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

Commits on Mar 29, 2015

  1. Copy the full SHA
    bc2f11d View commit details
  2. Copy the full SHA
    bc7660b View commit details
  3. Minor reformat.

    headius committed Mar 29, 2015
    Copy the full SHA
    ea14f4d View commit details
  4. Copy the full SHA
    ce8ba91 View commit details
22 changes: 16 additions & 6 deletions core/src/main/java/org/jruby/RubyString.java
Original file line number Diff line number Diff line change
@@ -2343,7 +2343,7 @@ public IRubyObject sub_bang19(ThreadContext context, IRubyObject arg0, IRubyObje
if (hash.isNil()) {
return subBangNoIter19(runtime, context, pattern, prepared, arg1.convertToString(), regexp);
} else {
return subBangIter19(runtime, context, pattern, prepared, (RubyHash)hash, block, regexp);
return subBangIter19(runtime, context, pattern, prepared, (RubyHash) hash, block, regexp);
}
}

@@ -3456,8 +3456,8 @@ public RubyArray split19(ThreadContext context, IRubyObject arg0, IRubyObject ar
}
}

public RubyArray split19(ThreadContext context, IRubyObject arg0, boolean useBackref) {
return splitCommon19(arg0, useBackref, flags, flags, context, useBackref);
public RubyArray split19(IRubyObject spat, ThreadContext context, boolean useBackref) {
return splitCommon19(spat, false, value.realSize(), 0, context, useBackref);
}

// MRI: rb_str_split_m, overall structure
@@ -3517,8 +3517,9 @@ private RubyArray regexSplit19(ThreadContext context, RubyRegexp pattern, boolea
int end, beg = 0;
boolean lastNull = false;
int start = beg;
while ((end = pattern.search19(context, this, start, false)) >= 0) {
RubyMatchData match = (RubyMatchData)context.getBackRef();
IRubyObject[] holder = useBackref ? null : new IRubyObject[]{context.nil};
while ((end = pattern.search19(context, this, start, false, holder)) >= 0) {
RubyMatchData match = useBackref ? (RubyMatchData)context.getBackRef() : (RubyMatchData)holder[0];
if (start == end && match.begin(0) == match.end(0)) {
if (len == 0) {
result.append(newEmptyString(runtime, getMetaClass()).infectBy(this));
@@ -3547,7 +3548,11 @@ private RubyArray regexSplit19(ThreadContext context, RubyRegexp pattern, boolea
}

// only this case affects backrefs
if (useBackref) context.setBackRef(runtime.getNil());
if (useBackref) {
context.setBackRef(runtime.getNil());
} else {
holder[0] = context.nil;
}

if (len > 0 && (limit || len > beg || lim < 0)) result.append(makeShared19(runtime, beg, len - beg));
return result;
@@ -6019,4 +6024,9 @@ final RubyString strDup(RubyClass clazz) {
public final void modify19(int length) {
modifyExpand(length);
}

@Deprecated
public RubyArray split19(ThreadContext context, IRubyObject arg0, boolean useBackref) {
return splitCommon19(arg0, useBackref, flags, flags, context, useBackref);
}
}
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/util/StringSupport.java
Original file line number Diff line number Diff line change
@@ -911,7 +911,7 @@ public static int rindex(ByteList source, int sourceChars, int subChars, int pos
}

int s = nth(enc, sourceBytes, sbeg, end, pos);
byte[] subBytes = subString.bytes();
byte[] subBytes = subString.unsafeBytes();

// switch to byte size here; this is now MRI:str_rindex
if (subSize == 0) return pos;
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/util/TypeConverter.java
Original file line number Diff line number Diff line change
@@ -299,7 +299,7 @@ public static void checkType(ThreadContext context, IRubyObject x, RubyModule t)
if (xt != t.getClassIndex()) {
String tname = t.getBaseName();
if (tname != null) {
throw context.runtime.newArgumentError("wrong argument type " + xt + " (expected " + t.getClassIndex());
throw context.runtime.newTypeError("wrong argument type " + tname + " (expected " + t.getName() + ")");
}
throw context.runtime.newRuntimeError("bug: unknown type " + t.getClassIndex() + " (" + xt + " given)");
}