mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* string.c (rb_str_enumerate_lines): fix invalid byte sequence error
when a separator is passed. The patch is from yoshidam (Yoshida Masato). [Bug #7646] [ruby-dev:46827] * test/ruby/test_string.rb: a test for above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38704 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
3caea6b6a2
commit
3b983407ef
3 changed files with 17 additions and 3 deletions
|
@ -1,3 +1,12 @@
|
||||||
|
Sat Jan 5 13:38:07 2013 Masaki Matsushita <glass.saga@gmail.com>
|
||||||
|
|
||||||
|
* string.c (rb_str_enumerate_lines): fix invalid byte sequence error
|
||||||
|
when a separator is passed. The patch is from yoshidam (Yoshida
|
||||||
|
Masato).
|
||||||
|
[Bug #7646] [ruby-dev:46827]
|
||||||
|
|
||||||
|
* test/ruby/test_string.rb: a test for above.
|
||||||
|
|
||||||
Sat Jan 5 12:25:42 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Sat Jan 5 12:25:42 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* test/ruby/envutil.rb (Test::Unit::Assertions#assert_in_out_err):
|
* test/ruby/envutil.rb (Test::Unit::Assertions#assert_in_out_err):
|
||||||
|
|
6
string.c
6
string.c
|
@ -6199,14 +6199,14 @@ rb_str_enumerate_lines(int argc, VALUE *argv, VALUE str, int wantarray)
|
||||||
if (c == newline &&
|
if (c == newline &&
|
||||||
(rslen <= 1 ||
|
(rslen <= 1 ||
|
||||||
(pend - p >= rslen && memcmp(RSTRING_PTR(rs), p, rslen) == 0))) {
|
(pend - p >= rslen && memcmp(RSTRING_PTR(rs), p, rslen) == 0))) {
|
||||||
p += (rslen ? rslen : n);
|
const char *pp = p + (rslen ? rslen : n);
|
||||||
line = rb_str_subseq(str, s - ptr, p - s);
|
line = rb_str_subseq(str, s - ptr, pp - s);
|
||||||
if (wantarray)
|
if (wantarray)
|
||||||
rb_ary_push(ary, line);
|
rb_ary_push(ary, line);
|
||||||
else
|
else
|
||||||
rb_yield(line);
|
rb_yield(line);
|
||||||
str_mod_check(str, ptr, len);
|
str_mod_check(str, ptr, len);
|
||||||
s = p;
|
s = pp;
|
||||||
}
|
}
|
||||||
p += n;
|
p += n;
|
||||||
}
|
}
|
||||||
|
|
|
@ -760,6 +760,11 @@ class TestString < Test::Unit::TestCase
|
||||||
|
|
||||||
assert_equal "hello\n", S("hello\nworld").each_line.next
|
assert_equal "hello\n", S("hello\nworld").each_line.next
|
||||||
assert_equal "hello\nworld", S("hello\nworld").each_line(nil).next
|
assert_equal "hello\nworld", S("hello\nworld").each_line(nil).next
|
||||||
|
|
||||||
|
bug7646 = "[ruby-dev:46827]"
|
||||||
|
assert_nothing_raised(bug7646) do
|
||||||
|
"\n\u0100".each_line("\n") {}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_lines
|
def test_lines
|
||||||
|
|
Loading…
Add table
Reference in a new issue