mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* ext/stringio/stringio.c (strio_getline): fix for "" as separator.
[ruby-dev:34591] (Backport r17739 by Yusuke Endoh from trunk). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@26140 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
ac714c2d30
commit
f9df459a31
3 changed files with 18 additions and 1 deletions
|
@ -1,3 +1,8 @@
|
|||
Mon Dec 21 15:27:48 2009 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
|
||||
|
||||
* ext/stringio/stringio.c (strio_getline): fix for "" as separator.
|
||||
[ruby-dev:34591] (Backport r17739 by Yusuke Endoh from trunk).
|
||||
|
||||
Mon Dec 21 15:20:42 2009 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
|
||||
|
||||
* test/openssl/{common.pem,max.pem}: added fixture certificates.
|
||||
|
|
|
@ -935,7 +935,7 @@ strio_getline(argc, argv, ptr)
|
|||
s = p;
|
||||
while ((p = memchr(p, '\n', e - p)) && (p != e)) {
|
||||
if (*++p == '\n') {
|
||||
e = p;
|
||||
e = p + 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,6 +56,18 @@ class TestStringIO < Test::Unit::TestCase
|
|||
assert_equal("abc\n\n", StringIO.new("abc\n\ndef\n").gets(""))
|
||||
end
|
||||
|
||||
def test_gets_paragraph
|
||||
assert_equal("abc\n\n", StringIO.new("abc\n\ndef\n").gets(""))
|
||||
assert_equal("abc\n\n", StringIO.new("\nabc\n\ndef\n").gets(""))
|
||||
assert_equal("abc", StringIO.new("abc").gets(""))
|
||||
assert_equal("abc\n", StringIO.new("abc\n").gets(""))
|
||||
assert_equal(nil, StringIO.new("").gets(""))
|
||||
assert_equal("def\n", StringIO.new("\n\ndef\n").gets(""))
|
||||
s = StringIO.new("\n\nabc\n\n\n\ndef\n")
|
||||
assert_equal("abc\n\n", s.gets(""))
|
||||
assert_equal("def\n", s.gets(""))
|
||||
end
|
||||
|
||||
def test_readlines
|
||||
assert_equal([], StringIO.new("").readlines)
|
||||
assert_equal(["\n"], StringIO.new("\n").readlines)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue