Revision: 3692 http://trac.macosforge.org/projects/ruby/changeset/3692 Author: lsansonetti@apple.com Date: 2010-03-03 22:03:57 -0800 (Wed, 03 Mar 2010) Log Message: ----------- fixed misc bugs in #dump and #inspect Modified Paths: -------------- MacRuby/branches/icu/string.c Modified: MacRuby/branches/icu/string.c =================================================================== --- MacRuby/branches/icu/string.c 2010-03-04 05:32:03 UTC (rev 3691) +++ MacRuby/branches/icu/string.c 2010-03-04 06:03:57 UTC (rev 3692) @@ -2395,15 +2395,17 @@ const long len = uchars ? str_length(str, true) : str->length_in_bytes; + VALUE result; if (len == 0) { - return rb_str_new2("\"\""); + result = rb_str_new2("\"\""); + goto bail; } // Allocate an UTF-8 string with a good initial capacity. // Binary strings will likely have most bytes escaped. const long result_init_len = BINARY_ENC(str->encoding) ? (len * 5) + 2 : len + 2; - VALUE result = rb_unicode_str_new(NULL, result_init_len); + result = rb_unicode_str_new(NULL, result_init_len); #define GET_UCHAR(pos) \ ((uchars \ @@ -2464,6 +2466,10 @@ #undef GET_UCHAR +bail: + if (OBJ_TAINTED(str)) { + OBJ_TAINT(result); + } return result; } @@ -2484,7 +2490,9 @@ static VALUE rstr_dump(VALUE self, SEL sel) { - return str_inspect(RSTR(self), true); + VALUE res = str_inspect(RSTR(self), true); + *(VALUE *)res = *(VALUE *)self; + return res; } /*