summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-02-29 08:05:32 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-02-29 08:05:32 +0000
commit4890f3a684aff94d93a5cc3f68fa8c67c1da6c19 (patch)
tree3e43148d3114380fff1418aa3ff6d01b157a97e4 /lib
parent0c123a83f0446204d974318b578236c949e5a01f (diff)
2000-02-29
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@629 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r--lib/debug.rb7
-rw-r--r--lib/singleton.rb2
-rw-r--r--lib/tempfile.rb10
3 files changed, 12 insertions, 7 deletions
diff --git a/lib/debug.rb b/lib/debug.rb
index 7807ebd..4497fd1 100644
--- a/lib/debug.rb
+++ b/lib/debug.rb
@@ -383,11 +383,12 @@ class DEBUGGER__
binding, binding_file, binding_line = @frames[frame_pos]
stdout.printf "#%d %s:%s\n", frame_pos, binding_file, binding_line
- when /^\s*fi(?:nish)?$/
- if frame_pos == 0
+ when /^\s*fin(?:ish)?$/
+ if frame_pos == @frames.size
stdout.print "\"finish\" not meaningful in the outermost frame.\n"
else
@finish_pos = @frames.size - frame_pos
+ p @finish_pos
frame_pos = 0
return
end
@@ -563,10 +564,10 @@ class DEBUGGER__
@frames.unshift [binding, file, line, id]
when 'return', 'end'
- @frames.shift
if @frames.size == @finish_pos
@stop_next = 1
end
+ @frames.shift
when 'end'
@frames.shift
diff --git a/lib/singleton.rb b/lib/singleton.rb
index 2785c77..235ba89 100644
--- a/lib/singleton.rb
+++ b/lib/singleton.rb
@@ -16,8 +16,8 @@ module Singleton
klass.instance_eval %{
@__instance__ = nil
def instance
+ Thread.critical = true
unless @__instance__
- Thread.critical = true
begin
@__instance__ = new
ensure
diff --git a/lib/tempfile.rb b/lib/tempfile.rb
index 11a8fba..c432285 100644
--- a/lib/tempfile.rb
+++ b/lib/tempfile.rb
@@ -15,9 +15,10 @@ require 'final'
class Tempfile < SimpleDelegator
Max_try = 10
- def Tempfile.callback(path)
+ def Tempfile.callback(path, data)
lambda{
print "removing ", path, "..." if $DEBUG
+ data[0].close if data[0]
if File.exist?(path)
File.unlink(path)
end
@@ -47,10 +48,12 @@ class Tempfile < SimpleDelegator
n += 1
end
- @clean_files = Tempfile.callback(tmpname)
+ @protect = []
+ @clean_files = Tempfile.callback(tmpname, @protect)
ObjectSpace.define_finalizer(self, @clean_files)
@tmpfile = File.open(tmpname, 'w+')
+ @protect[0] = @tmpfile
@tmpname = tmpname
super(@tmpfile)
Dir.rmdir(lock)
@@ -66,12 +69,13 @@ class Tempfile < SimpleDelegator
def open
@tmpfile.close if @tmpfile
@tmpfile = File.open(@tmpname, 'r+')
+ @protect[0] = @tmpfile
__setobj__(@tmpfile)
end
def close(real=false)
@tmpfile.close if @tmpfile
- @tmpfile = nil
+ @protect[0] = @tmpfile = nil
if real
@clean_files.call
ObjectSpace.undefine_finalizer(self)