diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-05-16 23:28:31 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-05-16 23:28:31 +0000 |
commit | 25fd1d7ff2de52b8670b50be68a5d09a5ddedd38 (patch) | |
tree | 3f9afe4bebd166e30e9f9c73cada34d2a51a6b7b /object.c | |
parent | ae8463b03c8882da342f0d4318175ab950280f0b (diff) |
* object.c (rb_class_allocate_instance): singleton class check
moved to rb_obj_alloc(). (ruby-bugs-ja PR#345)
* re.c (rb_reg_quote): should escape white space characters,
\t, \f, \n, \r. (ruby-bugs-ja PR#231)
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3811 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'object.c')
-rw-r--r-- | object.c | 17 |
1 files changed, 8 insertions, 9 deletions
@@ -730,8 +730,12 @@ VALUE rb_obj_alloc(klass) VALUE klass; { - VALUE obj = rb_funcall(klass, ID_ALLOCATOR, 0, 0); + VALUE obj; + if (FL_TEST(klass, FL_SINGLETON)) { + rb_raise(rb_eTypeError, "can't create instance of virtual class"); + } + obj = rb_funcall(klass, ID_ALLOCATOR, 0, 0); if (rb_obj_class(obj) != rb_class_real(klass)) { rb_raise(rb_eTypeError, "wrong instance allocation"); } @@ -743,14 +747,9 @@ static VALUE rb_class_allocate_instance(klass) VALUE klass; { - if (FL_TEST(klass, FL_SINGLETON)) { - rb_raise(rb_eTypeError, "can't create instance of virtual class"); - } - else { - NEWOBJ(obj, struct RObject); - OBJSETUP(obj, klass, T_OBJECT); - return (VALUE)obj; - } + NEWOBJ(obj, struct RObject); + OBJSETUP(obj, klass, T_OBJECT); + return (VALUE)obj; } VALUE |