diff options
author | knu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-02-28 18:24:25 +0000 |
---|---|---|
committer | knu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-02-28 18:24:25 +0000 |
commit | 1f6241439eec1af9dff4ca09958e4094a55151f0 (patch) | |
tree | fce5a8c824470bb4e423fbb2e4b9fd8eac970d5e /ext | |
parent | 795f9afa859139f01af99527e9cfa054b4f49f8e (diff) | |
download | ruby-1f6241439eec1af9dff4ca09958e4094a55151f0.tar.gz ruby-1f6241439eec1af9dff4ca09958e4094a55151f0.tar.xz ruby-1f6241439eec1af9dff4ca09958e4094a55151f0.zip |
* ext/digest/digest.c (get_digest_base_metadata): Allow inheriting
Digest::Base subclasses, which was unintentionally made
impossible while restructuring Digest classes.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@11947 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r-- | ext/digest/digest.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/ext/digest/digest.c b/ext/digest/digest.c index 07484f897..c239be294 100644 --- a/ext/digest/digest.c +++ b/ext/digest/digest.c @@ -423,15 +423,19 @@ rb_digest_class_s_hexdigest(int argc, VALUE *argv, VALUE klass) static rb_digest_metadata_t * get_digest_base_metadata(VALUE klass) { + VALUE p; VALUE obj; rb_digest_metadata_t *algo; - if (rb_ivar_defined(klass, id_metadata) == Qfalse) { - /* This class should not be subclassed in Ruby */ - rb_notimplement(); + for (p = klass; p; p = RCLASS(p)->super) { + if (rb_ivar_defined(p, id_metadata)) { + obj = rb_ivar_get(p, id_metadata); + break; + } } - obj = rb_ivar_get(klass, id_metadata); + if (!p) + rb_raise(rb_eRuntimeError, "Digest::Base cannot be inherited in Ruby"); Data_Get_Struct(obj, rb_digest_metadata_t, algo); |