summaryrefslogtreecommitdiff
path: root/string.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1998-04-16 07:42:49 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1998-04-16 07:42:49 +0000
commit94a1bece4a4adb5c0f8f09fb9b95356bae24912b (patch)
tree87c751178430d6471e391108c73d92cf25ad4af9 /string.c
parente0041160736f1c0f092400eb75336311ab10fa1e (diff)
flock,flatten,signal to main_thread
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/v1_1r@168 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r--string.c35
1 files changed, 20 insertions, 15 deletions
diff --git a/string.c b/string.c
index 086c872340..19321c09e5 100644
--- a/string.c
+++ b/string.c
@@ -84,23 +84,25 @@ VALUE
str_new4(orig)
VALUE orig;
{
- NEWOBJ(str, struct RString);
- OBJSETUP(str, cString, T_STRING);
-
- str->len = RSTRING(orig)->len;
- str->ptr = RSTRING(orig)->ptr;
if (RSTRING(orig)->orig) {
- str->orig = RSTRING(orig)->orig;
+ return str_freeze(RSTRING(orig)->orig);
+ }
+ else if (FL_TEST(orig, STR_FREEZE)) {
+ return orig;
}
else {
+ NEWOBJ(str, struct RString);
+ OBJSETUP(str, cString, T_STRING);
+
+ str->len = RSTRING(orig)->len;
+ str->ptr = RSTRING(orig)->ptr;
RSTRING(orig)->orig = (VALUE)str;
str->orig = 0;
+ if (rb_safe_level() >= 3) {
+ FL_SET(str, STR_TAINT);
+ }
+ return (VALUE)str;
}
- if (rb_safe_level() >= 3) {
- FL_SET(str, STR_TAINT);
- }
-
- return (VALUE)str;
}
static void
@@ -362,12 +364,15 @@ str_frozen_p(str)
}
VALUE
-str_dup_freezed(str)
+str_dup_frozen(str)
VALUE str;
{
- str = str_dup(str);
- str_freeze(str);
- return str;
+ if (RSTRING(str)->orig) {
+ return str_freeze(RSTRING(str)->orig);
+ }
+ if (FL_TEST(str, STR_FREEZE))
+ return str;
+ return str_freeze(str_dup(str));
}
VALUE