summaryrefslogtreecommitdiff
path: root/string.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-10-13 13:05:24 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-10-13 13:05:24 +0000
commit1184373d867f0e4792b3a6da11acfd2cf4c0b330 (patch)
treec93cdc524880d4142cfe48dcb194207d05a34263 /string.c
parentb6f1c0e2846acbbc9d694b1207c778e1d6db63e3 (diff)
* string.c (str_new4): should not preserve FL_TAINT status in the
internal shared string. [ruby-dev:21601] * string.c (rb_str_new4): ditto. * eval.c: use EXIT_SUCCESS and EXIT_FAILURE for exit values. * process.c: ditto. [ruby-dev:38521] * lib/debug.rb (debug_command): should enter emacs mode when assigned any value to the environment variable "EMACS". On Meadow, (getenv "EMACS") is "meadow". git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4749 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r--string.c13
1 files changed, 3 insertions, 10 deletions
diff --git a/string.c b/string.c
index 67f4f8d..ddf530c 100644
--- a/string.c
+++ b/string.c
@@ -152,7 +152,6 @@ str_new4(klass, str)
FL_SET(str, ELTS_SHARED);
RSTRING(str)->aux.shared = str2;
}
- OBJ_INFECT(str2, str);
return str2;
}
@@ -177,7 +176,6 @@ rb_str_new4(orig)
}
else if (FL_TEST(orig, STR_ASSOC)) {
str = str_new(klass, RSTRING(orig)->ptr, RSTRING(orig)->len);
- OBJ_INFECT(str, orig);
}
else {
str = str_new4(klass, orig);
@@ -527,20 +525,15 @@ rb_str_substr(str, beg, len)
if (len == 0) return rb_str_new5(str,0,0);
if (len > sizeof(struct RString)/2 &&
- beg + len == RSTRING(str)->len &&
- !FL_TEST(str, STR_ASSOC)) {
- if (FL_TEST(str, ELTS_SHARED) && RSTRING(str)->aux.shared)
- str = RSTRING(str)->aux.shared;
- else
- str = str_new4(rb_obj_class(str), str);
- str2 = rb_str_new3(str);
+ beg + len == RSTRING(str)->len && !FL_TEST(str, STR_ASSOC)) {
+ str2 = rb_str_new3(rb_str_new4(str));
RSTRING(str2)->ptr += RSTRING(str2)->len - len;
RSTRING(str2)->len = len;
}
else {
str2 = rb_str_new5(str, RSTRING(str)->ptr+beg, len);
- OBJ_INFECT(str2, str);
}
+ OBJ_INFECT(str2, str);
return str2;
}