diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-04-10 08:37:12 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-04-10 08:37:12 +0000 |
commit | e74149056bae388e35d4a4cab8cfa38114eb16b1 (patch) | |
tree | 2c2f889b16d8583f32bddc6311e596b369fa3346 | |
parent | dc08e8a60f3ea931598f7d240c76ad3f09ae3cef (diff) |
* variable.c (rb_mod_name): always return empty string for
anonymous class/module. (ruby-bugs-ja PR#424)
* config.sub: stop forcing addition of -gnu to -linux.
* variable.c (classname): refactoring.
* variable.c (rb_class_path): __tmp__classpath__ handling moved
from classname().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3664 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 11 | ||||
-rw-r--r-- | config.sub | 4 | ||||
-rw-r--r-- | eval.c | 29 | ||||
-rw-r--r-- | parse.y | 4 | ||||
-rw-r--r-- | variable.c | 56 |
5 files changed, 55 insertions, 49 deletions
@@ -1,7 +1,14 @@ Thu Apr 10 03:22:38 2003 Yukihiro Matsumoto <matz@ruby-lang.org> - * variable.c (rb_mod_name): search module path if classname is not - set yet. (ruby-bugs-ja PR#424) + * variable.c (rb_mod_name): always return empty string for + anonymous class/module. (ruby-bugs-ja PR#424) + + * config.sub: stop forcing addition of -gnu to -linux. + + * variable.c (classname): refactoring. + + * variable.c (rb_class_path): __tmp__classpath__ handling moved + from classname(). Thu Apr 10 01:52:24 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net> diff --git a/config.sub b/config.sub index 04baf3d80d..d2c7af03c5 100644 --- a/config.sub +++ b/config.sub @@ -1093,7 +1093,7 @@ case $os in os=-sysv4.2uw ;; -gnu/linux*) - os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` + os=`echo $os | sed -e 's|gnu/linux|linux|'` ;; # First accept the basic system types. # The portable systems comes first. @@ -1143,7 +1143,7 @@ case $os in os=`echo $os | sed -e 's|mac|macos|'` ;; -linux*) - os=`echo $os | sed -e 's|linux|linux-gnu|'` + os=-linux ;; -sunos5*) os=`echo $os | sed -e 's|sunos5|solaris2|'` @@ -6080,20 +6080,6 @@ rb_obj_call_init(obj, argc, argv) POP_ITER(); } -static VALUE -top_include(argc, argv) - int argc; - VALUE *argv; -{ - rb_secure(4); - if (ruby_wrapper) { - return rb_mod_include(argc, argv, ruby_wrapper); - } - else { - return rb_mod_include(argc, argv, rb_cObject); - } -} - void rb_extend_object(obj, module) VALUE obj, module; @@ -6127,6 +6113,21 @@ rb_obj_extend(argc, argv, obj) return obj; } +static VALUE +top_include(argc, argv) + int argc; + VALUE *argv; +{ + rb_secure(4); + if (ruby_wrapper) { + rb_obj_extend(argc, argv, ruby_top_self); + return rb_mod_include(argc, argv, ruby_wrapper); + } + else { + return rb_mod_include(argc, argv, rb_cObject); + } +} + VALUE rb_f_trace_var(); VALUE rb_f_untrace_var(); @@ -4271,10 +4271,10 @@ yylex() } if (ISDIGIT(c)) { if (tokidx == 1) { - rb_compile_error("`@%c' is not allowable as an instance variable name", c); + rb_compile_error("`@%c' is not allowed as an instance variable name", c); } else { - rb_compile_error("`@@%c' is not allowable as a class variable name", c); + rb_compile_error("`@@%c' is not allowed as a class variable name", c); } } if (!is_identchar(c)) { diff --git a/variable.c b/variable.c index 2f35d53116..05d2056b82 100644 --- a/variable.c +++ b/variable.c @@ -145,34 +145,23 @@ classname(klass) klass = rb_class_real(klass); if (!klass) klass = rb_cObject; - if (ROBJECT(klass)->iv_tbl && - !st_lookup(ROBJECT(klass)->iv_tbl, classpath, &path)) { - ID classid = rb_intern("__classid__"); + if (ROBJECT(klass)->iv_tbl) { + if (!st_lookup(ROBJECT(klass)->iv_tbl, classpath, &path)) { + ID classid = rb_intern("__classid__"); - if (st_lookup(ROBJECT(klass)->iv_tbl, classid, &path)) { + if (!st_lookup(ROBJECT(klass)->iv_tbl, classid, &path)) { + return Qnil; + } path = rb_str_new2(rb_id2name(SYM2ID(path))); st_insert(ROBJECT(klass)->iv_tbl, classpath, path); st_delete(RCLASS(klass)->iv_tbl, &classid, 0); } - } - if (NIL_P(path)) { - ID tmppath = rb_intern("__tmp_classpath__"); - - path = find_class_path(klass); - if (NIL_P(path)) { - if (!RCLASS(klass)->iv_tbl || - !st_lookup(RCLASS(klass)->iv_tbl, tmppath, &path)) { - return 0; - } - } - else if (RCLASS(klass)->iv_tbl) { - st_delete(RCLASS(klass)->iv_tbl, &tmppath, 0); + if (TYPE(path) != T_STRING) { + rb_bug("class path is not set properly"); } return path; } - if (TYPE(path) != T_STRING) - rb_bug("class path is not set properly"); - return path; + return Qnil; } VALUE @@ -181,8 +170,8 @@ rb_mod_name(mod) { VALUE path = classname(mod); - if (path) return rb_str_dup(path); - return rb_str_dup(rb_class_path(mod)); + if (!NIL_P(path)) return rb_str_dup(path); + return rb_str_new(0,0); } VALUE @@ -191,11 +180,20 @@ rb_class_path(klass) { VALUE path = classname(klass); - if (path) return path; + if (!NIL_P(path)) return path; else { - VALUE str; + ID tmppath = rb_intern("__tmp_classpath__"); char *s = "Class"; + path = find_class_path(klass); + if (!NIL_P(path)) { + st_delete(RCLASS(klass)->iv_tbl, &tmppath, 0); + return path; + } + if (RCLASS(klass)->iv_tbl && st_lookup(RCLASS(klass)->iv_tbl, tmppath, &path)) { + return path; + } + if (TYPE(klass) == T_MODULE) { if (rb_obj_class(klass) == rb_cModule) { s = "Module"; @@ -204,12 +202,12 @@ rb_class_path(klass) s = rb_class2name(RBASIC(klass)->klass); } } - str = rb_str_new(0, 2 + strlen(s) + 3 + 2 * SIZEOF_LONG + 1); - sprintf(RSTRING(str)->ptr, "#<%s:0x%lx>", s, klass); - RSTRING(str)->len = strlen(RSTRING(str)->ptr); - rb_iv_set(klass, "__tmp_classpath__", str); + path = rb_str_new(0, 2 + strlen(s) + 3 + 2 * SIZEOF_LONG + 1); + sprintf(RSTRING(path)->ptr, "#<%s:0x%lx>", s, klass); + RSTRING(path)->len = strlen(RSTRING(path)->ptr); + rb_iv_set(klass, "__tmp_classpath__", path); - return str; + return path; } } |