summaryrefslogtreecommitdiff
path: root/variable.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-09-05 09:42:56 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-09-05 09:42:56 +0000
commit49cd091cf24ba06d2cd019289815cd3f41c28d1f (patch)
tree889098fc7c624d1665a94d18564e776b059fd1f4 /variable.c
parent61ec0281a4327ef3d48eafa5f2b7eabffd9114e0 (diff)
downloadruby-49cd091cf24ba06d2cd019289815cd3f41c28d1f.tar.gz
* variable.c (rb_path2class): should not use rb_eval_string().
* marshal.c (w_extended): should allow marshaling of object which is extended by named module. * class.c (rb_make_metaclass): super may be T_ICLASS, need to skip. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2799 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'variable.c')
-rw-r--r--variable.c37
1 files changed, 29 insertions, 8 deletions
diff --git a/variable.c b/variable.c
index c37548fb91..18cd0c14ee 100644
--- a/variable.c
+++ b/variable.c
@@ -229,19 +229,40 @@ VALUE
rb_path2class(path)
const char *path;
{
- VALUE c;
+ const char *pbeg, *p;
+ ID id;
+ VALUE c = rb_cObject;
if (path[0] == '#') {
rb_raise(rb_eArgError, "can't retrieve anonymous class %s", path);
}
- c = rb_eval_string(path);
- switch (TYPE(c)) {
- case T_MODULE:
- case T_CLASS:
- break;
- default:
- rb_raise(rb_eTypeError, "class path %s does not point class", path);
+ pbeg = p = path;
+ while (*p) {
+ VALUE str;
+
+ while (*p && *p != ':') p++;
+ str = rb_str_new(pbeg, p-pbeg);
+ id = rb_intern(RSTRING(str)->ptr);
+ if (p[0] == ':') {
+ if (p[1] != ':') goto undefined_class;
+ p += 2;
+ pbeg = p;
+ }
+ if (!rb_const_defined(c, id)) {
+ undefined_class:
+ rb_raise(rb_eArgError, "undefined class/module %s", rb_id2name(id));
+ rb_raise(rb_eArgError, "undefined class/module %s", path);
+ }
+ c = rb_const_get_at(c, id);
+ switch (TYPE(c)) {
+ case T_MODULE:
+ case T_CLASS:
+ break;
+ default:
+ rb_raise(rb_eTypeError, "%s does not refer class/module %d", path, TYPE(c));
+ }
}
+
return c;
}