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: 886cbe955139
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 21b9760280f0
Choose a head ref
  • 2 commits
  • 7 files changed
  • 1 contributor

Commits on Sep 26, 2016

  1. Copy the full SHA
    f8c373e View commit details
  2. Expose dedent_string. Fixes #4176

    headius committed Sep 26, 2016
    Copy the full SHA
    21b9760 View commit details
Showing with 39 additions and 5 deletions.
  1. +1 −1 core/pom.rb
  2. +1 −1 core/pom.xml
  3. +16 −0 core/src/main/java/org/jruby/ext/ripper/RubyRipper.java
  4. +1 −1 core/src/main/java/org/jruby/lexer/LexingCommon.java
  5. +1 −1 pom.rb
  6. +1 −1 pom.xml
  7. +18 −0 test/mri/ripper/test_ripper.rb
2 changes: 1 addition & 1 deletion core/pom.rb
Original file line number Diff line number Diff line change
@@ -49,7 +49,7 @@
jar 'com.github.jnr:jnr-unixsocket:0.12', :exclusions => ['com.github.jnr:jnr-ffi']
jar 'com.github.jnr:jnr-posix:3.0.29', :exclusions => ['com.github.jnr:jnr-ffi']
jar 'com.github.jnr:jnr-constants:0.9.3', :exclusions => ['com.github.jnr:jnr-ffi']
jar 'com.github.jnr:jnr-ffi:2.0.9'
jar 'com.github.jnr:jnr-ffi:2.1.0-SNAPSHOT'
jar 'com.github.jnr:jffi:${jffi.version}'
jar 'com.github.jnr:jffi:${jffi.version}:native'

2 changes: 1 addition & 1 deletion core/pom.xml
Original file line number Diff line number Diff line change
@@ -158,7 +158,7 @@ DO NOT MODIFIY - GENERATED CODE
<dependency>
<groupId>com.github.jnr</groupId>
<artifactId>jnr-ffi</artifactId>
<version>2.0.9</version>
<version>2.1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.github.jnr</groupId>
16 changes: 16 additions & 0 deletions core/src/main/java/org/jruby/ext/ripper/RubyRipper.java
Original file line number Diff line number Diff line change
@@ -33,11 +33,13 @@
import org.jruby.RubyHash;
import org.jruby.RubyNumeric;
import org.jruby.RubyObject;
import org.jruby.RubyString;
import org.jruby.anno.JRubyMethod;
import org.jruby.internal.runtime.methods.DynamicMethod;
import org.jruby.lexer.ByteListLexerSource;
import org.jruby.lexer.GetsLexerSource;
import org.jruby.lexer.LexerSource;
import org.jruby.lexer.LexingCommon;
import org.jruby.runtime.ObjectAllocator;
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.Visibility;
@@ -340,6 +342,20 @@ public IRubyObject yydebug_set(ThreadContext context, IRubyObject arg) {
parser.setYYDebug(arg.isTrue());
return arg;
}

@JRubyMethod(meta = true)
public static IRubyObject dedent_string(ThreadContext context, IRubyObject self, IRubyObject _input, IRubyObject _width) {
RubyString input = _input.convertToString();
int wid = _width.convertToInteger().getIntValue();
input.modify19();
int col = LexingCommon.dedent_string(input.getByteList(), wid);
return context.runtime.newFixnum(col);
}

@JRubyMethod
public IRubyObject dedent_string(ThreadContext context, IRubyObject _input, IRubyObject _width) {
return dedent_string(context, this, _input, _width);
}

private LexerSource source(ThreadContext context, IRubyObject src, String filename, int lineno) {
// FIXME: respond_to? returns private methods
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/lexer/LexingCommon.java
Original file line number Diff line number Diff line change
@@ -122,7 +122,7 @@ public String createTokenString() {
return createTokenString(tokp);
}

protected int dedent_string(ByteList string, int width) {
public static int dedent_string(ByteList string, int width) {
long len = string.realSize();
int i, col = 0;
byte[] str = string.unsafeBytes();
2 changes: 1 addition & 1 deletion pom.rb
Original file line number Diff line number Diff line change
@@ -85,7 +85,7 @@
'jruby-launcher.version' => '1.1.1',
'ant.version' => '1.9.2',
'asm.version' => '5.0.4',
'jffi.version' => '1.2.12',
'jffi.version' => '1.2.13-SNAPSHOT',
'bouncy-castle.version' => '1.47',
'joda.time.version' => '2.8.2' )

2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
@@ -112,7 +112,7 @@ DO NOT MODIFIY - GENERATED CODE
<minitest.version>5.4.1</minitest.version>
<ant.version>1.9.2</ant.version>
<diff-lcs.version>1.1.3</diff-lcs.version>
<jffi.version>1.2.12</jffi.version>
<jffi.version>1.2.13-SNAPSHOT</jffi.version>
<rake.version>10.4.2</rake.version>
<jruby-launcher.version>1.1.1</jruby-launcher.version>
<project.build.sourceEncoding>utf-8</project.build.sourceEncoding>
18 changes: 18 additions & 0 deletions test/mri/ripper/test_ripper.rb
Original file line number Diff line number Diff line change
@@ -61,4 +61,22 @@ def test_yydebug_equals
assert_predicate @ripper, :yydebug
end

# https://bugs.jruby.org/4176
def test_dedent_string
col = Ripper.dedent_string ' hello', 0
assert_equal 0, col
col = Ripper.dedent_string ' hello', 2
assert_equal 2, col
col = Ripper.dedent_string ' hello', 4
assert_equal 2, col

# lexing a squiggly heredoc triggers Ripper#dedent_string use
src = <<-END
puts <<~END
hello
end
END

assert_nothing_raised { Ripper.lex src }
end
end if ripper_test