summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog7
-rw-r--r--eval.c45
-rw-r--r--ext/tk/lib/tk.rb28
-rw-r--r--ext/tk/lib/tkcanvas.rb6
-rw-r--r--ext/tk/lib/tkentry.rb2
-rw-r--r--ext/tk/lib/tktext.rb10
-rw-r--r--lib/net/imap.rb4
-rw-r--r--lib/net/telnet.rb8
-rw-r--r--lib/optparse.rb2
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 <matz@ruby-lang.org>
+
+ * 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 <matz@ruby-lang.org>
* 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<TkObject
self
end
- def command(cmd=Proc.new)
+ def command(cmd=Block.new)
configure_cmd 'command', cmd
end
@@ -3458,10 +3458,10 @@ class TkMenu<TkWindow
def postcascade(index)
tk_send 'postcascade', index
end
- def postcommand(cmd=Proc.new)
+ def postcommand(cmd=Block.new)
configure_cmd 'postcommand', cmd
end
- def tearoffcommand(cmd=Proc.new)
+ def tearoffcommand(cmd=Block.new)
configure_cmd 'tearoffcommand', cmd
end
def menutype(index)
diff --git a/ext/tk/lib/tkcanvas.rb b/ext/tk/lib/tkcanvas.rb
index 4a5e4b45bb..7f0fba13ec 100644
--- a/ext/tk/lib/tkcanvas.rb
+++ b/ext/tk/lib/tkcanvas.rb
@@ -81,11 +81,11 @@ class TkCanvas<TkWindow
list(tk_send('bbox', tagid(tagOrId), *tags.collect{|t| tagid(t)}))
end
- def itembind(tag, context, cmd=Proc.new, args=nil)
+ def itembind(tag, context, cmd=Block.new, args=nil)
_bind([path, "bind", tagid(tag)], context, cmd, args)
end
- def itembind_append(tag, context, cmd=Proc.new, args=nil)
+ def itembind_append(tag, context, cmd=Block.new, args=nil)
_bind_append([path, "bind", tagid(tag)], context, cmd, args)
end
@@ -346,7 +346,7 @@ module TkcTagAccess
@c.bbox(@id)
end
- def bind(seq, cmd=Proc.new, args=nil)
+ def bind(seq, cmd=Block.new, args=nil)
@c.itembind @id, seq, cmd, args
end
diff --git a/ext/tk/lib/tkentry.rb b/ext/tk/lib/tkentry.rb
index 2772dfd676..f95fdf340d 100644
--- a/ext/tk/lib/tkentry.rb
+++ b/ext/tk/lib/tkentry.rb
@@ -38,7 +38,7 @@ class TkEntry<TkLabel
attr :widget
end
- def initialize(cmd = Proc.new, args=nil)
+ def initialize(cmd = Block.new, args=nil)
if args
@id = install_cmd(proc{|*arg|
TkUtil.eval_cmd cmd, *arg
diff --git a/ext/tk/lib/tktext.rb b/ext/tk/lib/tktext.rb
index dd4d649042..2db9a22bdf 100644
--- a/ext/tk/lib/tktext.rb
+++ b/ext/tk/lib/tktext.rb
@@ -172,11 +172,11 @@ class TkText<TkTextWin
tk_send 'tag', 'add', tag, index1, index2
end
- def tag_bind(tag, seq, cmd=Proc.new, args=nil)
+ def tag_bind(tag, seq, cmd=Block.new, args=nil)
_bind(['tag', 'bind', tag], seq, cmd, args)
end
- def tag_bind_append(tag, seq, cmd=Proc.new, args=nil)
+ def tag_bind_append(tag, seq, cmd=Block.new, args=nil)
_bind_append(['tag', 'bind', tag], seq, cmd, args)
end
@@ -419,7 +419,7 @@ class TkText<TkTextWin
def dump(type_info, *index, &block)
args = type_info.collect{|inf| '-' + inf}
- args << '-command' << Proc.new(&block) if iterator?
+ args << '-command' << block if block
str = tk_send('dump', *(args + index))
result = []
sel = nil
@@ -663,11 +663,11 @@ class TkTextTag<TkObject
@t.tag_configinfo @id, key
end
- def bind(seq, cmd=Proc.new, args=nil)
+ def bind(seq, cmd=Block.new, args=nil)
_bind([@t.path, 'tag', 'bind', @id], seq, cmd, args)
end
- def bind_append(seq, cmd=Proc.new, args=nil)
+ def bind_append(seq, cmd=Block.new, args=nil)
_bind_append([@t.path, 'tag', 'bind', @id], seq, cmd, args)
end
diff --git a/lib/net/imap.rb b/lib/net/imap.rb
index 2cbb408168..1007f2bdf6 100644
--- a/lib/net/imap.rb
+++ b/lib/net/imap.rb
@@ -263,7 +263,7 @@ Object
If this mailbox exists, an array containing objects of
((<Net::IMAP::MailboxACLItem>)) 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