Revert "Do not chomp trailing line separator IO#each with nil separator and chomp"

This reverts commit 04f86ad0b5.

This is causing CI issues, reverting for now.
This commit is contained in:
Jeremy Evans 2022-07-21 08:29:50 -07:00
Родитель 12ac8971a3
Коммит 203f179ce7
2 изменённых файлов: 2 добавлений и 15 удалений

1
io.c
Просмотреть файл

@ -3875,6 +3875,7 @@ rb_io_getline_0(VALUE rs, long limit, int chomp, rb_io_t *fptr)
if (NIL_P(rs) && limit < 0) {
str = read_all(fptr, 0, Qnil);
if (RSTRING_LEN(str) == 0) return Qnil;
if (chomp) rb_str_chomp_string(str, rb_default_rs);
}
else if (limit == 0) {
return rb_enc_str_new(0, 0, io_read_encoding(fptr));

Просмотреть файл

@ -312,7 +312,7 @@ class TestIO < Test::Unit::TestCase
w.print "a\n\nb\n\n"
w.close
end, proc do |r|
assert_equal("a\n\nb\n\n", r.gets(nil, chomp: true), "[Bug #18770]")
assert_equal "a\n\nb\n", r.gets(nil, chomp: true)
assert_nil r.gets("")
r.close
end)
@ -1894,20 +1894,6 @@ class TestIO < Test::Unit::TestCase
assert_equal("baz\n", e.next)
assert_raise(StopIteration) { e.next }
end)
pipe(proc do |w|
w.write "foo\n"
w.close
end, proc do |r|
assert_equal(["foo\n"], r.each_line(nil, chomp: true).to_a, "[Bug #18770]")
end)
pipe(proc do |w|
w.write "foo\n"
w.close
end, proc do |r|
assert_equal(["fo", "o\n"], r.each_line(nil, 2, chomp: true).to_a, "[Bug #18770]")
end)
end
def test_each_byte2