ruby-changes:9673
From: matz <ko1@a...>
Date: Wed, 31 Dec 2008 23:31:14 +0900 (JST)
Subject: [ruby-changes:9673] Ruby:r21214 (trunk): * object.c (rb_to_float): replaced by to_flo definition from
matz 2008-12-31 23:30:50 +0900 (Wed, 31 Dec 2008) New Revision: 21214 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=21214 Log: * object.c (rb_to_float): replaced by to_flo definition from math.c [ruby-dev:37668] * math.c (Need_Float): use rb_to_float(). Modified files: trunk/ChangeLog trunk/math.c trunk/object.c Index: math.c =================================================================== --- math.c (revision 21213) +++ math.c (revision 21214) @@ -15,20 +15,7 @@ VALUE rb_mMath; -static VALUE -to_flo(VALUE x) -{ - if (!rb_obj_is_kind_of(x, rb_cNumeric)) { - rb_raise(rb_eTypeError, "can't convert %s into Float", - NIL_P(x) ? "nil" : - x == Qtrue ? "true" : - x == Qfalse ? "false" : - rb_obj_classname(x)); - } - return rb_convert_type(x, T_FLOAT, "Float", "to_f"); -} - -#define Need_Float(x) (x) = to_flo(x) +#define Need_Float(x) (x) = rb_to_float(x) #define Need_Float2(x,y) do {\ Need_Float(x);\ Need_Float(y);\ Index: ChangeLog =================================================================== --- ChangeLog (revision 21213) +++ ChangeLog (revision 21214) @@ -24,6 +24,13 @@ * ext/openssl/ossl_pkey_ec.c (ossl_ec_key_initialize): ditto. (ossl_ec_group_initialize): ditto. +Wed Dec 31 14:12:35 2008 Yukihiro Matsumoto <matz@r...> + + * object.c (rb_to_float): replaced by to_flo definition from + math.c [ruby-dev:37668] + + * math.c (Need_Float): use rb_to_float(). + Wed Dec 31 13:49:06 2008 Tanaka Akira <akr@f...> * ext/openssl/lib/openssl/buffering.rb (Buffering#read_nonblock): Index: object.c =================================================================== --- object.c (revision 21213) +++ object.c (revision 21214) @@ -2270,19 +2270,15 @@ VALUE rb_to_float(VALUE val) { - VALUE v; - if (TYPE(val) == T_FLOAT) return val; - if (NIL_P(val)) { - rb_raise(rb_eTypeError, "can't convert nil into Float"); + if (!rb_obj_is_kind_of(val, rb_cNumeric)) { + rb_raise(rb_eTypeError, "can't convert %s into Float", + NIL_P(val) ? "nil" : + val == Qtrue ? "true" : + val == Qfalse ? "false" : + rb_obj_classname(val)); } - v = convert_type(val, "Float", "to_f", Qtrue); - if (TYPE(v) != T_FLOAT) { - const char *cname = rb_obj_classname(val); - rb_raise(rb_eTypeError, "can't convert %s to Float (%s#to_f gives %s)", - cname, cname, rb_obj_classname(v)); - } - return v; + return rb_convert_type(val, T_FLOAT, "Float", "to_f"); } double -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/