aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-02-18 06:18:31 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-02-18 06:18:31 +0000
commit8efc7ea9ad664b942f48e16bb325769b08844b9f (patch)
treed0723afb5968fa880cf19e7935f5e6f1d337cc43
parente61e1f6234fe994508506341932fa118abafb370 (diff)
downloadruby-8efc7ea9ad664b942f48e16bb325769b08844b9f.tar.gz
* string.c (rb_str_each_line): fix newline size.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15539 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog4
-rw-r--r--string.c2
-rw-r--r--test/ruby/test_m17n.rb6
3 files changed, 11 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index a6caaba3df..122651e89d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Mon Feb 18 15:16:30 2008 Tanaka Akira <akr@fsij.org>
+
+ * string.c (rb_str_each_line): fix newline size.
+
Mon Feb 18 13:06:37 2008 Tanaka Akira <akr@fsij.org>
* lib/irb/locale.rb (IRB::Locale#lc2kconv): check ja_JP.EUC-JP as well.
diff --git a/string.c b/string.c
index 6177059738..9bab8d4411 100644
--- a/string.c
+++ b/string.c
@@ -4896,7 +4896,7 @@ rb_str_each_line(int argc, VALUE *argv, VALUE str)
p++;
continue;
}
- p = p0 + rb_enc_mbclen(s, p0, enc);
+ p = p0 + rb_enc_mbclen(p0, pend, enc);
line = rb_str_new5(str, s, p - s);
OBJ_INFECT(line, str);
rb_enc_copy(line, str);
diff --git a/test/ruby/test_m17n.rb b/test/ruby/test_m17n.rb
index c3e14f64c7..5ff2a9da78 100644
--- a/test/ruby/test_m17n.rb
+++ b/test/ruby/test_m17n.rb
@@ -980,6 +980,12 @@ class TestM17N < Test::Unit::TestCase
def test_each_line
s = e("\xa3\xb0\xa3\xb1\xa3\xb2\xa3\xb3\xa3\xb4")
assert_raise(ArgumentError){s.each_line(a("\xa3\xb1")) {|l| }}
+ s = e("\xa4\xa2\nfoo")
+
+ actual = []
+ s.each_line {|line| actual << line }
+ expected = [e("\xa4\xa2\n"), e("foo")]
+ assert_equal(expected, actual)
end
def test_each_char