diff options
| author | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-02-22 12:49:14 +0000 |
|---|---|---|
| committer | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-02-22 12:49:14 +0000 |
| commit | 812b61acca8db165665ded69cdb2a7379da8ad52 (patch) | |
| tree | 7ad83a65aee7efa31fbca7c61bcbb8e4d8079c61 /string.c | |
| parent | 4295f3d99eccd368e4e08eb9c1d114660e4ea921 (diff) | |
merges r22255 from trunk into ruby_1_9_1.
* compile.c (compile_array_, defined_expr, iseq_compile_each): hide
and freeze internal literal objects, to prevent from modifying.
[ruby-dev:37959]
* iseq.c (insn_operand_intern): copy internal literal objects.
* insns.def (putstring, duparray): ditto.
* string.c (rb_str_replace): exported.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_9_1@22532 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
| -rw-r--r-- | string.c | 18 |
1 files changed, 10 insertions, 8 deletions
@@ -815,14 +815,18 @@ rb_obj_as_string(VALUE obj) return str; } -static VALUE rb_str_replace(VALUE, VALUE); +static VALUE +str_duplicate(VALUE klass, VALUE str) +{ + VALUE dup = str_alloc(klass); + rb_str_replace(dup, str); + return dup; +} VALUE rb_str_dup(VALUE str) { - VALUE dup = str_alloc(rb_obj_class(str)); - rb_str_replace(dup, str); - return dup; + return str_duplicate(rb_obj_class(str), str); } @@ -3675,7 +3679,7 @@ rb_str_gsub(int argc, VALUE *argv, VALUE str) * s.replace "world" #=> "world" */ -static VALUE +VALUE rb_str_replace(VALUE str, VALUE str2) { long len; @@ -3977,9 +3981,7 @@ static VALUE rb_str_to_s(VALUE str) { if (rb_obj_class(str) != rb_cString) { - VALUE dup = str_alloc(rb_cString); - rb_str_replace(dup, str); - return dup; + return str_duplicate(rb_cString, str); } return str; } |
