From fefba453856ff9dfe5ecb0b1e04888c6f14b2383 Mon Sep 17 00:00:00 2001 From: matz Date: Thu, 11 Jul 2002 08:24:54 +0000 Subject: * string.c (rb_str_slice_bang): if there's no corresponding substring, slice! should return nil without exception. * string.c (rb_str_split_m): accept separator value nil as well. * class.c (include_class_new): module may be T_ICLASS; retrieve original module information. * re.c (rb_reg_expr_str): need to process backslashes properly. * parse.y (yylex): no here document after a dot. * parse.y (yylex): should have set lex_state properly after '`'. * parse.y (yylex): should have set lex_state properly after tOP_ASGN. * bignum.c (rb_big2dbl): return canonical HUGE_VAL for infinity. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_6@2633 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- class.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'class.c') diff --git a/class.c b/class.c index a7d2fed562..15f060d4e9 100644 --- a/class.c +++ b/class.c @@ -290,6 +290,9 @@ include_class_new(module, super) NEWOBJ(klass, struct RClass); OBJSETUP(klass, rb_cClass, T_ICLASS); + if (BUILTIN_TYPE(module) == T_ICLASS) { + module = RBASIC(module)->klass; + } if (!RCLASS(module)->iv_tbl) { RCLASS(module)->iv_tbl = st_init_numtable(); } @@ -331,19 +334,27 @@ rb_include_module(klass, module) c = klass; while (module) { + int superclass_seen = Qfalse; + if (RCLASS(klass)->m_tbl == RCLASS(module)->m_tbl) rb_raise(rb_eArgError, "cyclic include detected"); /* ignore if the module included already in superclasses */ for (p = RCLASS(klass)->super; p; p = RCLASS(p)->super) { - if (BUILTIN_TYPE(p) == T_ICLASS) { + switch (BUILTIN_TYPE(p)) { + case T_ICLASS: if (RCLASS(p)->m_tbl == RCLASS(module)->m_tbl) { - c = p; + if (!superclass_seen) { + c = p; /* move insertion point */ + } goto skip; } + break; + case T_CLASS: + superclass_seen = Qtrue; + break; } } - RCLASS(c)->super = include_class_new(module, RCLASS(c)->super); - c = RCLASS(c)->super; + c = RCLASS(c)->super = include_class_new(module, RCLASS(c)->super); changed = 1; skip: module = RCLASS(module)->super; -- cgit v1.2.3