summaryrefslogtreecommitdiff
path: root/object.c
diff options
context:
space:
mode:
Diffstat (limited to 'object.c')
-rw-r--r--object.c42
1 files changed, 27 insertions, 15 deletions
diff --git a/object.c b/object.c
index 86a246f1c3..6ded7b089d 100644
--- a/object.c
+++ b/object.c
@@ -162,6 +162,7 @@ inspect_i(id, value, str)
if (!rb_is_instance_id(id)) return ST_CONTINUE;
if (RSTRING(str)->ptr[0] == '-') { /* first element */
RSTRING(str)->ptr[0] = '#';
+ rb_str_cat2(str, " ");
}
else {
rb_str_cat2(str, ", ");
@@ -182,6 +183,7 @@ inspect_obj(obj, str)
{
st_foreach(ROBJECT(obj)->iv_tbl, inspect_i, str);
rb_str_cat2(str, ">");
+ RSTRING(str)->ptr[0] = '#';
OBJ_INFECT(str, obj);
return str;
@@ -205,7 +207,7 @@ rb_obj_inspect(obj)
return str;
}
str = rb_str_new(0, strlen(c)+6+16+1); /* 6:tags 16:addr 1:eos */
- sprintf(RSTRING(str)->ptr, "-<%s:0x%lx ", c, obj);
+ sprintf(RSTRING(str)->ptr, "-<%s:0x%lx", c, obj);
RSTRING(str)->len = strlen(RSTRING(str)->ptr);
return rb_protect_inspect(inspect_obj, obj, str);
}
@@ -286,10 +288,12 @@ rb_obj_taint(obj)
VALUE obj;
{
rb_secure(4);
- if (OBJ_FROZEN(obj)) {
- rb_error_frozen("object");
+ if (OBJ_TAINTED(obj)) {
+ if (OBJ_FROZEN(obj)) {
+ rb_error_frozen("object");
+ }
+ OBJ_TAINT(obj);
}
- OBJ_TAINT(obj);
return obj;
}
@@ -298,10 +302,12 @@ rb_obj_untaint(obj)
VALUE obj;
{
rb_secure(3);
- if (OBJ_FROZEN(obj)) {
- rb_error_frozen("object");
+ if (!OBJ_TAINTED(obj)) {
+ if (OBJ_FROZEN(obj)) {
+ rb_error_frozen("object");
+ }
+ FL_UNSET(obj, FL_TAINT);
}
- FL_UNSET(obj, FL_TAINT);
return obj;
}
@@ -309,10 +315,13 @@ VALUE
rb_obj_freeze(obj)
VALUE obj;
{
- if (rb_safe_level() >= 4 && !OBJ_TAINTED(obj))
- rb_raise(rb_eSecurityError, "Insecure: can't freeze object");
-
- OBJ_FREEZE(obj);
+ if (OBJ_FROZEN(obj)) {
+ if (rb_safe_level() >= 4 && !OBJ_TAINTED(obj)) {
+ rb_raise(rb_eSecurityError, "Insecure: can't freeze object");
+ }
+
+ OBJ_FREEZE(obj);
+ }
return obj;
}
@@ -538,11 +547,14 @@ rb_mod_clone(module)
}
static VALUE
-rb_mod_dup(module)
- VALUE module;
+rb_mod_dup(mod)
+ VALUE mod;
{
- VALUE dup = rb_mod_clone(module);
- OBJSETUP(dup, RBASIC(module)->klass, BUILTIN_TYPE(module));
+ VALUE dup = rb_mod_clone(mod);
+ OBJSETUP(dup, RBASIC(mod)->klass, BUILTIN_TYPE(mod));
+ if (FL_TEST(mod, FL_SINGLETON)) {
+ FL_SET(dup, FL_SINGLETON);
+ }
return dup;
}