1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

string.c: fix typo

* string.c (rb_str_scrub): fix typo, should yield invalid byte
  sequence to be scrubbed.  reported by znz at IRC.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43503 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2013-11-01 11:53:59 +00:00
parent 21ea356a42
commit e7fac351c2
3 changed files with 9 additions and 1 deletions

View file

@ -1,3 +1,8 @@
Fri Nov 1 20:53:56 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
* string.c (rb_str_scrub): fix typo, should yield invalid byte
sequence to be scrubbed. reported by znz at IRC.
Fri Nov 1 17:25:30 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
* gc.c (is_live_object): finalizer may not run because of lazy-sweep.

View file

@ -8069,7 +8069,7 @@ rb_str_scrub(VALUE str, VALUE repl)
if (!rep7bit_p) cr = ENC_CODERANGE_VALID;
}
else {
repl = rb_yield(rb_enc_str_new(p1, clen, enc));
repl = rb_yield(rb_enc_str_new(p, clen, enc));
repl = str_compat_and_valid(repl, enc);
rb_str_buf_cat(buf, RSTRING_PTR(repl), RSTRING_LEN(repl));
if (ENC_CODERANGE(repl) == ENC_CODERANGE_VALID)

View file

@ -1524,6 +1524,9 @@ class TestM17N < Test::Unit::TestCase
assert_raise(ArgumentError){ u("\xE3\x81\x82\xE3\x81\x82\xE3\x81").scrub{u("\x81")} }
assert_equal(e("\xA4\xA2\xA2\xAE"), e("\xA4\xA2\xA4").scrub{e("\xA2\xAE")})
assert_equal("\x81", u("a\x81").scrub {|c| break c})
assert_raise(ArgumentError) {u("a\x81").scrub {|c| c}}
assert_equal("\uFFFD\u3042".encode("UTF-16BE"),
"\xD8\x00\x30\x42".force_encoding(Encoding::UTF_16BE).
scrub)