From 287810940070b1c7b0cc915e6728da2f0aaac5e2 Mon Sep 17 00:00:00 2001 From: matz Date: Thu, 30 Apr 1998 07:41:23 +0000 Subject: new exception model git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/v1_1r@199 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/debug.rb | 7 +++++++ lib/delegate.rb | 2 +- lib/tk.rb | 21 ++++++++++++++------- 3 files changed, 22 insertions(+), 8 deletions(-) (limited to 'lib') diff --git a/lib/debug.rb b/lib/debug.rb index 432c7b4d19..2e3a29aa9e 100644 --- a/lib/debug.rb +++ b/lib/debug.rb @@ -11,6 +11,8 @@ class DEBUGGER__ @scripts = {} end + DEBUG_LAST_CMD = [] + def interrupt @stop_next = 1 end @@ -40,6 +42,11 @@ class DEBUGGER__ STDOUT.flush while input = STDIN.gets input.chop! + if input == "" + input = DEBUG_LAST_CMD[0] + else + DEBUG_LAST_CMD[0] = input + end case input when /^b(reak)?\s+(([^:\n]+:)?.+)/ pos = $2 diff --git a/lib/delegate.rb b/lib/delegate.rb index c73a3bd8a0..bc6f876212 100644 --- a/lib/delegate.rb +++ b/lib/delegate.rb @@ -7,7 +7,7 @@ # # Usage: # foo = Object.new -# foo = SimpleDelegator.new(foo) +# foo2 = SimpleDelegator.new(foo) # foo.hash == foo2.hash # => true class Delegator diff --git a/lib/tk.rb b/lib/tk.rb index 8c361c03e5..213fc54de7 100644 --- a/lib/tk.rb +++ b/lib/tk.rb @@ -113,7 +113,6 @@ module TkComm end end def list(val) - p val tk_split_list(val).to_a end def window(val) @@ -274,7 +273,7 @@ module TkCore end def _get_eval_string(str) - return str if str == None + return nil if str == None if str.kind_of?(Hash) str = hash_kv(str).join(" ") elsif str == nil @@ -294,10 +293,20 @@ module TkCore def tk_call(*args) print args.join(" "), "\n" if $DEBUG args.filter {|x|_get_eval_string(x)} - args.delete!(None) - args.flatten! args.compact! - res = INTERP._invoke(*args) + args.flatten! + begin + res = INTERP._invoke(*args) + rescue NameError + err = $! + begin + args.unshift "unknown" + res = INTERP._invoke(*args) + rescue + raise unless /^invalid command/ =~ $! + raise err + end + end if INTERP._return_value() != 0 fail RuntimeError, res, error_at end @@ -819,8 +828,6 @@ class TkObject