* string.c (rb_str_each_line): should consider rslen.

* string.c (rb_str_buf_append): should propagate encoding.

* string.c (rb_str_each_line): ditto.

* test/ruby/test_m17n.rb (TestM17N::test_str_each_line): should
  check encoding as well.

* test/ruby/test_m17n.rb (TestM17N::test_str_each_line): empty
  array can not propagate encoding;  should not check.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14343 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2007-12-19 17:46:17 +00:00
Родитель 42244c17f6
Коммит d874dde282
3 изменённых файлов: 22 добавлений и 2 удалений

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

@ -47,6 +47,18 @@ Wed Dec 19 22:59:52 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
* test/ruby/test_m17n.rb (TestM17N::test_str_insert): test updated
to check negative offset behavior.
* string.c (rb_str_each_line): should consider rslen.
* string.c (rb_str_buf_append): should propagate encoding.
* string.c (rb_str_each_line): ditto.
* test/ruby/test_m17n.rb (TestM17N::test_str_each_line): should
check encoding as well.
* test/ruby/test_m17n.rb (TestM17N::test_str_each_line): empty
array can not propagate encoding; should not check.
Wed Dec 19 21:42:18 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* re.c (rb_reg_regsub): should set checked encoding.

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

@ -1007,8 +1007,10 @@ rb_str_cat2(VALUE str, const char *ptr)
VALUE
rb_str_buf_append(VALUE str, VALUE str2)
{
rb_encoding *enc;
long capa, len;
enc = rb_enc_check(str, str2);
rb_str_modify(str);
if (STR_ASSOC_P(str)) {
FL_UNSET(str, STR_ASSOC);
@ -1031,6 +1033,7 @@ rb_str_buf_append(VALUE str, VALUE str2)
RSTRING_PTR(str2), RSTRING_LEN(str2)+1);
STR_SET_LEN(str, len);
OBJ_INFECT(str, str2);
rb_enc_associate(str, enc);
return str;
}
@ -4288,9 +4291,10 @@ rb_str_each_line(int argc, VALUE *argv, VALUE str)
(rslen <= 1 || memcmp(RSTRING_PTR(rs), p, rslen) == 0)) {
line = rb_str_new5(str, s, p - s + (rslen ? rslen : n));
OBJ_INFECT(line, str);
rb_enc_copy(line, str);
rb_yield(line);
str_mod_check(str, ptr, len);
s = p + n;
s = p + (rslen ? rslen : n);
}
p += n;
}
@ -4299,6 +4303,7 @@ rb_str_each_line(int argc, VALUE *argv, VALUE str)
if (p > pend) p = pend;
line = rb_str_new5(str, s, p - s);
OBJ_INFECT(line, str);
rb_enc_copy(line, str);
rb_yield(line);
}

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

@ -1201,7 +1201,10 @@ class TestM17N < Test::Unit::TestCase
assert_equal(s1.encoding, line.encoding)
lines << line
}
assert_equal(s1, lines.join(''))
next if lines.size == 0
s2 = lines.join('')
assert_equal(s1.encoding, s2.encoding)
assert_equal(s1, s2)
}
end