Skip to content

Commit d4a27a5

Browse files
committed
Merge branch 'master' into truffle-head
2 parents b9af305 + 8f81e15 commit d4a27a5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+162
-376
lines changed

core/src/main/java/org/jruby/Ruby.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1758,12 +1758,12 @@ private void initBuiltins() {
17581758
addLazyBuiltin("ffi-internal.jar", "ffi-internal", "org.jruby.ext.ffi.FFIService");
17591759
addLazyBuiltin("tempfile.jar", "tempfile", "org.jruby.ext.tempfile.TempfileLibrary");
17601760
addLazyBuiltin("fcntl.rb", "fcntl", "org.jruby.ext.fcntl.FcntlLibrary");
1761-
addLazyBuiltin("yecht.jar", "yecht", "YechtService");
17621761
addLazyBuiltin("pathname.jar", "pathname", "org.jruby.ext.pathname.PathnameLibrary");
17631762

17641763
addLazyBuiltin("mathn/complex.jar", "mathn/complex", "org.jruby.ext.mathn.Complex");
17651764
addLazyBuiltin("mathn/rational.jar", "mathn/rational", "org.jruby.ext.mathn.Rational");
17661765
addLazyBuiltin("psych.jar", "psych", "org.jruby.ext.psych.PsychLibrary");
1766+
addLazyBuiltin("ripper.jar", "ripper", "org.jruby.ext.ripper.RipperLibrary");
17671767
addLazyBuiltin("coverage.jar", "coverage", "org.jruby.ext.coverage.CoverageLibrary");
17681768

17691769
// TODO: implement something for these?

core/src/main/java/org/jruby/RubyString.java

+4-12
Original file line numberDiff line numberDiff line change
@@ -2582,18 +2582,10 @@ private IRubyObject gsubCommon19(ThreadContext context, Block block, RubyString
25822582
private IRubyObject gsubCommon19(ThreadContext context, Block block, RubyString repl,
25832583
RubyHash hash, IRubyObject arg0, final boolean bang, int tuFlags, boolean useBackref) {
25842584
Ruby runtime = context.runtime;
2585-
2586-
final Regex pattern, prepared;
2587-
final RubyRegexp regexp;
2588-
if (arg0 instanceof RubyRegexp) {
2589-
regexp = (RubyRegexp)arg0;
2590-
pattern = regexp.getPattern();
2591-
prepared = regexp.preparePattern(this);
2592-
} else {
2593-
regexp = null;
2594-
pattern = getStringPattern19(runtime, arg0);
2595-
prepared = RubyRegexp.preparePattern(runtime, pattern, this);
2596-
}
2585+
RubyRegexp regexp = arg0 instanceof RubyRegexp ? (RubyRegexp) arg0 :
2586+
RubyRegexp.newRegexp(runtime, RubyRegexp.quote19(getStringForPattern(arg0).getByteList(), false), new RegexpOptions());
2587+
Regex pattern = regexp.getPattern();
2588+
Regex prepared = regexp.preparePattern(this);
25972589

25982590
int offset, cp, n, blen;
25992591

core/src/main/java/org/jruby/parser/Parser.java

+8-1
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,16 @@ public Node parse(String file, LexerSource lexerSource, DynamicScope blockScope,
127127
case NOT_ASCII_COMPATIBLE:
128128
throw runtime.newArgumentError(e.getMessage());
129129
default:
130+
int line = e.getPosition().getLine();
131+
132+
// Detailed source positions always have the right line number so they don't need to be adjusted.
133+
if (! (e.getPosition() instanceof DetailedSourcePosition)) {
134+
line++;
135+
}
136+
130137
StringBuilder buffer = new StringBuilder(100);
131138
buffer.append(e.getPosition().getFile()).append(':');
132-
buffer.append(e.getPosition().getLine() + 1).append(": ");
139+
buffer.append(line).append(": ");
133140
buffer.append(e.getMessage());
134141

135142
throw runtime.newSyntaxError(buffer.toString());

core/src/test/java/org/jruby/parser/DetailedSourcePositionTest.java

+11
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,17 @@ public void testRegression2() {
165165
// assertEquals(8, position.getLength());
166166
}
167167

168+
public void testSyntaxError() {
169+
try {
170+
parse("3.to_i(\n");
171+
} catch (org.jruby.exceptions.RaiseException e) {
172+
final String syntaxErrorMessage = e.getException().message.asJavaString();
173+
174+
// There's no easy way to get at the source position information, but it is embedded in the syntax error message.
175+
assertEquals("test:1: syntax error, unexpected end-of-file\n", syntaxErrorMessage);
176+
}
177+
}
178+
168179
private class FoundException extends RuntimeException {
169180

170181
private final Node node;

ext/.gitignore

-3
This file was deleted.

ext/.project

-17
This file was deleted.

ext/.settings/org.eclipse.core.resources.prefs

-2
This file was deleted.

ext/.settings/org.eclipse.m2e.core.prefs

-4
This file was deleted.

ext/pom.rb

-17
This file was deleted.

ext/pom.xml

-30
This file was deleted.

ext/ripper/.classpath

-26
This file was deleted.

ext/ripper/.project

-23
This file was deleted.

ext/ripper/.settings/org.eclipse.core.resources.prefs

-3
This file was deleted.

ext/ripper/.settings/org.eclipse.jdt.core.prefs

-5
This file was deleted.

ext/ripper/.settings/org.eclipse.m2e.core.prefs

-4
This file was deleted.

ext/ripper/License.txt

-30
This file was deleted.

ext/ripper/Mavenfile

-21
This file was deleted.

ext/ripper/Rakefile

-7
This file was deleted.

ext/ripper/nb-configuration.xml

-18
This file was deleted.

0 commit comments

Comments
 (0)