mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* ext/digest/digest.c: Improve RDoc documentation.
* ext/digest/digest.c (Init_digest, rb_digest_base_s_digest, rb_digest_base_s_hexdigest): Make Digest::Base::digest() and Digest::Base::hexdigest() take extra arguments, which are passed through to the constructor in an internal call. * ext/digest/bubblebabble/bubblebabble.c (rb_digest_base_s_bubblebabble): Ditto for Digest::Base::bubblebabble(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11164 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
703d2d1612
commit
bf8cd1e929
3 changed files with 55 additions and 21 deletions
13
ChangeLog
13
ChangeLog
|
@ -1,3 +1,16 @@
|
|||
Sat Oct 14 04:33:33 2006 Akinori MUSHA <knu@iDaemons.org>
|
||||
|
||||
* ext/digest/digest.c: Improve RDoc documentation.
|
||||
|
||||
* ext/digest/digest.c (Init_digest, rb_digest_base_s_digest,
|
||||
rb_digest_base_s_hexdigest): Make Digest::Base::digest() and
|
||||
Digest::Base::hexdigest() take extra arguments, which are passed
|
||||
through to the constructor in an internal call.
|
||||
|
||||
* ext/digest/bubblebabble/bubblebabble.c
|
||||
(rb_digest_base_s_bubblebabble): Ditto for
|
||||
Digest::Base::bubblebabble().
|
||||
|
||||
Sat Oct 14 00:55:08 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* bcc32/Makefile.sub (post-install-ext): no longer needed.
|
||||
|
|
|
@ -82,7 +82,11 @@ bubblebabble_str_new(VALUE str_digest)
|
|||
* call-seq:
|
||||
* Digest.bubblebabble(string) -> bubblebabble_string
|
||||
*
|
||||
* Returns a BubbleBabble encoded version of a given _string_. */
|
||||
* Returns a BubbleBabble encoded version of a given _string_.
|
||||
*
|
||||
* If extra arguments are given, they are passed to
|
||||
* Digest::ALGORITHM.digest() along with the _string_.
|
||||
*/
|
||||
static VALUE
|
||||
rb_digest_s_bubblebabble(VALUE klass, VALUE str)
|
||||
{
|
||||
|
@ -91,14 +95,14 @@ rb_digest_s_bubblebabble(VALUE klass, VALUE str)
|
|||
|
||||
/*
|
||||
* call-seq:
|
||||
* Digest::ALGORITHM.bubblebabble(string) -> hash_string
|
||||
* Digest::ALGORITHM.bubblebabble(string, ...) -> hash_string
|
||||
*
|
||||
* Returns the BubbleBabble encoded hash value of a given _string_.
|
||||
*/
|
||||
static VALUE
|
||||
rb_digest_base_s_bubblebabble(VALUE klass, VALUE str)
|
||||
rb_digest_base_s_bubblebabble(int argc, VALUE *argv, VALUE klass)
|
||||
{
|
||||
return bubblebabble_str_new(rb_funcall(klass, id_digest, 1, str));
|
||||
return bubblebabble_str_new(rb_funcall2(klass, id_digest, argc, argv));
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -127,7 +131,7 @@ Init_bubblebabble(void)
|
|||
rb_define_module_function(mDigest, "bubblebabble", rb_digest_s_bubblebabble, 1);
|
||||
|
||||
/* Digest::Base::bubblebabble() */
|
||||
rb_define_singleton_method(cDigest_Base, "bubblebabble", rb_digest_base_s_bubblebabble, 1);
|
||||
rb_define_singleton_method(cDigest_Base, "bubblebabble", rb_digest_base_s_bubblebabble, -1);
|
||||
|
||||
/* Digest::Base#bubblebabble() */
|
||||
rb_define_method(cDigest_Base, "bubblebabble", rb_digest_base_bubblebabble, 0);
|
||||
|
|
|
@ -108,19 +108,33 @@ rb_digest_base_alloc(VALUE klass)
|
|||
|
||||
/*
|
||||
* call-seq:
|
||||
* Digest::ALGORITHM.digest(data) -> string
|
||||
* Digest::ALGORITHM.digest(string[, ...]) -> hash_string
|
||||
*
|
||||
* Returns the hash value of a given string _data_.
|
||||
* Returns the hash value of a given string _data_. This is almost
|
||||
* equivalent to Digest::ALGORITHM.new(...).update(string).digest()
|
||||
* where extra arguments, if any, are passed to the constructor.
|
||||
*/
|
||||
static VALUE
|
||||
rb_digest_base_s_digest(VALUE klass, VALUE str)
|
||||
rb_digest_base_s_digest(int argc, VALUE *argv, VALUE klass)
|
||||
{
|
||||
algo_t *algo = get_digest_base_metadata(klass);
|
||||
VALUE str;
|
||||
algo_t *algo;
|
||||
void *pctx;
|
||||
volatile VALUE obj;
|
||||
|
||||
if (argc < 1) {
|
||||
rb_raise(rb_eArgError, "no data given");
|
||||
}
|
||||
|
||||
str = *argv++;
|
||||
argc--;
|
||||
|
||||
StringValue(str);
|
||||
|
||||
algo = get_digest_base_metadata(klass);
|
||||
|
||||
if (algo == NULL) {
|
||||
VALUE obj = rb_funcall(klass, id_new, 0);
|
||||
VALUE obj = rb_funcall2(klass, id_new, argc, argv);
|
||||
rb_funcall(obj, id_update, 1, str);
|
||||
return rb_funcall(obj, id_digest, 0);
|
||||
}
|
||||
|
@ -128,7 +142,6 @@ rb_digest_base_s_digest(VALUE klass, VALUE str)
|
|||
obj = rb_digest_base_alloc(klass);
|
||||
Data_Get_Struct(obj, void, pctx);
|
||||
|
||||
StringValue(str);
|
||||
algo->update_func(pctx, RSTRING_PTR(str), RSTRING_LEN(str));
|
||||
|
||||
str = rb_str_new(0, algo->digest_len);
|
||||
|
@ -139,16 +152,20 @@ rb_digest_base_s_digest(VALUE klass, VALUE str)
|
|||
|
||||
/*
|
||||
* call-seq:
|
||||
* Digest::ALGORITHM.hexdigest(data) -> string
|
||||
* Digest::ALGORITHM.hexdigest(string[, ...]) -> hash_string
|
||||
*
|
||||
* Returns the hex-encoded hash value of a given string _data_.
|
||||
* Returns the hex-encoded hash value of a given _string_. This
|
||||
* method just hex-encode the return value of
|
||||
* Digest::ALGORITHM.digest(string[, ...]) where extra arguments, if
|
||||
* any, are passed to digest() along with the _string_.
|
||||
*/
|
||||
static VALUE
|
||||
rb_digest_base_s_hexdigest(VALUE klass, VALUE str)
|
||||
rb_digest_base_s_hexdigest(int argc, VALUE *argv, VALUE klass)
|
||||
{
|
||||
return hexdigest_str_new(rb_funcall(klass, id_digest, 1, str));
|
||||
return hexdigest_str_new(rb_funcall2(klass, id_digest, argc, argv));
|
||||
}
|
||||
|
||||
/* :nodoc: */
|
||||
static VALUE
|
||||
rb_digest_base_copy(VALUE copy, VALUE obj)
|
||||
{
|
||||
|
@ -205,9 +222,9 @@ rb_digest_base_reset(VALUE self)
|
|||
|
||||
/*
|
||||
* call-seq:
|
||||
* digest_obj.update(data) -> digest_obj
|
||||
* digest_obj.update(string) -> digest_obj
|
||||
*
|
||||
* Updates the digest using a given string _data_ and returns self.
|
||||
* Updates the digest using a given _string_ and returns self.
|
||||
*/
|
||||
static VALUE
|
||||
rb_digest_base_update(VALUE self, VALUE str)
|
||||
|
@ -232,9 +249,9 @@ rb_digest_base_update(VALUE self, VALUE str)
|
|||
|
||||
/*
|
||||
* call-seq:
|
||||
* digest_obj << data -> digest_obj
|
||||
* digest_obj << string -> digest_obj
|
||||
*
|
||||
* Alias for update().
|
||||
* Calls update(string).
|
||||
*/
|
||||
static VALUE
|
||||
rb_digest_base_lshift(VALUE self, VALUE str)
|
||||
|
@ -387,8 +404,8 @@ Init_digest(void)
|
|||
cDigest_Base = rb_define_class_under(mDigest, "Base", rb_cObject);
|
||||
|
||||
rb_define_alloc_func(cDigest_Base, rb_digest_base_alloc);
|
||||
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_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_copy", rb_digest_base_copy, 1);
|
||||
rb_define_method(cDigest_Base, "reset", rb_digest_base_reset, 0);
|
||||
|
|
Loading…
Reference in a new issue