summaryrefslogtreecommitdiff
path: root/class.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-07-11 08:24:54 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-07-11 08:24:54 +0000
commitfefba453856ff9dfe5ecb0b1e04888c6f14b2383 (patch)
treee4ac3ce8b1d657c893ce2e79d40ca183e625c846 /class.c
parent8e1d1358b689a13b4706754a2ab3fbcd7ef1d683 (diff)
* 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
Diffstat (limited to 'class.c')
-rw-r--r--class.c19
1 files changed, 15 insertions, 4 deletions
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;