Skip to content

Commit

Permalink
Additional fixes for chomp with nil sep
Browse files Browse the repository at this point in the history
  • Loading branch information
headius committed Aug 14, 2023
1 parent 8a579bb commit 64b2771
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions ext/java/org/jruby/ext/stringio/StringIO.java
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,8 @@ public IRubyObject getline(ThreadContext context, StringIO self, IRubyObject rs,
return RubyString.newEmptyString(context.runtime, self.getEncoding());
}

if (rs.isNil()) chomp = false;

IRubyObject result = self.getline(context, rs, limit, chomp);

context.setLastLine(result);
Expand All @@ -616,6 +618,8 @@ public StringIO getline(ThreadContext context, StringIO self, IRubyObject rs, in
throw context.runtime.newArgumentError("invalid limit: 0 for each_line");
}

if (rs.isNil()) chomp = false;

while (!(line = self.getline(context, rs, limit, chomp)).isNil()) {
block.yieldSpecific(context, line);
}
Expand All @@ -634,6 +638,8 @@ public RubyArray getline(ThreadContext context, StringIO self, IRubyObject rs, i
throw context.runtime.newArgumentError("invalid limit: 0 for readlines");
}

if (rs.isNil()) chomp = false;

while (!(line = self.getline(context, rs, limit, chomp)).isNil()) {
ary.append(line);
}
Expand Down

0 comments on commit 64b2771

Please sign in to comment.