diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-05-27 08:09:46 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-05-27 08:09:46 +0000 |
commit | 4fad63da01789ad3b562833c97d289d2abfeff19 (patch) | |
tree | 0916ba45ffe09bec9cc8406b860c9dca27eec0c5 /string.c | |
parent | be1ceb27234815628631524d23cdb6c518a73044 (diff) |
transcode.c: scrub in the given encoding
* transcode.c (str_transcode0): scrub in the given encoding when
the source encoding is given, not in the encoding of the
receiver. [ruby-core:75732] [Bug #12431]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55181 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r-- | string.c | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -8927,8 +8927,13 @@ str_compat_and_valid(VALUE str, rb_encoding *enc) VALUE rb_str_scrub(VALUE str, VALUE repl) { + return rb_enc_str_scrub(STR_ENC_GET(str), str, repl); +} + +VALUE +rb_enc_str_scrub(rb_encoding *enc, VALUE str, VALUE repl) +{ int cr = ENC_CODERANGE(str); - rb_encoding *enc; int encidx; VALUE buf = Qnil; const char *rep; @@ -8938,7 +8943,6 @@ rb_str_scrub(VALUE str, VALUE repl) if (ENC_CODERANGE_CLEAN_P(cr)) return Qnil; - enc = STR_ENC_GET(str); if (!NIL_P(repl)) { repl = str_compat_and_valid(repl, enc); tainted = OBJ_TAINTED_RAW(repl); |