diff options
| author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2001-02-20 07:42:03 +0000 |
|---|---|---|
| committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2001-02-20 07:42:03 +0000 |
| commit | 775819d51f74fb75697ee31f739c48544e288bf3 (patch) | |
| tree | 3babd1780de60f5918ec26d7c516b2495d4302cc /time.c | |
| parent | 8485eeaaaaf26bfc367a0f11572ae33f7830d775 (diff) | |
| download | ruby-775819d51f74fb75697ee31f739c48544e288bf3.tar.gz ruby-775819d51f74fb75697ee31f739c48544e288bf3.tar.xz ruby-775819d51f74fb75697ee31f739c48544e288bf3.zip | |
* configure.in: add check for negative time_t for gmtime(3).
* time.c (time_new_internal): no positive check if gmtime(3) can
handle negative time_t.
* time.c (time_timeval): ditto.
* bignum.c (rb_big2long): should not raise RangeError for Bignum
LONG_MIN value.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@1205 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'time.c')
| -rw-r--r-- | time.c | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -80,8 +80,10 @@ time_new_internal(klass, sec, usec) VALUE obj; struct time_object *tobj; +#ifndef NEGATIVE_TIME_T if (sec < 0 || (sec == 0 && usec < 0)) rb_raise(rb_eArgError, "time must be positive"); +#endif obj = Data_Make_Struct(klass, struct time_object, 0, free, tobj); tobj->tm_got = 0; @@ -108,22 +110,28 @@ time_timeval(time, interval) switch (TYPE(time)) { case T_FIXNUM: t.tv_sec = FIX2LONG(time); +#ifndef NEGATIVE_TIME_T if (t.tv_sec < 0) rb_raise(rb_eArgError, "time must be positive"); +#endif t.tv_usec = 0; break; case T_FLOAT: +#ifndef NEGATIVE_TIME_T if (RFLOAT(time)->value < 0.0) rb_raise(rb_eArgError, "time must be positive"); +#endif t.tv_sec = (time_t)RFLOAT(time)->value; t.tv_usec = (time_t)((RFLOAT(time)->value - (double)t.tv_sec)*1e6); break; case T_BIGNUM: t.tv_sec = NUM2LONG(time); +#ifndef NEGATIVE_TIME_T if (t.tv_sec < 0) rb_raise(rb_eArgError, "time must be positive"); +#endif t.tv_usec = 0; break; |
