Created
July 15, 2009 06:18
-
-
Save bluescreen303/147516 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff -urN ruby-1.9.1-p129/array.c ruby-1.9.1-p129-putstringfix-22395/array.c | |
--- ruby-1.9.1-p129/array.c 2009-05-04 14:30:55.000000000 +0200 | |
+++ ruby-1.9.1-p129-putstringfix-22395/array.c 2009-07-13 22:47:07.000000000 +0200 | |
@@ -1457,6 +1457,12 @@ | |
return dup; | |
} | |
+VALUE | |
+rb_ary_resurrect(VALUE ary) | |
+{ | |
+ return rb_ary_new4(RARRAY_LEN(ary), RARRAY_PTR(ary)); | |
+} | |
+ | |
extern VALUE rb_output_fs; | |
static VALUE | |
diff -urN ruby-1.9.1-p129/insns.def ruby-1.9.1-p129-putstringfix-22395/insns.def | |
--- ruby-1.9.1-p129/insns.def 2009-02-22 13:49:14.000000000 +0100 | |
+++ ruby-1.9.1-p129-putstringfix-22395/insns.def 2009-07-13 22:48:33.000000000 +0200 | |
@@ -373,7 +373,7 @@ | |
() | |
(VALUE val) | |
{ | |
- val = rb_str_replace(rb_str_new(0, 0), str); | |
+ val = rb_str_resurrect(str); | |
} | |
/** | |
@@ -460,7 +460,7 @@ | |
() | |
(VALUE val) | |
{ | |
- val = rb_ary_replace(rb_ary_new2(0), ary); | |
+ val = rb_ary_resurrect(ary); | |
} | |
/** | |
diff -urN ruby-1.9.1-p129/iseq.c ruby-1.9.1-p129-putstringfix-22395/iseq.c | |
--- ruby-1.9.1-p129/iseq.c 2009-04-12 16:03:33.000000000 +0200 | |
+++ ruby-1.9.1-p129-putstringfix-22395/iseq.c 2009-07-13 22:51:32.000000000 +0200 | |
@@ -23,6 +23,22 @@ | |
#define hidden_obj_p(obj) (!SPECIAL_CONST_P(obj) && !RBASIC(obj)->klass) | |
+static inline VALUE | |
+obj_resurrect(VALUE obj) | |
+{ | |
+ if (hidden_obj_p(obj)) { | |
+ switch (BUILTIN_TYPE(obj)) { | |
+ case T_STRING: | |
+ obj = rb_str_resurrect(obj); | |
+ break; | |
+ case T_ARRAY: | |
+ obj = rb_ary_resurrect(obj); | |
+ break; | |
+ } | |
+ } | |
+ return obj; | |
+} | |
+ | |
static void | |
compile_data_free(struct iseq_compile_data *compile_data) | |
{ | |
@@ -701,16 +717,7 @@ | |
op = ID2SYM(op); | |
case TS_VALUE: /* VALUE */ | |
- if (hidden_obj_p(op)) { | |
- switch (BUILTIN_TYPE(op)) { | |
- case T_STRING: | |
- op = rb_str_replace(rb_str_new(0, 0), op); | |
- break; | |
- case T_ARRAY: | |
- op = rb_ary_replace(rb_ary_new2(0), op); | |
- break; | |
- } | |
- } | |
+ op = obj_resurrect(op); | |
ret = rb_inspect(op); | |
if (CLASS_OF(op) == rb_cISeq) { | |
rb_ary_push(child, op); | |
@@ -1142,7 +1149,7 @@ | |
rb_ary_push(ary, INT2FIX(*seq)); | |
break; | |
case TS_VALUE: | |
- rb_ary_push(ary, *seq); | |
+ rb_ary_push(ary, obj_resurrect(*seq)); | |
break; | |
case TS_ISEQ: | |
{ | |
diff -urN ruby-1.9.1-p129/string.c ruby-1.9.1-p129-putstringfix-22395/string.c | |
--- ruby-1.9.1-p129/string.c 2009-05-04 14:30:06.000000000 +0200 | |
+++ ruby-1.9.1-p129-putstringfix-22395/string.c 2009-07-13 22:52:40.000000000 +0200 | |
@@ -829,6 +829,11 @@ | |
return str_duplicate(rb_obj_class(str), str); | |
} | |
+VALUE | |
+rb_str_resurrect(VALUE str) | |
+{ | |
+ return rb_str_replace(str_alloc(rb_cString), str); | |
+} | |
/* | |
* call-seq: | |
diff -urN ruby-1.9.1-p129/vm_core.h ruby-1.9.1-p129-putstringfix-22395/vm_core.h | |
--- ruby-1.9.1-p129/vm_core.h 2009-02-22 13:49:28.000000000 +0100 | |
+++ ruby-1.9.1-p129-putstringfix-22395/vm_core.h 2009-07-13 22:49:26.000000000 +0200 | |
@@ -596,6 +596,9 @@ | |
#define sysstack_error GET_VM()->special_exceptions[ruby_error_sysstack] | |
+VALUE rb_str_resurrect(VALUE str); | |
+VALUE rb_ary_resurrect(VALUE ary); | |
+ | |
/* for thread */ | |
#if RUBY_VM_THREAD_MODEL == 2 | |
diff -urN ruby-1.9.1-p129/vm.inc ruby-1.9.1-p129-putstringfix-22395/vm.inc | |
--- ruby-1.9.1-p129/vm.inc 2009-05-12 07:38:54.000000000 +0200 | |
+++ ruby-1.9.1-p129-putstringfix-22395/vm.inc 2009-07-13 22:38:12.000000000 +0200 | |
@@ -546,7 +546,7 @@ | |
USAGE_ANALYSIS_OPERAND(BIN(putstring), 0, str); | |
{ | |
#line 376 "insns.def" | |
- val = rb_str_replace(rb_str_new(0, 0), str); | |
+ val = rb_str_resurrect(str); | |
#line 552 "vm.inc" | |
PUSH(val); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment