summaryrefslogtreecommitdiff
path: root/numeric.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-08-06 03:05:23 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-08-06 03:05:23 +0000
commitf33a61c28dadf8ff2bb86d36d6428f487b671708 (patch)
tree6794731dfe7e2d526808376060893846f2ddc6c2 /numeric.c
parent439b453e3aa244e7b824a55aa11768dca3d4a6f4 (diff)
* string.c (rb_str_lstrip_bang): new method.
* string.c (rb_str_rstrip_bang): new method. * string.c (rb_str_associate): should consider STR_ASSOC too. * eval.c (rb_undefined): do not recurse if method_missing is undefined. * process.c (proc_waitpid): now all arguments are optional. * process.c (Init_process): waitpid is now alias to wait. * process.c (Init_process): waitpid2 is now alias to wait2. * process.c (rb_waitpid): made public. * ext/pty/pty.c (pty_getpty): avoid disturbing SIGCHLD using thread and rb_waitpid. * process.c (proc_getpgrp): now takes no argument on all platforms. * process.c (proc_setpgrp): ditto. * ext/socket/socket.c (sock_s_pack_sockaddr_in): added Socket::pack_sockaddr_in(). [new] * ext/socket/socket.c (sock_s_pack_sockaddr_un): added Socket::pack_sockaddr_un(). [new] * ext/socket/socket.c (sock_s_pack_sockaddr_in): added Socket::unpack_sockaddr_in(). [new] * ext/socket/socket.c (sock_s_pack_sockaddr_un): added Socket::unpack_sockaddr_un(). [new] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1666 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'numeric.c')
-rw-r--r--numeric.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/numeric.c b/numeric.c
index 027ee6366b..bf3f46279f 100644
--- a/numeric.c
+++ b/numeric.c
@@ -17,8 +17,7 @@
#include <floatingpoint.h>
#endif
-static ID coerce;
-static ID to_i;
+static ID id_coerce, id_to_i, id_div;
VALUE rb_cNumeric;
VALUE rb_cFloat;
@@ -47,7 +46,7 @@ static VALUE
coerce_body(x)
VALUE *x;
{
- return rb_funcall(x[1], coerce, 1, x[0]);
+ return rb_funcall(x[1], id_coerce, 1, x[0]);
}
static VALUE
@@ -119,7 +118,7 @@ static VALUE
num_div(x, y)
VALUE x, y;
{
- return rb_funcall(x, '/', 1, y);
+ return rb_funcall(x, id_div, 1, y);
}
static VALUE
@@ -128,7 +127,7 @@ num_divmod(x, y)
{
VALUE div, mod;
- div = rb_funcall(x, '/', 1, y);
+ div = rb_funcall(x, div, 1, y);
if (TYPE(div) == T_FLOAT) {
double d = floor(RFLOAT(div)->value);
@@ -1535,8 +1534,9 @@ Init_Numeric()
/* allow divide by zero -- Inf */
fpsetmask(fpgetmask() & ~(FP_X_DZ|FP_X_INV|FP_X_OFL));
#endif
- coerce = rb_intern("coerce");
- to_i = rb_intern("to_i");
+ id_coerce = rb_intern("coerce");
+ id_to_i = rb_intern("to_i");
+ id_div = rb_intern("div");
rb_eZeroDivError = rb_define_class("ZeroDivisionError", rb_eStandardError);
rb_eFloatDomainError = rb_define_class("FloatDomainError", rb_eRangeError);
@@ -1550,7 +1550,7 @@ Init_Numeric()
rb_define_method(rb_cNumeric, "-@", num_uminus, 0);
rb_define_method(rb_cNumeric, "===", num_equal, 1);
rb_define_method(rb_cNumeric, "eql?", num_eql, 1);
- rb_define_method(rb_cNumeric, "div", num_div, 1);
+ rb_define_method(rb_cNumeric, "/", num_div, 1);
rb_define_method(rb_cNumeric, "divmod", num_divmod, 1);
rb_define_method(rb_cNumeric, "modulo", num_modulo, 1);
rb_define_method(rb_cNumeric, "remainder", num_remainder, 1);
@@ -1675,3 +1675,4 @@ Init_Numeric()
rb_define_method(rb_cFloat, "infinite?", flo_is_infinite_p, 0);
rb_define_method(rb_cFloat, "finite?", flo_is_finite_p, 0);
}
+