From db2c62ff83f57da0a0afc740d06b877f2ed361e9 Mon Sep 17 00:00:00 2001 From: matz Date: Thu, 19 Dec 2002 09:20:20 +0000 Subject: * numeric.c (num_step): use DBL_EPSILON. * array.c (rb_check_array_type): new function: return an array (convert if possible), or nil. * string.c (rb_check_string_type): new function: return a string (convert if possible), or nil. * numeric.c (rb_dbl_cmp): returns nil if values are not comparable. * numeric.c (fix_cmp,flo_cmp): use rb_num_coerce_cmp() * bignum.c (rb_big_cmp): ditto. * numeric.c (rb_num_coerce_cmp): new coercing function for "<=>", which does not raise TypeError. * numeric.c (do_coerce): can be supress exception now. * object.c (rb_mod_cmp): should return nil for non class/module objects. * re.c (rb_reg_eqq): return false if the argument is not a string. now returns boolean value. * class.c (rb_include_module): argument should be T_MODULE, not T_class, nor T_ICLASS. * eval.c (is_defined): "defined?" should return "assignment" for attribute assignment (e.g. a.foo=b) and indexed assignment (e.g. a[2] = 44). * parse.y (aryset): use NODE_ATTRASGN. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@3169 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- range.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'range.c') diff --git a/range.c b/range.c index a004f408e..bb12bc38c 100644 --- a/range.c +++ b/range.c @@ -123,6 +123,7 @@ r_lt(a, b) { VALUE r = rb_funcall(a, id_cmp, 1, b); + if (NIL_P(r)) return Qfalse; if (rb_cmpint(r) < 0) return Qtrue; return Qfalse; } @@ -133,16 +134,19 @@ r_le(a, b) { VALUE r = rb_funcall(a, id_cmp, 1, b); + if (NIL_P(r)) return Qfalse; if (rb_cmpint(r) <= 0) return Qtrue; return Qfalse; } + static int r_gt(a,b) VALUE a, b; { VALUE r = rb_funcall(a, id_cmp, 1, b); + if (NIL_P(r)) return Qfalse; if (rb_cmpint(r) > 0) return Qtrue; return Qfalse; } @@ -474,12 +478,13 @@ range_include(range, val) beg = rb_ivar_get(range, id_beg); end = rb_ivar_get(range, id_end); - if (r_gt(beg, val)) return Qfalse; - if (EXCL(range)) { - if (r_lt(val, end)) return Qtrue; - } - else { - if (r_le(val, end)) return Qtrue; + if (r_le(beg, val)) { + if (EXCL(range)) { + if (r_lt(val, end)) return Qtrue; + } + else { + if (r_le(val, end)) return Qtrue; + } } return Qfalse; } -- cgit