1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* eval.c (is_defined): defined?(Foo::Baz) should check constants

only, no methods.

* eval.c (is_defined): should not dump core on defined?(a::b)
  where a is not a class nor a module.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_6@2020 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2002-01-28 08:42:40 +00:00
parent 5f12cd3e24
commit c9cf552a91
7 changed files with 35 additions and 16 deletions

View file

@ -1,3 +1,11 @@
Mon Jan 28 13:29:41 2002 K.Kosako <kosako@sofnec.co.jp>
* eval.c (is_defined): defined?(Foo::Baz) should check constants
only, no methods.
* eval.c (is_defined): should not dump core on defined?(a::b)
where a is not a class nor a module.
Fri Jan 25 17:48:43 2002 WATANABE Hirofumi <eban@ruby-lang.org>
* configure.in (solaris): add '-shared' only for GNU ld.

13
class.c
View file

@ -304,7 +304,7 @@ void
rb_include_module(klass, module)
VALUE klass, module;
{
VALUE p;
VALUE p, c;
int changed = 0;
rb_frozen_class_p(klass);
@ -323,18 +323,19 @@ rb_include_module(klass, module)
Check_Type(module, T_MODULE);
}
c = klass;
while (module) {
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 &&
RCLASS(p)->m_tbl == RCLASS(module)->m_tbl) {
goto skip;
if (BUILTIN_TYPE(p) == T_ICLASS) {
if (RCLASS(p)->m_tbl == RCLASS(module)->m_tbl)
goto skip;
}
}
RCLASS(klass)->super = include_class_new(module, RCLASS(klass)->super);
klass = RCLASS(klass)->super;
RCLASS(c)->super = include_class_new(module, RCLASS(c)->super);
c = RCLASS(c)->super;
changed = 1;
skip:
module = RCLASS(module)->super;

4
eval.c
View file

@ -1871,8 +1871,9 @@ is_defined(self, node, buf)
case T_MODULE:
if (rb_const_defined_at(val, node->nd_mid))
return "constant";
break;
default:
if (rb_method_boundp(val, node->nd_mid, 1)) {
if (rb_method_boundp(CLASS_OF(val), node->nd_mid, 1)) {
return "method";
}
}
@ -6783,6 +6784,7 @@ umethod_bind(method, recv)
method = Data_Make_Struct(rb_cMethod,struct METHOD,bm_mark,free,bound);
*bound = *data;
bound->recv = recv;
bound->rklass = CLASS_OF(recv);
return method;
}

View file

@ -452,7 +452,7 @@ pty_getpty(self, command)
rfptr->f = fdopen(info.fd, "r");
rfptr->path = strdup(RSTRING(command)->ptr);
wfptr->mode = rb_io_mode_flags("w");
wfptr->mode = rb_io_mode_flags("w") | FMODE_SYNC;
wfptr->f = fdopen(dup(info.fd), "w");
wfptr->path = strdup(RSTRING(command)->ptr);

View file

@ -1317,7 +1317,7 @@ class TkVariable
opts = ['r','w','u'].find_all{|c| opts.index(c)}.join('')
idx = -1
newopts = ''
@trace_var.each_with_index{|i,e|
@trace_var.each_with_index{|e,i|
if idx < 0 && e[0] == opts && e[1] == cmd
idx = i
next
@ -1351,7 +1351,7 @@ class TkVariable
return unless @trace_elem[elem].kind_of? Array
opts = ['r','w','u'].find_all{|c| opts.index(c)}.join('')
idx = -1
@trace_elem[elem].each_with_index{|i,e|
@trace_elem[elem].each_with_index{|e,i|
if idx < 0 && e[0] == opts && e[1] == cmd
idx = i
next

View file

@ -173,8 +173,8 @@ class TkFont
TkFont.new(nil, nil).call_font_configure(path, *(args + [{}]))
else
begin
compound = Hash[*list(tk_call('font', 'configure',
fnt))].collect{|key,value|
compound = Hash[*tk_split_simplelist(tk_call('font', 'configure',
fnt))].collect{|key,value|
[key[1..-1], value]
}.assoc('compound')[1]
rescue

View file

@ -813,12 +813,20 @@ class TkTextMark<TkObject
tk_call @t.path, 'mark', 'gravity', @id, direction
end
def next(index)
@t.tagid2obj(tk_call(@t.path, 'mark', 'next', index))
def next(index = nil)
if index
@t.tagid2obj(tk_call(@t.path, 'mark', 'next', index))
else
@t.tagid2obj(tk_call(@t.path, 'mark', 'next', @id))
end
end
def previous(index)
@t.tagid2obj(tk_call(@t.path, 'mark', 'previous', index))
def previous(index = nil)
if index
@t.tagid2obj(tk_call(@t.path, 'mark', 'previous', index))
else
@t.tagid2obj(tk_call(@t.path, 'mark', 'previous', @id))
end
end
end