From 8eb7570850980e1849f07bbed57d1bda8351f064 Mon Sep 17 00:00:00 2001 From: knu Date: Wed, 11 Oct 2006 06:05:32 +0000 Subject: [PATCH] * ext/digest/digest.c (rb_digest_base_reset): Do not make recursive calls, but call initialize() when reset() is not defined in a subclass. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11125 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ ext/digest/digest.c | 14 +++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 93a17fb6e5..5772392272 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Wed Oct 11 15:03:55 2006 Akinori MUSHA + + * ext/digest/digest.c (rb_digest_base_reset): Do not make + recursive calls, but call initialize() when reset() is not + defined in a subclass. + Wed Oct 11 14:58:44 2006 Yukihiro Matsumoto * array.c (rb_ary_each): prohibit array modification during each diff --git a/ext/digest/digest.c b/ext/digest/digest.c index 0e3bf47a20..d95f8a6976 100644 --- a/ext/digest/digest.c +++ b/ext/digest/digest.c @@ -16,7 +16,7 @@ #include "digest.h" static VALUE mDigest, cDigest_Base; -static ID id_metadata, id_new, id_reset, id_update, id_digest; +static ID id_metadata, id_new, id_initialize, id_update, id_digest; /* * Digest::Base @@ -207,8 +207,10 @@ rb_digest_base_copy(VALUE copy, VALUE obj) rb_check_frozen(copy); algo = get_digest_base_metadata(rb_obj_class(copy)); - if (algo == NULL) + if (algo == NULL) { + /* subclasses must define initialize_copy() */ rb_notimplement(); + } /* get_digest_base_metadata() may return a NULL */ if (algo != get_digest_base_metadata(rb_obj_class(obj))) { @@ -230,7 +232,7 @@ rb_digest_base_reset(VALUE self) algo = get_digest_base_metadata(rb_obj_class(self)); if (algo == NULL) { - rb_funcall(self, id_reset, 0); + rb_funcall(self, id_initialize, 0); return self; } @@ -309,8 +311,10 @@ rb_digest_base_digest(VALUE self) algo = get_digest_base_metadata(rb_obj_class(self)); - if (algo == NULL) + if (algo == NULL) { + /* subclasses must define update() */ rb_notimplement(); + } Data_Get_Struct(self, void, pctx1); @@ -441,7 +445,7 @@ Init_digest(void) id_metadata = rb_intern("metadata"); id_new = rb_intern("new"); - id_reset = rb_intern("reset"); + id_initialize = rb_intern("initialize"); id_update = rb_intern("update"); id_digest = rb_intern("digest"); }