mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
revert r58703 & r58705
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58708 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
0843c1ca37
commit
7323de517d
1 changed files with 2 additions and 16 deletions
18
string.c
18
string.c
|
@ -997,24 +997,10 @@ rb_str_conv_enc(VALUE str, rb_encoding *from, rb_encoding *to)
|
|||
VALUE
|
||||
rb_external_str_new_with_enc(const char *ptr, long len, rb_encoding *eenc)
|
||||
{
|
||||
rb_encoding *ienc;
|
||||
VALUE str;
|
||||
|
||||
if (!eenc || (eenc == rb_ascii8bit_encoding()) ||
|
||||
(eenc == rb_usascii_encoding() && search_nonascii(ptr, ptr + len))) {
|
||||
return rb_tainted_str_new(ptr, len);
|
||||
}
|
||||
ienc = rb_default_internal_encoding();
|
||||
if (!ienc || eenc == ienc) {
|
||||
return rb_tainted_str_new_with_enc(ptr, len, eenc);
|
||||
}
|
||||
str = rb_tainted_str_new_with_enc(NULL, 0, ienc);
|
||||
if (NIL_P(rb_str_cat_conv_enc_opts(str, 0, ptr, len, eenc, 0, Qnil))) {
|
||||
STR_SET_LEN(str, 0);
|
||||
rb_enc_associate(str, eenc);
|
||||
rb_str_cat(str, ptr, len);
|
||||
}
|
||||
return str;
|
||||
str = rb_tainted_str_new_with_enc(ptr, len, eenc);
|
||||
return rb_external_str_with_enc(str, eenc);
|
||||
}
|
||||
|
||||
VALUE
|
||||
|
|
Loading…
Add table
Reference in a new issue