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

Commits on Feb 18, 2016

  1. Fix up ID verification to match 1.9+ logic.

    Fixes MRI TestObject#test_inspect.
    headius committed Feb 18, 2016
    Copy the full SHA
    6761527 View commit details
  2. Don't taint frozen, untainted strings in default to_s logic.

    Fixes an Object#to_s test regression in MRI.
    headius committed Feb 18, 2016
    Copy the full SHA
    c54e70f View commit details
  3. Hash default always returns at least nil, so check nil here.

    Unbreaks my fix for default values in sprintf hash.
    headius committed Feb 18, 2016
    Copy the full SHA
    6b26e1f View commit details
  4. Update Kernel#String logic to try to_str conversion first.

    Fixes MRI TestObject#test_convert_string.
    headius committed Feb 18, 2016
    Copy the full SHA
    e0450e5 View commit details
10 changes: 8 additions & 2 deletions core/src/main/java/org/jruby/RubyKernel.java
Original file line number Diff line number Diff line change
@@ -164,7 +164,7 @@ public static IRubyObject autoload(ThreadContext context, final IRubyObject recv
final Ruby runtime = context.runtime;
final String nonInternedName = symbol.asJavaString();

if (!IdUtil.isValidConstantName(nonInternedName)) {
if (!IdUtil.isValidConstantName19(nonInternedName)) {
throw runtime.newNameError("autoload must be constant name", nonInternedName);
}

@@ -433,7 +433,13 @@ public static IRubyObject new_string(ThreadContext context, IRubyObject recv, IR

@JRubyMethod(name = "String", required = 1, module = true, visibility = PRIVATE)
public static IRubyObject new_string19(ThreadContext context, IRubyObject recv, IRubyObject object) {
return TypeConverter.convertToType19(object, context.runtime.getString(), "to_s");
Ruby runtime = context.runtime;

IRubyObject tmp = TypeConverter.checkStringType(runtime, object);
if (tmp.isNil()) {
tmp = TypeConverter.convertToType19(object, context.runtime.getString(), "to_s");
}
return tmp;
}

// MRI: rb_f_p_internal
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/RubyModule.java
Original file line number Diff line number Diff line change
@@ -3760,7 +3760,7 @@ public IRubyObject fastSetConstant(String internedName, IRubyObject value) {
public void defineConstant(String name, IRubyObject value) {
assert value != null;

if (!IdUtil.isValidConstantName(name)) {
if (!IdUtil.isValidConstantName19(name)) {
throw getRuntime().newNameError("bad constant name " + name, name);
}

4 changes: 3 additions & 1 deletion core/src/main/java/org/jruby/RubyString.java
Original file line number Diff line number Diff line change
@@ -1275,7 +1275,9 @@ public static RubyString objAsString(ThreadContext context, IRubyObject obj) {
if (obj instanceof RubyString) return (RubyString) obj;
IRubyObject str = obj.callMethod(context, "to_s");
if (!(str instanceof RubyString)) return (RubyString) obj.anyToString();
if (obj.isTaint()) str.setTaint(true);
// taint string if it is not untainted and not frozen
// TODO: MRI sets an fstring flag on fstrings and uses that flag here
if (obj.isTaint() && !str.isTaint() && !str.isFrozen()) str.setTaint(true);
return (RubyString) str;
}

8 changes: 4 additions & 4 deletions core/src/main/java/org/jruby/util/IdUtil.java
Original file line number Diff line number Diff line change
@@ -103,7 +103,7 @@ public static boolean isValidInstanceVariableName(String id) {
int len;
if ((len = id.length()) > 1 && '@' == id.charAt(0)) {
if (isInitialCharacter(id.charAt(1))) {
return isNameString(id, 2, len);
return isNameString19(id, 2, len);
}
}
return false;
@@ -113,14 +113,14 @@ public static boolean isValidClassVariableName(String id) {
int len;
if ((len = id.length()) > 2 && '@' == id.charAt(0) && '@' == id.charAt(1)) {
if (isInitialCharacter(id.charAt(2))) {
return isNameString(id, 3, len);
return isNameString19(id, 3, len);
}
}
return false;
}

public static boolean isInitialCharacter(int c) {
return ((c &= ~0x20) <= 'Z' && c >= 'A') || c == '_';
return Character.isAlphabetic(c) || c == '_';
}

public static boolean isNameCharacter(char c) {
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/util/Sprintf.java
Original file line number Diff line number Diff line change
@@ -162,7 +162,7 @@ IRubyObject next(ByteList name) {
// if not found, try dispatching to pick up default hash value
if (object == null) object = rubyHash.callMethod(runtime.getCurrentContext(), "[]", nameSym);

if (object == null) raiseKeyError("key<" + name + "> not found");
if (object.isNil()) raiseKeyError("key<" + name + "> not found");
return object;
} else if (rubyHash != null) {
raiseArgumentError("positional args mixed with named args");