Skip to content

Commit

Permalink
Merge branch 'master' into bytelist_love
Browse files Browse the repository at this point in the history
  • Loading branch information
enebo committed Apr 24, 2018
2 parents 2683c35 + b0f614c commit 135da97
Show file tree
Hide file tree
Showing 15 changed files with 32 additions and 20 deletions.
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/Ruby.java
Expand Up @@ -730,7 +730,7 @@ private RootNode addGetsLoop(RootNode oldRoot, boolean printing, boolean process
BlockNode whileBody = new BlockNode(pos);
newBody.add(new WhileNode(pos, new VCallNode(pos, newSymbol("gets")), whileBody));

if (processLineEndings) whileBody.add(new CallNode(pos, dollarUnderscore, newSymbol("chop!"), null, null, false));
if (processLineEndings) whileBody.add(new CallNode(pos, dollarUnderscore, newSymbol("chomp!"), null, null, false));
if (split) whileBody.add(new GlobalAsgnNode(pos, newSymbol("$F"), new CallNode(pos, dollarUnderscore, newSymbol("split"), null, null, false)));

if (oldRoot.getBodyNode() instanceof BlockNode) { // common case n stmts
Expand Down
8 changes: 6 additions & 2 deletions core/src/main/java/org/jruby/RubyKernel.java
Expand Up @@ -1222,7 +1222,11 @@ public static IRubyObject warn(ThreadContext context, IRubyObject recv, IRubyObj
message = (RubyString) message.op_plus19(context, runtime.newString("\n"));
}

return sites(context).warn.call(context, recv, runtime.getWarning(), message);
if (recv == runtime.getWarning()) {
return RubyWarnings.warn(context, recv, message);
} else {
return sites(context).warn.call(context, recv, runtime.getWarning(), message);
}
}

public static final String[] WARN_VALID_KEYS = {"uplevel"};
Expand Down Expand Up @@ -1254,7 +1258,7 @@ public static IRubyObject warn(ThreadContext context, IRubyObject recv, IRubyObj

int index = uplevel + 1;
RubyString baseMessage = context.runtime.newString();
baseMessage.catString(elements[index].getFileName() + ":" + (elements[index].getLineNumber()) + " warning: ");
baseMessage.catString(elements[index].getFileName() + ":" + (elements[index].getLineNumber()) + ": warning: ");

for (int i = 0; i < numberOfMessages; i++) {
warn(context, recv, baseMessage.op_plus19(context, args[i]));
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/java/org/jruby/RubyString.java
Expand Up @@ -1141,9 +1141,9 @@ private IRubyObject op_equalCommon(ThreadContext context, IRubyObject other) {
return sites(context).equals.call(context, this, other, this).isTrue() ? runtime.getTrue() : runtime.getFalse();
}

@JRubyMethod(name = "-@") // -'foo' returns frozen string
@JRubyMethod(name = "-@") // -'foo' returns deduplicated (interned) string
public final IRubyObject minus_at(ThreadContext context) {
return isFrozen() ? this : context.runtime.freezeAndDedupString(this);
return context.runtime.freezeAndDedupString(this);
}

@JRubyMethod(name = "+@") // +'foo' returns modifiable string
Expand Down
6 changes: 4 additions & 2 deletions core/src/main/java/org/jruby/RubySymbol.java
Expand Up @@ -50,6 +50,7 @@
import org.jruby.runtime.CallSite;
import org.jruby.runtime.ClassIndex;
import org.jruby.runtime.ContextAwareBlockBody;
import org.jruby.runtime.Helpers;
import org.jruby.runtime.MethodIndex;
import org.jruby.runtime.ObjectAllocator;
import org.jruby.runtime.Signature;
Expand Down Expand Up @@ -108,10 +109,11 @@ private RubySymbol(Ruby runtime, String internedSymbol, ByteList symbolBytes) {
this.symbolBytes = symbolBytes;
this.id = runtime.allocSymbolId();

long k0 = Helpers.hashStart(runtime, id);
long hash = runtime.isSiphashEnabled() ? SipHashInline.hash24(
symbolHashSeedK0, 0, symbolBytes.getUnsafeBytes(),
k0, 0, symbolBytes.getUnsafeBytes(),
symbolBytes.getBegin(), symbolBytes.getRealSize()) :
PerlHash.hash(symbolHashSeedK0, symbolBytes.getUnsafeBytes(),
PerlHash.hash(k0, symbolBytes.getUnsafeBytes(),
symbolBytes.getBegin(), symbolBytes.getRealSize());
this.hashCode = (int) hash;
setFrozen(true);
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/ext/ripper/RipperParser.java
Expand Up @@ -2772,7 +2772,7 @@ public Object yyparse (RipperLexer yyLex) throws java.io.IOException {
};
states[266] = new RipperParserState() {
@Override public Object execute(RipperParser p, Object yyVal, Object[] yyVals, int yyTop) {
p.warning("comparison '" + ((IRubyObject)yyVals[-1+yyTop]) + "%s' after comparison");
p.warning("comparison '" + ((IRubyObject)yyVals[-1+yyTop]) + "' after comparison");
yyVal = p.dispatch("on_binary", ((IRubyObject)yyVals[-2+yyTop]), p.intern(">"), ((IRubyObject)yyVals[0+yyTop]));
return yyVal;
}
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/ext/ripper/RipperParser.y
Expand Up @@ -918,7 +918,7 @@ rel_expr : arg relop arg %prec tGT {

}
| rel_expr relop arg %prec tGT {
p.warning("comparison '" + $2 + "%s' after comparison");
p.warning("comparison '" + $2 + "' after comparison");
$$ = p.dispatch("on_binary", $1, p.intern(">"), $3);
}

Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/parser/RubyParser.java
Expand Up @@ -3374,7 +3374,7 @@ public Object yyparse (RubyLexer yyLex) throws java.io.IOException {
};
states[262] = new ParserState() {
@Override public Object execute(ParserSupport support, RubyLexer lexer, Object yyVal, Object[] yyVals, int yyTop) {
support.warning(ID.MISCELLANEOUS, lexer.getPosition(), "comparison '" + ((ByteList)yyVals[-1+yyTop]) + "%s' after comparison");
support.warning(ID.MISCELLANEOUS, lexer.getPosition(), "comparison '" + ((ByteList)yyVals[-1+yyTop]) + "' after comparison");
yyVal = support.getOperatorCallNode(((Node)yyVals[-2+yyTop]), ((ByteList)yyVals[-1+yyTop]), ((Node)yyVals[0+yyTop]), lexer.getPosition());
return yyVal;
}
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/parser/RubyParser.y
Expand Up @@ -1288,7 +1288,7 @@ rel_expr : arg relop arg %prec tGT {
$$ = support.getOperatorCallNode($1, $2, $3, lexer.getPosition());
}
| rel_expr relop arg %prec tGT {
support.warning(ID.MISCELLANEOUS, lexer.getPosition(), "comparison '" + $2 + "%s' after comparison");
support.warning(ID.MISCELLANEOUS, lexer.getPosition(), "comparison '" + $2 + "' after comparison");
$$ = support.getOperatorCallNode($1, $2, $3, lexer.getPosition());
}

Expand Down
Expand Up @@ -170,12 +170,11 @@ private FoundLibrary findFileResourceWithLoadPath(String searchName, String suff
if (resource.absolutePath() != resource.canonicalPath()) {
FileResource expandedResource = JRubyFile.createResourceAsFile(runtime, resource.canonicalPath());
if (expandedResource.exists()){
resource = expandedResource;
String scriptName = resolveScriptName(resource, resource.canonicalPath());
String loadName = resolveLoadName(resource, searchName + suffix);
String scriptName = resolveScriptName(expandedResource, expandedResource.canonicalPath());
String loadName = resolveLoadName(expandedResource, searchName + suffix);
return new FoundLibrary(ResourceLibrary.create(searchName, scriptName, resource), loadName);
}
}
}
DebugLog.Resource.logFound(pathWithSuffix);
String scriptName = resolveScriptName(resource, pathWithSuffix);
String loadName = resolveLoadName(resource, searchName + suffix);
Expand Down
7 changes: 3 additions & 4 deletions core/src/main/java/org/jruby/runtime/load/LoadService.java
Expand Up @@ -60,6 +60,7 @@
import org.jruby.RubyFile;
import org.jruby.RubyHash;
import org.jruby.RubyInstanceConfig;
import org.jruby.RubyKernel;
import org.jruby.RubyString;
import org.jruby.ast.executable.Script;
import org.jruby.exceptions.JumpException;
Expand Down Expand Up @@ -469,12 +470,10 @@ private void unlock(String requireName) {
}

protected void warnCircularRequire(String requireName) {
StringBuilder sb = new StringBuilder();
StringBuilder sb = new StringBuilder("loading in progress, circular require considered harmful - " + requireName);

runtime.getCurrentContext().renderCurrentBacktrace(sb);

runtime.getWarnings().warn("loading in progress, circular require considered harmful - " + requireName);
runtime.getErr().print(sb.toString());
runtime.getWarnings().warn(sb.toString());
}

/**
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/util/Sprintf.java
Expand Up @@ -91,7 +91,7 @@ public class Sprintf {
private static final String ERR_MALFORMED_DOT_NUM = "malformed format string - %.[0-9]";
private static final String ERR_MALFORMED_STAR_NUM = "malformed format string - %*[0-9]";
private static final String ERR_ILLEGAL_FORMAT_CHAR = "illegal format character - %";
private static final String ERR_INCOMPLETE_FORMAT_SPEC = "incomplete format specifier; use %%%% (double %%) instead";
private static final String ERR_INCOMPLETE_FORMAT_SPEC = "incomplete format specifier; use %% (double %) instead";
private static final String ERR_MALFORMED_NAME = "malformed name - unmatched parenthesis";

private static final ThreadLocal<Map<Locale, NumberFormat>> LOCALE_NUMBER_FORMATS = new ThreadLocal<Map<Locale, NumberFormat>>();
Expand Down
4 changes: 4 additions & 0 deletions test/mri/excludes/TestClass.rb
@@ -1,6 +1,10 @@
exclude :test_cannot_reinitialize_class_with_initialize_copy, "broken subprocess logic in setup"
exclude :test_check_inheritable, "needs investigation"
exclude :test_invalid_break_from_class_definition, "new LJE behavior or tests in Ruby 2.5"
exclude :test_invalid_jump_from_class_definition, "needs investigation"
exclude :test_invalid_next_from_class_definition, "new LJE behavior or tests in Ruby 2.5"
exclude :test_invalid_redo_from_class_definition, "new LJE behavior or tests in Ruby 2.5"
exclude :test_invalid_retry_from_class_definition, "new LJE behavior or tests in Ruby 2.5"
exclude :test_method_redefinition, "needs investigation"
exclude :test_redefine_private_class, "needs investigation"
exclude :test_redefinition_mismatch, "parser issue with Japanese identifiers (#3679)"
Expand Down
1 change: 1 addition & 0 deletions test/mri/excludes/TestEval.rb
@@ -1,3 +1,4 @@
exclude :test_eval_ascii_incompatible, "needs investigation"
exclude :test_eval_location_fstring, "needs investigation"
exclude :test_file_encoding, "needs investigation"
exclude :test_return_in_eval_proc, "new LJE behavior or tests in Ruby 2.5"
2 changes: 2 additions & 0 deletions test/mri/excludes/TestRequire.rb
Expand Up @@ -7,6 +7,8 @@
exclude :test_loading_fifo_threading_success, "we do not use IO to read files and so will not show as stopped while loading"
exclude :test_race_exception, "needs investigation"
exclude :test_require_changed_home, "needs investigation"
exclude :test_require_insecure_path, "JRuby does not have null-terminated strings nor tainting"
exclude :test_require_insecure_path_shift_jis, "JRuby does not have null-terminated strings nor tainting"
exclude :test_require_nonascii, "needs investigation"
exclude :test_require_nonascii_path_shift_jis, "needs investigation"
exclude :test_require_path_home_1, "needs investigation"
Expand Down
1 change: 1 addition & 0 deletions test/mri/excludes/TestRubyOptions.rb
Expand Up @@ -8,6 +8,7 @@
exclude :test_dump_yydebug_with_rflag, "MRI-specific format"
exclude :test_encoding, "needs investigation"
exclude :test_eval, "needs investigation"
exclude :test_flag_in_shebang, "unreliable with our bash script"
exclude :test_frozen_string_literal_debug, "needs investigation #4303"
exclude :test_indentation_check, "needs investigation"
exclude :test_invalid_option, "needs investigation"
Expand Down

0 comments on commit 135da97

Please sign in to comment.