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: 49323931cdcc
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 20cada438ad7
Choose a head ref
  • 6 commits
  • 2 files changed
  • 2 contributors

Commits on Mar 25, 2018

  1. Copy the full SHA
    2e1987d View commit details
  2. Copy the full SHA
    77cc454 View commit details
  3. Copy the full SHA
    113bde3 View commit details
  4. Copy the full SHA
    617e783 View commit details
  5. Kernel#sprintf must raise ArgumentError on dangling '%' chars in form…

    …at string since Ruby 2.5
    nomadium committed Mar 25, 2018
    Copy the full SHA
    49a74b9 View commit details

Commits on Mar 26, 2018

  1. Merge pull request #5107 from nomadium/fix-ruby-2.5-ruby-spec-tests-f…

    …or-string
    
    Fix failed Ruby 2.5 ruby/spec tests for String
    kares authored Mar 26, 2018
    Copy the full SHA
    20cada4 View commit details
Showing with 10 additions and 6 deletions.
  1. +8 −6 core/src/main/java/org/jruby/RubyString.java
  2. +2 −0 core/src/main/java/org/jruby/util/Sprintf.java
14 changes: 8 additions & 6 deletions core/src/main/java/org/jruby/RubyString.java
Original file line number Diff line number Diff line change
@@ -4037,7 +4037,7 @@ public IRubyObject start_with_p(ThreadContext context, IRubyObject arg) {
@JRubyMethod(name = "delete_prefix")
public IRubyObject delete_prefix(ThreadContext context, IRubyObject arg) {
RubyString prefix = arg.convertToString();
if (!this.start_with_p(context, prefix).isTrue()) return this;
if (!this.start_with_p(context, prefix).isTrue()) return this.dup();
if (prefix.value.getRealSize() == this.value.getRealSize()) return newEmptyString(context.runtime, value.getEncoding());
RubyString result = (RubyString) substr19(context.runtime, prefix.strLength(), this.strLength() - prefix.strLength());
return result.isEmpty() ? this : result;
@@ -4046,14 +4046,15 @@ public IRubyObject delete_prefix(ThreadContext context, IRubyObject arg) {
@JRubyMethod(name = "delete_suffix")
public IRubyObject delete_suffix(ThreadContext context, IRubyObject arg) {
RubyString suffix = arg.convertToString();
if (!this.end_with_p(context, suffix).isTrue()) return this;
if (!this.end_with_p(context, suffix).isTrue()) return this.dup();
if (suffix.value.getRealSize() == this.value.getRealSize()) return newEmptyString(context.runtime, value.getEncoding());
RubyString result = (RubyString) substr19(context.runtime, 0, this.strLength() - suffix.strLength());
return result.isEmpty() ? this : result;
}

@JRubyMethod(name = "delete_prefix!")
public IRubyObject delete_prefix_bang(ThreadContext context, IRubyObject arg) {
modifyCheck();
RubyString result = (RubyString) delete_prefix(context, arg);
if (equals(result)) return context.runtime.getNil();
replaceInternal19(0, this.strLength(), result);
@@ -4062,10 +4063,11 @@ public IRubyObject delete_prefix_bang(ThreadContext context, IRubyObject arg) {

@JRubyMethod(name = "delete_suffix!")
public IRubyObject delete_suffix_bang(ThreadContext context, IRubyObject arg) {
RubyString result = (RubyString) delete_suffix(context, arg);
if (equals(result)) return context.runtime.getNil();
replaceInternal19(0, this.strLength(), result);
return this;
modifyCheck();
RubyString result = (RubyString) delete_suffix(context, arg);
if (equals(result)) return context.runtime.getNil();
replaceInternal19(0, this.strLength(), result);
return this;
}

@JRubyMethod(name = "start_with?", rest = true)
2 changes: 2 additions & 0 deletions core/src/main/java/org/jruby/util/Sprintf.java
Original file line number Diff line number Diff line change
@@ -90,6 +90,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_MALFORMED_NAME = "malformed name - unmatched parenthesis";

private static final ThreadLocal<Map<Locale, NumberFormat>> LOCALE_NUMBER_FORMATS = new ThreadLocal<Map<Locale, NumberFormat>>();
@@ -1413,6 +1414,7 @@ else if ((flags & FLAG_MINUS) != 0) {
if (incomplete) {
if (flags == FLAG_NONE) {
// dangling '%' char
if (format[length - 1] == '%') raiseArgumentError(args,ERR_INCOMPLETE_FORMAT_SPEC);
buf.append('%');
} else {
raiseArgumentError(args,ERR_ILLEGAL_FORMAT_CHAR);