diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-07-03 11:02:53 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-07-03 11:02:53 +0000 |
commit | 0a9bd7cd61ad99aca3ea3f3c8d0e6e3971def75c (patch) | |
tree | 58b15b4dc85acca1c806388ff3848a3c85fd0ebf /lib | |
parent | acabf0d25139902b4ae2d153f983b0f79faa7b7e (diff) | |
download | ruby-0a9bd7cd61ad99aca3ea3f3c8d0e6e3971def75c.tar.gz ruby-0a9bd7cd61ad99aca3ea3f3c8d0e6e3971def75c.tar.xz ruby-0a9bd7cd61ad99aca3ea3f3c8d0e6e3971def75c.zip |
* array.c (rb_values_at): extract common procedure from
rb_ary_values_at. follow DRY principle.
* re.c (match_values_at): values_at should understand ranges.
* struct.c (rb_struct_values_at): ditto.
* struct.c (inspect_struct): inspect format changed; add "struct "
at the top.
* sprintf.c (rb_f_sprintf): "%p" specifier for inspect output.
(RCR#68)
* eval.c (rb_mod_undef_method): allow "undef_method" to accept
multiple arguments. (RCR#146)
* lib/timeout.rb: put timeout in Timeout module. (RCR#121)
[ruby-talk:61028]
* re.c (match_groups): new method added. (RCR#139)
* variable.c (rb_mod_const_of): should exclude constant defined
in Object, unless retrieving constants of Object.
* string.c (rb_str_new4): do not allocate new string if original
is frozen or already have copy-on-write entry. [ruby-talk:74940]
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@4031 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r-- | lib/debug.rb | 2 | ||||
-rw-r--r-- | lib/irb/context.rb | 1 | ||||
-rw-r--r-- | lib/mkmf.rb | 1 | ||||
-rw-r--r-- | lib/timeout.rb | 41 |
4 files changed, 31 insertions, 14 deletions
diff --git a/lib/debug.rb b/lib/debug.rb index 0caeecb00..9275b47cd 100644 --- a/lib/debug.rb +++ b/lib/debug.rb @@ -700,9 +700,11 @@ EOHELP @line = line case event when 'line' + p [line, @stop_next] frame_set_pos(file, line) if !@no_step or @frames.size == @no_step @stop_next -= 1 + @stop_next = 0 if @stop_next < 0 elsif @frames.size < @no_step @stop_next = 0 # break here before leaving... else diff --git a/lib/irb/context.rb b/lib/irb/context.rb index 9022e8138..f1194f8db 100644 --- a/lib/irb/context.rb +++ b/lib/irb/context.rb @@ -177,6 +177,7 @@ module IRB @inspect_mode end + undef use_readline= def use_readline=(opt) @use_readline = opt print "use readline module\n" if @use_readline diff --git a/lib/mkmf.rb b/lib/mkmf.rb index 7ae234904..9b01d67c4 100644 --- a/lib/mkmf.rb +++ b/lib/mkmf.rb @@ -8,6 +8,7 @@ CONFIG = Config::MAKEFILE_CONFIG ORIG_LIBPATH = ENV['LIB'] SRC_EXT = ["c", "cc", "m", "cxx", "cpp", "C"] +$static = $config_h = nil unless defined? $configure_args $configure_args = {} diff --git a/lib/timeout.rb b/lib/timeout.rb index 8c6ccb712..00e60aff8 100644 --- a/lib/timeout.rb +++ b/lib/timeout.rb @@ -23,25 +23,38 @@ # # The time in seconds to wait for block teminatation. # +# : [exception] +# +# The exception classs to be raised on timeout. +# #=end -class TimeoutError<Interrupt -end +module Timeout + class Error<Interrupt + end -def timeout(sec, exception=TimeoutError) - return yield if sec == nil - begin - x = Thread.current - y = Thread.start { - sleep sec - x.raise exception, "execution expired" if x.alive? - } - yield sec -# return true - ensure - y.kill if y and y.alive? + def timeout(sec, exception=Error) + return yield if sec == nil + begin + x = Thread.current + y = Thread.start { + sleep sec + x.raise exception, "execution expired" if x.alive? + } + yield sec + # return true + ensure + y.kill if y and y.alive? + end end + module_function :timeout +end + +# compatible +def timeout(n, &block) + Timeout::timeout(n, &block) end +TimeoutError = Timeout::Error if __FILE__ == $0 p timeout(5) { |