From f678390e1f7e2e8556b160202a482baa64d67f9d Mon Sep 17 00:00:00 2001 From: knu Date: Fri, 13 Oct 2006 11:58:05 +0000 Subject: [PATCH] * ext/digest/digest.c (Init_digest): Digest::Base.new() does no longer take an initial string to feed. This change allows subclasses to take hashing parameters. A statement such as ``md = Digest::MD5.new(s)'' can be easily rewritten as ``md = Digest::MD5.new << s'' or ``md = Digest::MD5.new.update(s)''. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11154 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 9 +++++++++ ext/digest/digest.c | 13 ------------- test/digest/test_digest.rb | 3 ++- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index 22dbe12cff..0bcc8b53df 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +Fri Oct 13 20:53:37 2006 Akinori MUSHA + + * ext/digest/digest.c (Init_digest): Digest::Base.new() does no + longer take an initial string to feed. This change allows + subclasses to take hashing parameters. A statement such as + ``md = Digest::MD5.new(s)'' can be easily rewritten as + ``md = Digest::MD5.new << s'' or + ``md = Digest::MD5.new.update(s)''. + Fri Oct 13 20:51:55 2006 Akinori MUSHA * ext/digest/digest.c, ext/digest/md5/md5init.c, diff --git a/ext/digest/digest.c b/ext/digest/digest.c index fa3fd3bfa1..d30d96fbbd 100644 --- a/ext/digest/digest.c +++ b/ext/digest/digest.c @@ -259,18 +259,6 @@ rb_digest_base_lshift(VALUE self, VALUE str) return self; } -static VALUE -rb_digest_base_init(int argc, VALUE *argv, VALUE self) -{ - VALUE arg; - - rb_scan_args(argc, argv, "01", &arg); - - if (!NIL_P(arg)) rb_digest_base_update(self, arg); - - return self; -} - /* * call-seq: * digest_obj.digest -> string @@ -402,7 +390,6 @@ Init_digest(void) rb_define_singleton_method(cDigest_Base, "digest", rb_digest_base_s_digest, 1); rb_define_singleton_method(cDigest_Base, "hexdigest", rb_digest_base_s_hexdigest, 1); - rb_define_method(cDigest_Base, "initialize", rb_digest_base_init, -1); rb_define_method(cDigest_Base, "initialize_copy", rb_digest_base_copy, 1); rb_define_method(cDigest_Base, "reset", rb_digest_base_reset, 0); rb_define_method(cDigest_Base, "update", rb_digest_base_update, 1); diff --git a/test/digest/test_digest.rb b/test/digest/test_digest.rb index 5cc9a99c01..fa12086300 100644 --- a/test/digest/test_digest.rb +++ b/test/digest/test_digest.rb @@ -43,7 +43,8 @@ module TestDigest def test_eq # This test is also for clone() - md1 = self.class::ALGO.new("ABC") + md1 = self.class::ALGO.new + md1 << "ABC" assert_equal(md1, md1.clone, self.class::ALGO)