Skip to content

Commit

Permalink
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions core/src/main/java/org/jruby/Ruby.java
Original file line number Diff line number Diff line change
@@ -80,6 +80,7 @@

import org.jcodings.Encoding;
import org.joda.time.DateTimeZone;
import org.joni.WarnCallback;
import org.jruby.ast.Node;
import org.jruby.ast.RootNode;
import org.jruby.ast.executable.RuntimeCache;
@@ -2839,6 +2840,10 @@ public RubyWarnings getWarnings() {
return warnings;
}

WarnCallback getRegexpWarnings() {
return regexpWarnings;
}

public PrintStream getErrorStream() {
// FIXME: We can't guarantee this will always be a RubyIO...so the old code here is not safe
/*java.io.OutputStream os = ((RubyIO) getGlobalVariables().getService("$stderr")).getOutStream();
@@ -5050,6 +5055,12 @@ private MRIRecursionGuard oldRecursionGuard() {

private GlobalVariables globalVariables = new GlobalVariables(this);
private final RubyWarnings warnings = new RubyWarnings(this);
private final WarnCallback regexpWarnings = new WarnCallback() {
@Override
public void warn(String message) {
getWarnings().warning(message);
}
};

// Contains a list of all blocks (as Procs) that should be called when
// the runtime environment exits.
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/RubyRegexp.java
Original file line number Diff line number Diff line change
@@ -148,7 +148,7 @@ public Encoding getMarshalEncoding() {
private static Regex makeRegexp(Ruby runtime, ByteList bytes, RegexpOptions options, Encoding enc) {
try {
int p = bytes.getBegin();
return new Regex(bytes.getUnsafeBytes(), p, p + bytes.getRealSize(), options.toJoniOptions(), enc, Syntax.DEFAULT, runtime.getWarnings());
return new Regex(bytes.getUnsafeBytes(), p, p + bytes.getRealSize(), options.toJoniOptions(), enc, Syntax.DEFAULT, runtime.getRegexpWarnings());
} catch (Exception e) {
RegexpSupport.raiseRegexpError19(runtime, bytes, enc, options, e.getMessage());
return null; // not reached

0 comments on commit d20b9f7

Please sign in to comment.