* transcode.c (encoded_dup): extract.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30788 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
780678dafb
commit
e9cc518446
@ -1,3 +1,7 @@
|
|||||||
|
Sat Feb 5 09:38:08 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* transcode.c (encoded_dup): extract.
|
||||||
|
|
||||||
Sat Feb 5 03:37:47 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Sat Feb 5 03:37:47 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* lib/fileutils.rb (FileUtils::LowMethods): make low level methods
|
* lib/fileutils.rb (FileUtils::LowMethods): make low level methods
|
||||||
|
17
transcode.c
17
transcode.c
@ -2757,6 +2757,8 @@ str_encode_bang(int argc, VALUE *argv, VALUE str)
|
|||||||
return str_encode_associate(str, encidx);
|
return str_encode_associate(str, encidx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static VALUE encoded_dup(VALUE newstr, VALUE str, int encidx);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* str.encode(encoding [, options] ) -> str
|
* str.encode(encoding [, options] ) -> str
|
||||||
@ -2816,15 +2818,7 @@ str_encode(int argc, VALUE *argv, VALUE str)
|
|||||||
{
|
{
|
||||||
VALUE newstr = str;
|
VALUE newstr = str;
|
||||||
int encidx = str_transcode(argc, argv, &newstr);
|
int encidx = str_transcode(argc, argv, &newstr);
|
||||||
|
return encoded_dup(newstr, str, encidx);
|
||||||
if (encidx < 0) return rb_str_dup(str);
|
|
||||||
if (newstr == str) {
|
|
||||||
newstr = rb_str_dup(str);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
RBASIC(newstr)->klass = rb_obj_class(str);
|
|
||||||
}
|
|
||||||
return str_encode_associate(newstr, encidx);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
VALUE
|
VALUE
|
||||||
@ -2834,7 +2828,12 @@ rb_str_encode(VALUE str, VALUE to, int ecflags, VALUE ecopts)
|
|||||||
VALUE *argv = &to;
|
VALUE *argv = &to;
|
||||||
VALUE newstr = str;
|
VALUE newstr = str;
|
||||||
int encidx = str_transcode0(argc, argv, &newstr, ecflags, ecopts);
|
int encidx = str_transcode0(argc, argv, &newstr, ecflags, ecopts);
|
||||||
|
return encoded_dup(newstr, str, encidx);
|
||||||
|
}
|
||||||
|
|
||||||
|
static VALUE
|
||||||
|
encoded_dup(VALUE newstr, VALUE str, int encidx)
|
||||||
|
{
|
||||||
if (encidx < 0) return rb_str_dup(str);
|
if (encidx < 0) return rb_str_dup(str);
|
||||||
if (newstr == str) {
|
if (newstr == str) {
|
||||||
newstr = rb_str_dup(str);
|
newstr = rb_str_dup(str);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user