diff options
author | knu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2001-05-24 16:00:54 +0000 |
---|---|---|
committer | knu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2001-05-24 16:00:54 +0000 |
commit | d6e985ad0b6d47a914cc9c2f86a14e08fff4c267 (patch) | |
tree | d592e2434d8fb50efdc4ad6adc2f068b103adf9b /ext/sha1 | |
parent | dcd6223c648d1c6834873b69b9293e5b53258d5b (diff) | |
download | ruby-d6e985ad0b6d47a914cc9c2f86a14e08fff4c267.tar.gz |
* ext/sha1/sha1-ruby.c (md5i_new): separate initialize() from
new().
* ext/md5/md5init.c (sha1_new): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1448 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/sha1')
-rw-r--r-- | ext/sha1/sha1-ruby.c | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/ext/sha1/sha1-ruby.c b/ext/sha1/sha1-ruby.c index 760ce0f2b0..75b3826407 100644 --- a/ext/sha1/sha1-ruby.c +++ b/ext/sha1/sha1-ruby.c @@ -64,22 +64,32 @@ sha1_clone(obj) } static VALUE +sha1_init(argc, argv, self) + int argc; + VALUE* argv; + VALUE self; +{ + VALUE arg; + + rb_scan_args(argc, argv, "01", &arg); + + if (!NIL_P(arg)) sha1_update(self, arg); + + return self; +} + +static VALUE sha1_new(argc, argv, class) int argc; VALUE* argv; VALUE class; { - VALUE arg, obj; + VALUE obj; SHA1_CTX *sha1; - rb_scan_args(argc, argv, "01", &arg); - if (!NIL_P(arg)) Check_Type(arg, T_STRING); - obj = Data_Make_Struct(class, SHA1_CTX, 0, free, sha1); SHA1Init(sha1); - if (!NIL_P(arg)) { - sha1_update(obj, arg); - } + rb_obj_call_init(obj, argc, argv); return obj; } @@ -93,6 +103,7 @@ Init_sha1() rb_define_singleton_method(cSHA1, "sha1", sha1_new, -1); rb_define_method(cSHA1, "update", sha1_update, 1); + rb_define_method(cSHA1, "initialize", sha1_init, -1); rb_define_method(cSHA1, "<<", sha1_update, 1); rb_define_method(cSHA1, "digest", sha1_digest, 0); rb_define_method(cSHA1, "hexdigest", sha1_hexdigest, 0); |