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

Commits on Feb 23, 2016

  1. Copy the full SHA
    b1652d9 View commit details
  2. Guard nils from format hash.

    headius committed Feb 23, 2016
    Copy the full SHA
    26e4325 View commit details
  3. Copy the full SHA
    484ccc3 View commit details
Showing with 18 additions and 3 deletions.
  1. +10 −1 core/src/main/java/org/jruby/RubyNumeric.java
  2. +3 −2 core/src/main/java/org/jruby/RubyString.java
  3. +5 −0 core/src/main/java/org/jruby/util/Sprintf.java
11 changes: 10 additions & 1 deletion core/src/main/java/org/jruby/RubyNumeric.java
Original file line number Diff line number Diff line change
@@ -51,6 +51,7 @@
import org.jruby.util.ByteList;
import org.jruby.util.ConvertBytes;
import org.jruby.util.ConvertDouble;
import org.jruby.util.TypeConverter;

import java.math.BigInteger;

@@ -267,10 +268,18 @@ public static double num2dbl(IRubyObject arg) {
}
}

IRubyObject val = f_to_f(runtime.getCurrentContext(), arg);
IRubyObject val = numericToFloat(runtime, arg);
return ((RubyFloat) val).getDoubleValue();
}

private static IRubyObject numericToFloat(Ruby runtime, IRubyObject num) {
if (!(num instanceof RubyNumeric)) {
throw runtime.newTypeError("can't convert " + num.getType() + " into Float");
}

return TypeConverter.convertToType(num, runtime.getFloat(), "to_f");
}

/** rb_dbl_cmp (numeric.c)
*
*/
5 changes: 3 additions & 2 deletions core/src/main/java/org/jruby/RubyString.java
Original file line number Diff line number Diff line change
@@ -1467,7 +1467,7 @@ public RubyString reverse_bang19(ThreadContext context) {

Encoding enc = value.getEncoding();
// this really needs to be inlined here
if (singleByteOptimizable(enc)) {
if (singleByteOptimizable()) {
for (int i = 0; i < len >> 1; i++) {
byte b = bytes[p + i];
bytes[p + i] = bytes[p + len - i - 1];
@@ -1476,12 +1476,13 @@ public RubyString reverse_bang19(ThreadContext context) {
} else if (cr == CR_VALID) {
byte[] obytes = new byte[len];
while (p < end) {
int cl = StringSupport.length(enc, bytes, p, end);
int cl = StringSupport.encFastMBCLen(bytes, p, end, enc);

op -= cl;
System.arraycopy(bytes, p, obytes, op, cl);
p += cl;
}
value.setUnsafeBytes(obytes);
} else {
byte[] obytes = new byte[len];
cr = enc.isAsciiCompatible() ? CR_7BIT : CR_VALID;
5 changes: 5 additions & 0 deletions core/src/main/java/org/jruby/util/Sprintf.java
Original file line number Diff line number Diff line change
@@ -170,6 +170,11 @@ IRubyObject next(ByteList name) {
object = object.callMethod(runtime.getCurrentContext(), "call", nameSym);
}
}

if (object.isNil()) {
throw runtime.newKeyError("key " + nameSym + " not found");
}

return object;
} else if (rubyHash != null) {
raiseArgumentError("positional args mixed with named args");