summaryrefslogtreecommitdiff
path: root/string.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-11-13 08:19:52 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-11-13 08:19:52 +0000
commit7422ccdd9e2fb2b28844879d5117d8fdc000c944 (patch)
tree9a6e9129ad35a2c0306e222f4ad2c59163849ee8 /string.c
parent948ff2456bc7839817ea043b42b6423538ab873c (diff)
* signal.c (sighandle): should not re-register sighandler if
POSIX_SIGNAL is defined. * eval.c (error_print): errat array may be empty. * eval.c (rb_eval_cmd): should not upgrade safe level unless explicitly specified by argument newly added. * signal.c (sig_trap): should not allow tainted trap closure. * variable.c (rb_f_trace_var): should not allow trace_var on safe level higher than 3. * variable.c (rb_f_trace_var): should not allow tainted trace closure. * gc.c: do not use static stack until system stack overflows. * eval.c (eval): should call Exception#exception instead of calling rb_exc_new3() directly. * error.c (exc_exception): set "mesg" directly to the clone. it might be better to set mesg via some method for flexibility. * variable.c (cvar_override_check): should print original module name, if 'a' is T_ICLASS. * parse.y (yylex): float '1_.0' should not be allowed. * variable.c (var_getter): should care about var as Qfalse (ruby-bugs#PR199). * array.c (cmpint): <=> or block for {min,max} may return bignum. * array.c (sort_1): use rb_compint. * array.c (sort_2): ditto. * enum.c (min_ii): ditto. * enum.c (min_ii): ditto. * enum.c (max_i): ditto. * enum.c (max_ii): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1827 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r--string.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/string.c b/string.c
index 183db6a..01ee1b5 100644
--- a/string.c
+++ b/string.c
@@ -103,7 +103,7 @@ VALUE
rb_str_new3(str)
VALUE str;
{
- VALUE str2 = rb_obj_alloc(rb_cString);
+ VALUE str2 = rb_obj_alloc(rb_obj_class(str));
RSTRING(str2)->len = RSTRING(str)->len;
RSTRING(str2)->ptr = RSTRING(str)->ptr;
@@ -124,13 +124,13 @@ rb_str_new4(orig)
VALUE str;
if (FL_TEST(orig, STR_NO_ORIG)) {
- str = rb_str_new(RSTRING(orig)->ptr, RSTRING(orig)->len);
+ str = rb_str_new0(klass, RSTRING(orig)->ptr, RSTRING(orig)->len);
}
else {
str = rb_str_new3(RSTRING(orig)->orig);
+ RBASIC(str)->klass = klass;
}
OBJ_FREEZE(str);
- RBASIC(str)->klass = klass;
return str;
}
else {
@@ -139,7 +139,6 @@ rb_str_new4(orig)
RSTRING(str)->len = RSTRING(orig)->len;
RSTRING(str)->ptr = RSTRING(orig)->ptr;
RSTRING(orig)->orig = str;
- RSTRING(str)->orig = 0;
OBJ_INFECT(str, orig);
OBJ_FREEZE(str);
@@ -287,10 +286,11 @@ rb_str_dup(str)
if (OBJ_FROZEN(str)) str2 = rb_str_new3(str);
else if (FL_TEST(str, STR_NO_ORIG)) {
- str2 = rb_str_new(RSTRING(str)->ptr, RSTRING(str)->len);
+ str2 = rb_str_new0(klass, RSTRING(str)->ptr, RSTRING(str)->len);
}
else if (RSTRING(str)->orig) {
str2 = rb_str_new3(RSTRING(str)->orig);
+ RBASIC(str2)->klass = klass;
FL_UNSET(str2, FL_TAINT);
OBJ_INFECT(str2, str);
}
@@ -300,7 +300,6 @@ rb_str_dup(str)
if (FL_TEST(str, FL_EXIVAR))
rb_copy_generic_ivar(str2, str);
OBJ_INFECT(str2, str);
- RBASIC(str2)->klass = klass;
return str2;
}
@@ -448,6 +447,7 @@ str_independent(str)
if (!OBJ_TAINTED(str) && rb_safe_level() >= 4)
rb_raise(rb_eSecurityError, "Insecure: can't modify string");
if (!RSTRING(str)->orig || FL_TEST(str, STR_NO_ORIG)) return 1;
+ if (RBASIC(str)->flags == 0) abort();
if (TYPE(RSTRING(str)->orig) != T_STRING) rb_bug("non string str->orig");
return 0;
}