From 20f5f4816288b7344bcfaca128f32dc14a60c51a Mon Sep 17 00:00:00 2001 From: matz Date: Thu, 14 Nov 2002 06:18:59 +0000 Subject: * math.c (math_acos): check errno after operation. ditto for asin, acosh, atanh, log, log10 and sqrt. * eval.c (rb_add_method): initialize should always be private. * parse.y (expr): add rescue modifier rule. * parse.y (command_call): return, break and next with argument is now part of this rule. * parse.y (yylex): "a" in "a /5" should be considered as a local variable. [experimental] git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@3041 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/delegate.rb | 8 ++++---- lib/pstore.rb | 7 +++++-- 2 files changed, 9 insertions(+), 6 deletions(-) (limited to 'lib') diff --git a/lib/delegate.rb b/lib/delegate.rb index afd6a2abe..707bc2144 100644 --- a/lib/delegate.rb +++ b/lib/delegate.rb @@ -19,10 +19,10 @@ class Delegator def initialize(obj) - preserved = ::Kernel.instance_methods + preserved = ::Kernel.public_instance_methods preserved -= ["to_s","to_a","inspect","==","=~","==="] for t in self.class.ancestors - preserved |= t.instance_methods + preserved |= t.public_instance_methods preserved |= t.private_instance_methods preserved |= t.protected_instance_methods break if t == Delegator @@ -76,8 +76,8 @@ SimpleDelegater = SimpleDelegator # def DelegateClass(superclass) klass = Class.new - methods = superclass.instance_methods(true) - methods -= ::Kernel.instance_methods + methods = superclass.public_instance_methods(true) + methods -= ::Kernel.public_instance_methods methods |= ["to_s","to_a","inspect","==","=~","==="] klass.module_eval <<-EOS def initialize(obj) diff --git a/lib/pstore.rb b/lib/pstore.rb index dfec76e47..dd74f4fc2 100644 --- a/lib/pstore.rb +++ b/lib/pstore.rb @@ -102,7 +102,7 @@ class PStore file.flock(read_only ? File::LOCK_SH : File::LOCK_EX) if read_only @table = Marshal::load(file) - elsif orig and (content = file.read) != nil + elsif orig and (content = file.read) != "" @table = Marshal::load(content) size = content.size md5 = Digest::MD5.digest(content) @@ -118,7 +118,7 @@ class PStore @abort = true raise ensure - if !read_only && !@abort + if !read_only and !@abort file.rewind content = Marshal::dump(@table) if !md5 || size != content.size || md5 != Digest::MD5.digest(content) @@ -133,6 +133,9 @@ class PStore end end end + if @abort and !orig + File.unlink(@filename) + end @abort = false end ensure -- cgit