From: matz@... (Yukihiro Matsumoto) Date: 1997-08-29T13:05:20+09:00 Subject: [ruby-dev:323] Re: << まつもと ゆきひろです In message "[ruby-dev:322] Re: <<" on 97/08/29, Yukihiro Matsumoto writes: |まつもと ゆきひろです | |In message "[ruby-dev:321] Re: <<" | on 97/08/29, Yukihiro Matsumoto writes: | ||パッチを出します.他の件も解消できているはずです. | |問題が見つかりました.これは捨てて下さい.;_; 修正パッチです.ごめんなさい. # 今度は大丈夫だろうな. --- inits.c~ Wed Jan 29 12:58:20 1997 +++ inits.c Fri Aug 29 10:59:16 1997 @@ -23,3 +23,2 @@ #endif - Init_GC(); Init_eval(); @@ -46,2 +45,3 @@ Init_Math(); + Init_GC(); Init_ext(); --- variable.c~ Fri Aug 29 10:22:33 1997 +++ variable.c Fri Aug 29 12:50:51 1997 @@ -114,3 +114,8 @@ arg.prev = 0; - st_foreach(RCLASS(cObject)->iv_tbl, fc_i, &arg); + if (RCLASS(cObject)->iv_tbl) { + st_foreach(RCLASS(cObject)->iv_tbl, fc_i, &arg); + } + if (arg.name == 0) { + st_foreach(class_tbl, fc_i, &arg); + } if (arg.name) { @@ -122,4 +127,4 @@ -VALUE -rb_class_path(class) +static VALUE +classname(class) VALUE class; @@ -128,3 +133,3 @@ - while (TYPE(class) == T_ICLASS || FL_TEST(class, FL_SINGLETON)) { + while (TYPE(class) == T_ICLASS || FL_TEST(class, FL_SINGLETON)) { class = (VALUE)RCLASS(class)->super; @@ -133,10 +138,11 @@ if (NIL_P(path)) { + path = rb_iv_get(class, "__classid__"); + if (!NIL_P(path)) { + path = str_new2(rb_id2name(FIX2INT(path))); + } + } + if (NIL_P(path)) { path = find_class_path(class); if (NIL_P(path)) { - char buf[256]; - char *s = "Class"; - - if (TYPE(class) == T_MODULE) s = "Module"; - sprintf(buf, "#<%s 0x%x>", s, class); - return str_new2(buf); + return 0; } @@ -148,2 +154,28 @@ +mod_name(mod) + VALUE mod; +{ + VALUE path = classname(mod); + + if (path) return path; + return str_new(0,0); +} + +VALUE +rb_class_path(class) + VALUE class; +{ + VALUE path = classname(class); + + if (path) return path; + else { + char buf[256]; + char *s = "Class"; + + if (TYPE(class) == T_MODULE) s = "Module"; + sprintf(buf, "#<%s 0x%x>", s, class); + return str_new2(buf); + } +} + void @@ -182,24 +214,10 @@ { - rb_iv_set(class, "__classpath__", str_new2(rb_id2name(id))); -} + extern VALUE cString; -VALUE -mod_name(mod) - VALUE mod; -{ - VALUE path; - - while (TYPE(mod) == T_ICLASS || FL_TEST(mod, FL_SINGLETON)) { - mod = (VALUE)RCLASS(mod)->super; + if (cString) { + rb_iv_set(class, "__classpath__", str_new2(rb_id2name(id))); } - path = rb_iv_get(mod, "__classpath__"); - if (NIL_P(path)) { - path = find_class_path(mod); - if (NIL_P(path)) { - return str_new(0,0); - } - return path; + else { + rb_iv_set(class, "__classid__", INT2FIX(id)); } - if (TYPE(path) != T_STRING) Bug("class path is not set properly"); - return path; } --- parse.y~ Fri Aug 29 11:43:57 1997 +++ parse.y Fri Aug 29 11:53:07 1997 @@ -2167,4 +2167,4 @@ /* skip embedded rd document */ - if (strncmp(lex_p, "begin", 5) == 0 && - (lex_p[5] == '\n' || lex_p[5] == '\r')) { + if (strncmp(lex_p, "begin", 5) == 0 && isspace(lex_p[5])) { + lex_p = lex_pend; for (;;) { @@ -2175,5 +2175,4 @@ if (c != '=') continue; - if (strncmp(lex_p, "end", 3) == 0 && - (lex_p[3] == '\n' || lex_p[3] == '\r')) { - lex_p += 3; /* sizeof "end" */ + if (strncmp(lex_p, "end", 3) == 0 && isspace(lex_p[3])) { + lex_p = lex_pend; break; @@ -2205,4 +2204,4 @@ if (lex_state != EXPR_END && c == '<') { - c = nextc(); - if (!isspace(c) && (strchr("\"'`", c) || isalpha(c))) { + int c2 = nextc(); + if (!isspace(c2) && (strchr("\"'`", c2) || isalpha(c2))) { if (!lex_input) { @@ -2210,4 +2209,5 @@ } - return here_document(c); + return here_document(c2); } + pushback(c2); }