merges r21047 from trunk into ruby_1_9_1.

* transcode.c (str_transcode0): set encoding when String#encode was
  given explicit but the same destination and source encoding.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@21064 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
yugui 2008-12-26 05:54:41 +00:00
parent 1f161c1824
commit b7a1cb6251
3 changed files with 8 additions and 2 deletions

View file

@ -2455,7 +2455,7 @@ str_transcode0(int argc, VALUE *argv, VALUE *self, int ecflags, VALUE ecopts)
ECONV_XML_ATTR_CONTENT_DECORATOR|
ECONV_XML_ATTR_QUOTE_DECORATOR)) == 0) {
if (senc && senc == denc) {
return -1;
return NIL_P(arg2) ? -1 : dencidx;
}
if (senc && denc && rb_enc_asciicompat(senc) && rb_enc_asciicompat(denc)) {
if (ENC_CODERANGE(str) == ENC_CODERANGE_7BIT) {
@ -2463,7 +2463,7 @@ str_transcode0(int argc, VALUE *argv, VALUE *self, int ecflags, VALUE ecopts)
}
}
if (encoding_equal(sname, dname)) {
return -1;
return NIL_P(arg2) ? -1 : dencidx;
}
}
else {