summaryrefslogtreecommitdiff
path: root/object.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-01-15 07:01:00 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-01-15 07:01:00 +0000
commit971a4d94f074916c6612edd2c3e1090ca71bc531 (patch)
tree6eca3839a0f276f5b36839407473c48e2c53ef67 /object.c
parentac8a2a31c2103abc249544469910ea3ff97f883c (diff)
Mon Jan 15 16:00:07 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
* pack.c (pack_unpack): should check associated pointer packed by pack("P"). restriction added. Sun Jan 14 21:49:28 2001 Koji Arai <JCA02266@nifty.ne.jp> * sprintf.c (rb_f_sprintf): simple typo. binary base should be 2, not '2'. * re.c (rb_reg_s_last_match): should explicitly return nth match. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1127 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
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 86a246f..6ded7b0 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;
}