зеркало из https://github.com/github/ruby.git
* time.c (lt): call <=> instead of <.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27213 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
eb71e5cd67
Коммит
9c50406bd5
|
@ -1,3 +1,7 @@
|
||||||
|
Sun Apr 4 09:44:01 2010 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
|
* time.c (lt): call <=> instead of <.
|
||||||
|
|
||||||
Sun Apr 4 06:46:16 2010 Aaron Patterson <aaron@tenderlovemaking.com>
|
Sun Apr 4 06:46:16 2010 Aaron Patterson <aaron@tenderlovemaking.com>
|
||||||
|
|
||||||
* lib/yaml: Moved to ext/syck/lib, Syck only uses Syck constant.
|
* lib/yaml: Moved to ext/syck/lib, Syck only uses Syck constant.
|
||||||
|
|
13
time.c
13
time.c
|
@ -31,6 +31,8 @@ static ID id_eq, id_ne, id_quo, id_div, id_cmp, id_lshift;
|
||||||
#define NMOD(x,y) ((y)-(-((x)+1)%(y))-1)
|
#define NMOD(x,y) ((y)-(-((x)+1)%(y))-1)
|
||||||
#define DIV(n,d) ((n)<0 ? NDIV((n),(d)) : (n)/(d))
|
#define DIV(n,d) ((n)<0 ? NDIV((n),(d)) : (n)/(d))
|
||||||
|
|
||||||
|
#define cmp(x,y) (rb_cmpint(rb_funcall((x), id_cmp, 1, (y)), (x), (y)))
|
||||||
|
|
||||||
static int
|
static int
|
||||||
eq(VALUE x, VALUE y)
|
eq(VALUE x, VALUE y)
|
||||||
{
|
{
|
||||||
|
@ -46,7 +48,7 @@ lt(VALUE x, VALUE y)
|
||||||
if (FIXNUM_P(x) && FIXNUM_P(y)) {
|
if (FIXNUM_P(x) && FIXNUM_P(y)) {
|
||||||
return (long)x < (long)y;
|
return (long)x < (long)y;
|
||||||
}
|
}
|
||||||
return RTEST(rb_funcall(x, '<', 1, y));
|
return cmp(x,y) < 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define ne(x,y) (!eq(x,y))
|
#define ne(x,y) (!eq(x,y))
|
||||||
|
@ -154,7 +156,6 @@ mod(VALUE x, VALUE y)
|
||||||
}
|
}
|
||||||
|
|
||||||
#define neg(x) (sub(INT2FIX(0), (x)))
|
#define neg(x) (sub(INT2FIX(0), (x)))
|
||||||
#define cmp(x,y) (rb_cmpint(rb_funcall((x), id_cmp, 1, (y)), (x), (y)))
|
|
||||||
#define lshift(x,y) (rb_funcall((x), id_lshift, 1, (y)))
|
#define lshift(x,y) (rb_funcall((x), id_lshift, 1, (y)))
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
|
@ -3210,12 +3211,12 @@ time_cmp(VALUE time1, VALUE time2)
|
||||||
n = wcmp(tobj1->timew, tobj2->timew);
|
n = wcmp(tobj1->timew, tobj2->timew);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
VALUE cmp;
|
VALUE tmp;
|
||||||
|
|
||||||
cmp = rb_funcall(time2, rb_intern("<=>"), 1, time1);
|
tmp = rb_funcall(time2, rb_intern("<=>"), 1, time1);
|
||||||
if (NIL_P(cmp)) return Qnil;
|
if (NIL_P(tmp)) return Qnil;
|
||||||
|
|
||||||
n = -rb_cmpint(cmp, time1, time2);
|
n = -rb_cmpint(tmp, time1, time2);
|
||||||
}
|
}
|
||||||
if (n == 0) return INT2FIX(0);
|
if (n == 0) return INT2FIX(0);
|
||||||
if (n > 0) return INT2FIX(1);
|
if (n > 0) return INT2FIX(1);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче