[前][次][番号順一覧][スレッド一覧]

ruby-changes:14107

From: knu <ko1@a...>
Date: Wed, 25 Nov 2009 19:34:40 +0900 (JST)
Subject: [ruby-changes:14107] Ruby:r25921 (ruby_1_8): * ext/digest/digest.c (rb_digest_instance_method_unimpl): Do not

knu	2009-11-25 19:34:24 +0900 (Wed, 25 Nov 2009)

  New Revision: 25921

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=25921

  Log:
    * ext/digest/digest.c (rb_digest_instance_method_unimpl): Do not
      call rb_inspect() on an object that does not implement necessary
      methods; reported by NaHi.

  Modified files:
    branches/ruby_1_8/ChangeLog
    branches/ruby_1_8/ext/digest/digest.c

Index: ruby_1_8/ext/digest/digest.c
===================================================================
--- ruby_1_8/ext/digest/digest.c	(revision 25920)
+++ ruby_1_8/ext/digest/digest.c	(revision 25921)
@@ -83,6 +83,15 @@
  * object to calculate message digest values.
  */
 
+static void
+rb_digest_instance_method_unimpl(VALUE self, const char *method)
+{
+    VALUE klass = rb_obj_class(self);
+
+    rb_raise(rb_eRuntimeError, "%s does not implement %s()",
+	     rb_obj_classname(self), method);
+}
+
 /*
  * call-seq:
  *     digest_obj.update(string) -> digest_obj
@@ -97,7 +106,7 @@
 static VALUE
 rb_digest_instance_update(VALUE self, VALUE str)
 {
-    rb_raise(rb_eRuntimeError, "%s does not implement update()", RSTRING_PTR(rb_inspect(self)));
+    rb_digest_instance_method_unimpl(self, "update");
 }
 
 /*
@@ -115,7 +124,7 @@
 static VALUE
 rb_digest_instance_finish(VALUE self)
 {
-    rb_raise(rb_eRuntimeError, "%s does not implement finish()", RSTRING_PTR(rb_inspect(self)));
+    rb_digest_instance_method_unimpl(self, "finish");
 }
 
 /*
@@ -129,7 +138,7 @@
 static VALUE
 rb_digest_instance_reset(VALUE self)
 {
-    rb_raise(rb_eRuntimeError, "%s does not implement reset()", RSTRING_PTR(rb_inspect(self)));
+    rb_digest_instance_method_unimpl(self, "reset");
 }
 
 /*
@@ -358,7 +367,7 @@
 static VALUE
 rb_digest_instance_block_length(VALUE self)
 {
-    rb_raise(rb_eRuntimeError, "%s does not implement block_length()", RSTRING_PTR(rb_inspect(self)));
+    rb_digest_instance_method_unimpl(self, "block_length");
 }
 
 /*
Index: ruby_1_8/ChangeLog
===================================================================
--- ruby_1_8/ChangeLog	(revision 25920)
+++ ruby_1_8/ChangeLog	(revision 25921)
@@ -1,3 +1,9 @@
+Wed Nov 25 19:32:25 2009  Akinori MUSHA  <knu@i...>
+
+	* ext/digest/digest.c (rb_digest_instance_method_unimpl): Do not
+	  call rb_inspect() on an object that does not implement necessary
+	  methods; reported by NaHi.
+
 Wed Nov 25 15:06:42 2009  Akinori MUSHA  <knu@i...>
 
 	* test/ruby/test_array.rb (TestArray#test_splat): Add tests for a

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]