summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--numeric.c6
-rw-r--r--object.c2
3 files changed, 7 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 7ef4616fe6..736d1c7dcb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,10 +1,10 @@
Tue Jul 22 02:22:45 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+ * numeric.c (num_equal): should not use rb_equal().
+
* string.c (rb_str_equal): should return nil for non string
operand to conform comparable convention. [ruby-dev:20759]
- * object.c (rb_equal): preserve nil if "==" returns nil.
-
Tue Jul 22 00:19:19 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
* lib/tmpdir.rb: new library to get temporary directory path,
diff --git a/numeric.c b/numeric.c
index d97c1493d4..37ff50e8c3 100644
--- a/numeric.c
+++ b/numeric.c
@@ -57,7 +57,7 @@
#define DBL_EPSILON 2.2204460492503131e-16
#endif
-static ID id_coerce, id_to_i;
+static ID id_coerce, id_to_i, id_eq;
VALUE rb_cNumeric;
VALUE rb_cFloat;
@@ -515,7 +515,8 @@ static VALUE
num_equal(x, y)
VALUE x, y;
{
- return rb_equal(y, x);
+ if (x == y) return Qtrue;
+ return rb_funcall(y, id_eq, 1, x);
}
static VALUE
@@ -1804,6 +1805,7 @@ Init_Numeric()
#endif
id_coerce = rb_intern("coerce");
id_to_i = rb_intern("to_i");
+ id_eq = rb_intern("==");
rb_eZeroDivError = rb_define_class("ZeroDivisionError", rb_eStandardError);
rb_eFloatDomainError = rb_define_class("FloatDomainError", rb_eRangeError);
diff --git a/object.c b/object.c
index e168fa7505..7e8b5e68e1 100644
--- a/object.c
+++ b/object.c
@@ -42,7 +42,7 @@ rb_equal(obj1, obj2)
if (obj1 == obj2) return Qtrue;
result = rb_funcall(obj1, id_eq, 1, obj2);
if (RTEST(result)) return Qtrue;
- return result;
+ return Qfalse;
}
int