* ext/digest/lib/digest.rb (Digest::self.const_missing): Drop

autoloads for sha2 classes in favor of handling in
  const_missing(), to work around a problem exposed on OS X.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11736 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
knu 2007-02-14 12:45:59 +00:00
parent b9084ef408
commit 559be019de
2 changed files with 18 additions and 10 deletions

View File

@ -1,3 +1,9 @@
Wed Feb 14 21:39:36 2007 Akinori MUSHA <knu@iDaemons.org>
* ext/digest/lib/digest.rb (Digest::self.const_missing): Drop
autoloads for sha2 classes in favor of handling in
const_missing(), to work around a problem exposed on OS X.
Wed Feb 14 21:19:47 2007 Koichi Sasada <ko1@atdot.net> Wed Feb 14 21:19:47 2007 Koichi Sasada <ko1@atdot.net>
* thread_pthread.ci (native_thread_create): adjust 4KB (page size) * thread_pthread.ci (native_thread_create): adjust 4KB (page size)

View File

@ -1,19 +1,21 @@
require 'digest.so' require 'digest.so'
module Digest module Digest
autoload "SHA256", "digest/sha2.so"
autoload "SHA384", "digest/sha2.so"
autoload "SHA512", "digest/sha2.so"
def self.const_missing(name) def self.const_missing(name)
begin case name
require File.join('digest', name.downcase) when :SHA256, :SHA384, :SHA512
lib = 'digest/sha2.so'
return Digest.const_get(name) if Digest.const_defined?(name) else
rescue LoadError => e lib = File.join('digest', name.to_s.downcase)
end end
raise NameError, "Digest class not found: Digest::#{name}" begin
require lib
rescue LoadError => e
raise LoadError, "library not found for class Digest::#{name} -- #{lib}"
end
Digest.const_get(name)
end end
class ::Digest::Class class ::Digest::Class