From c5fc4bca6d45ac58be7ccba26fbb90664643eab3 Mon Sep 17 00:00:00 2001 From: matz Date: Tue, 3 Jun 2003 09:40:21 +0000 Subject: [PATCH] * eval.c (rb_call_super): inheritance line adjustment moved from rb_call(). [ruby-core:01113] * eval.c (rb_eval): use rb_call_super() to follow DRY principle. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3901 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 7 +++++++ eval.c | 45 ++++++++++++++++++++---------------------- ext/tk/lib/tk.rb | 28 +++++++++++++------------- ext/tk/lib/tkcanvas.rb | 6 +++--- ext/tk/lib/tkentry.rb | 2 +- ext/tk/lib/tktext.rb | 10 +++++----- lib/net/imap.rb | 4 ++-- lib/net/telnet.rb | 8 ++++++++ lib/optparse.rb | 2 +- 9 files changed, 62 insertions(+), 50 deletions(-) diff --git a/ChangeLog b/ChangeLog index 29fd4971c6..328fef9463 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Tue Jun 3 09:59:27 2003 Yukihiro Matsumoto + + * eval.c (rb_call_super): inheritance line adjustment moved from + rb_call(). [ruby-core:01113] + + * eval.c (rb_eval): use rb_call_super() to follow DRY principle. + Mon Jun 2 02:20:52 2003 Yukihiro Matsumoto * array.c (push_values_at): Array#values_at should work with diff --git a/eval.c b/eval.c index 07aad2a963..2dff10bcdb 100644 --- a/eval.c +++ b/eval.c @@ -3021,12 +3021,8 @@ rb_eval(self, n) END_CALLARGS; } - PUSH_ITER(ruby_iter->iter?ITER_PRE:ITER_NOT); SET_CURRENT_SOURCE(); - result = rb_call(RCLASS(ruby_frame->last_class)->super, - ruby_frame->self, ruby_frame->orig_func, - argc, argv, 3); - POP_ITER(); + result = rb_call_super(argc, argv); } break; @@ -5041,7 +5037,6 @@ rb_call(klass, recv, mid, argc, argv, scope) int noex; ID id = mid; struct cache_entry *ent; - VALUE k = klass; if (!klass) { rb_raise(rb_eNotImpError, "method `%s' called on terminated object (0x%lx)", @@ -5052,7 +5047,7 @@ rb_call(klass, recv, mid, argc, argv, scope) if (ent->mid == mid && ent->klass == klass) { if (!ent->method) return rb_undefined(recv, mid, argc, argv, scope==2?CSTAT_VCALL:0); - k = ent->origin; + klass = ent->origin; id = ent->mid0; noex = ent->noex; body = ent->method; @@ -5063,19 +5058,6 @@ rb_call(klass, recv, mid, argc, argv, scope) } return rb_undefined(recv, mid, argc, argv, scope==2?CSTAT_VCALL:0); } - if (BUILTIN_TYPE(k) == T_MODULE) { - while (!(BUILTIN_TYPE(klass) == T_ICLASS && RBASIC(klass)->klass == k)) { - klass = RCLASS(klass)->super; - if (!klass) { - rb_raise(rb_eTypeError, "%s is not included in %s", - rb_class2name(k), - rb_class2name(CLASS_OF(recv))); - } - } - } - else { - klass = k; - } if (mid != missing) { /* receiver specified form for private method */ @@ -5187,7 +5169,7 @@ rb_call_super(argc, argv) int argc; const VALUE *argv; { - VALUE result; + VALUE result, self, klass, k; if (ruby_frame->last_class == 0) { rb_name_error(ruby_frame->last_func, @@ -5195,10 +5177,25 @@ rb_call_super(argc, argv) rb_id2name(ruby_frame->last_func)); } + self = ruby_frame->self; + klass = CLASS_OF(self); + k = ruby_frame->last_class; + if (BUILTIN_TYPE(k) == T_MODULE) { + while (!(BUILTIN_TYPE(klass) == T_ICLASS && RBASIC(klass)->klass == k)) { + klass = RCLASS(klass)->super; + if (!klass) { + rb_raise(rb_eTypeError, "%s is not included in %s", + rb_class2name(k), + rb_class2name(CLASS_OF(self))); + } + } + } + else { + klass = k; + } + PUSH_ITER(ruby_iter->iter?ITER_PRE:ITER_NOT); - result = rb_call(RCLASS(ruby_frame->last_class)->super, - ruby_frame->self, ruby_frame->last_func, - argc, argv, 3); + result = rb_call(RCLASS(klass)->super, self, ruby_frame->last_func, argc, argv, 3); POP_ITER(); return result; diff --git a/ext/tk/lib/tk.rb b/ext/tk/lib/tk.rb index b908aaa240..701392c875 100644 --- a/ext/tk/lib/tk.rb +++ b/ext/tk/lib/tk.rb @@ -441,11 +441,11 @@ module TkComm private :install_bind, :tk_event_sequence, :_bind_core, :_bind, :_bind_append, :_bind_remove, :_bindinfo - def bind(tagOrClass, context, cmd=Proc.new, args=nil) + def bind(tagOrClass, context, cmd=Block.new, args=nil) _bind(["bind", tagOrClass], context, cmd, args) end - def bind_append(tagOrClass, context, cmd=Proc.new, args=nil) + def bind_append(tagOrClass, context, cmd=Block.new, args=nil) _bind_append(["bind", tagOrClass], context, cmd, args) end @@ -457,11 +457,11 @@ module TkComm _bindinfo(['bind', tagOrClass], context) end - def bind_all(context, cmd=Proc.new, args=nil) + def bind_all(context, cmd=Block.new, args=nil) _bind(['bind', 'all'], context, cmd, args) end - def bind_append_all(context, cmd=Proc.new, args=nil) + def bind_append_all(context, cmd=Block.new, args=nil) _bind_append(['bind', 'all'], context, cmd, args) end @@ -513,7 +513,7 @@ module TkCore fail TkCallbackContinue, "Tk callback returns 'continue' status" end - def after(ms, cmd=Proc.new) + def after(ms, cmd=Block.new) myid = _curr_cmd_id cmdid = install_cmd(cmd) tk_call("after",ms,cmdid) @@ -531,7 +531,7 @@ module TkCore # end end - def after_idle(cmd=Proc.new) + def after_idle(cmd=Block.new) myid = _curr_cmd_id cmdid = install_cmd(cmd) tk_call('after','idle',cmdid) @@ -871,10 +871,10 @@ module Tk end module Scrollable - def xscrollcommand(cmd=Proc.new) + def xscrollcommand(cmd=Block.new) configure_cmd 'xscrollcommand', cmd end - def yscrollcommand(cmd=Proc.new) + def yscrollcommand(cmd=Block.new) configure_cmd 'yscrollcommand', cmd end def xview(*index) @@ -1103,11 +1103,11 @@ else end module TkBindCore - def bind(context, cmd=Proc.new, args=nil) + def bind(context, cmd=Block.new, args=nil) Tk.bind(to_eval, context, cmd, args) end - def bind_append(context, cmd=Proc.new, args=nil) + def bind_append(context, cmd=Block.new, args=nil) Tk.bind_append(to_eval, context, cmd, args) end @@ -2161,7 +2161,7 @@ module TkOption proc_str = TkOption.get(self::CARRIER, id.id2name, '') proc_str = '{' + proc_str + '}' unless /\A\{.*\}\Z/ =~ proc_str proc_str = __check_proc_string__(proc_str) - res_proc = eval 'Proc.new' + proc_str + res_proc = eval 'Block.new' + proc_str self::METHOD_TBL[id] = res_proc end proc{ @@ -2840,7 +2840,7 @@ class TkWindow)) will be returned. -: add_response_handler(handler = Proc.new) +: add_response_handler(handler = Block.new) Adds a response handler. ex). @@ -1047,7 +1047,7 @@ module Net return sort_internal("UID SORT", sort_keys, search_keys, charset) end - def add_response_handler(handler = Proc.new) + def add_response_handler(handler = Block.new) @response_handlers.push(handler) end diff --git a/lib/net/telnet.rb b/lib/net/telnet.rb index b03cbc7a73..89bb8ef044 100644 --- a/lib/net/telnet.rb +++ b/lib/net/telnet.rb @@ -480,6 +480,14 @@ module Net buf = preprocess(c) rest = '' end + else + # Not Telnetmode. + # + # We cannot use preprocess() on this data, because that + # method makes some Telnetmode-specific assumptions. + buf = c + buf.gsub!(/#{EOL}/no, "\n") unless @options["Binmode"] + rest = '' end @log.print(buf) if @options.has_key?("Output_log") line += buf diff --git a/lib/optparse.rb b/lib/optparse.rb index 295f2bc94b..7a2cfc49c9 100644 --- a/lib/optparse.rb +++ b/lib/optparse.rb @@ -167,7 +167,7 @@ Individual switch class. =end #'#"#`# def initialize(pattern = nil, conv = nil, short = nil, long = nil, arg = nil, - desc = ([] if short or long), block = Proc.new) + desc = ([] if short or long), block = Block.new) @pattern, @conv, @short, @long, @arg, @desc, @block = pattern, conv, short, long, arg, desc, block end