summaryrefslogtreecommitdiff
path: root/ext/digest/digest.c
diff options
context:
space:
mode:
authorknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-02-28 18:24:25 +0000
committerknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-02-28 18:24:25 +0000
commit04cd7cc62d8b16da8ccdff92f46e54e62ff26fab (patch)
treefce5a8c824470bb4e423fbb2e4b9fd8eac970d5e /ext/digest/digest.c
parent50d3ece900d8592907eb06b8eb77b4612e7e5020 (diff)
* 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: svn+ssh://ci.ruby-lang.org/ruby/trunk@11947 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/digest/digest.c')
-rw-r--r--ext/digest/digest.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/ext/digest/digest.c b/ext/digest/digest.c
index 07484f8..c239be2 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);