From 88eef2d7fec7a3380f495d768c72d1292260ea18 Mon Sep 17 00:00:00 2001 From: matz Date: Tue, 20 Feb 2001 07:42:03 +0000 Subject: * 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: svn+ssh://ci.ruby-lang.org/ruby/trunk@1205 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 12 ++++++++++++ README | 10 +++++----- bignum.c | 2 +- configure.in | 36 ++++++++++++++++++++++++++++++++++++ signal.c | 2 +- time.c | 8 ++++++++ version.h | 4 ++-- 7 files changed, 65 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 02a440fc18..36be371049 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +Tue Feb 20 16:37:58 2001 Yukihiro Matsumoto + + * 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. + Mon Feb 19 17:46:37 2001 Yukihiro Matsumoto * string.c (rb_str_substr): "a"[1,2] should return ""; need diff --git a/README b/README index f924702e39..97d940f4cf 100644 --- a/README +++ b/README @@ -22,14 +22,14 @@ Perl). It is simple, straight-forward, and extensible. The Ruby distribution can be found on: - ftp://ftp.netlab.co.jp/pub/lang/ruby/ + ftp://ftp.ruby-lang.org/pub/lang/ruby/ You can get it by anonymous CVS. How to check out is: - $ cvs -d :pserver:anonymous@cvs.netlab.co.jp:/home/cvs login - (Logging in to anonymous@cvs.netlab.co.jp) + $ cvs -d :pserver:anonymous@cvs.ruby-lang.org:/home/cvs login + (Logging in to anonymous@cvs.ruby-lang.org) CVS password: guest - $ cvs -d :pserver:anonymous@cvs.netlab.co.jp:/home/cvs checkout ruby + $ cvs -d :pserver:anonymous@cvs.ruby-lang.org:/home/cvs checkout ruby * Mailing list @@ -40,7 +40,7 @@ To subscribe this list, please send the following phrase e.g. subscribe Joseph Smith -in the mail body (not subject) to the address . +in the mail body (not subject) to the address . * How to compile and install diff --git a/bignum.c b/bignum.c index 39d90aa92d..bc4733408b 100644 --- a/bignum.c +++ b/bignum.c @@ -467,7 +467,7 @@ rb_big2long(x) { unsigned long num = big2ulong(x, "int"); - if ((long)num < 0) { + if ((long)num < 0 && (long)num != LONG_MIN) { rb_raise(rb_eRangeError, "bignum too big to convert into `int'"); } if (!RBIGNUM(x)->sign) return -(long)num; diff --git a/configure.in b/configure.in index 0c4f0ad94a..9d42330a2a 100644 --- a/configure.in +++ b/configure.in @@ -261,6 +261,42 @@ AC_CACHE_CHECK(for external int daylight, rb_cv_have_daylight, if test "$rb_cv_have_daylight" = yes; then AC_DEFINE(HAVE_DAYLIGHT) fi +AC_CACHE_CHECK(for negative time_t for gmtime(3), rb_cv_negative_time_t, + [AC_TRY_RUN([ +#include + +void +check(tm, y, m, d, h, s) + struct tm *tm; + int y, m, d, h, s; +{ + if (tm->tm_year != y || + tm->tm_mon != m-1 || + tm->tm_mday != d || + tm->tm_hour != h || + tm->tm_sec != s) { + exit(1); + } +} + +int +main() +{ + time_t t = -1; + struct tm *tm; + + check(gmtime(&t), 69, 12, 31, 23, 59); + t = -0x80000000; + check(gmtime(&t), 1, 12, 13, 20, 52); + return 0; +} +], + rb_cv_negative_time_t=yes, + rb_cv_negative_time_t=no, + rb_cv_negative_time_t=yes)]) +if test "$rb_cv_negative_time_t" = yes; then + AC_DEFINE(NEGATIVE_TIME_T) +fi if test "$ac_cv_func_sigprocmask" = yes && test "$ac_cv_func_sigaction" = yes; then AC_DEFINE(POSIX_SIGNAL) diff --git a/signal.c b/signal.c index ca4cded055..b9c5d66979 100644 --- a/signal.c +++ b/signal.c @@ -387,7 +387,7 @@ sigsegv(sig) #endif #ifdef SIGPIPE -static RETSIGTYPE sigsegv _((int)); +static RETSIGTYPE sigpipe _((int)); static RETSIGTYPE sigpipe(sig) int sig; diff --git a/time.c b/time.c index 4648611ef8..8da0daff53 100644 --- a/time.c +++ b/time.c @@ -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; diff --git a/version.h b/version.h index 16735267fc..1d4cf052fd 100644 --- a/version.h +++ b/version.h @@ -1,4 +1,4 @@ #define RUBY_VERSION "1.7.0" -#define RUBY_RELEASE_DATE "2001-02-19" +#define RUBY_RELEASE_DATE "2001-02-20" #define RUBY_VERSION_CODE 170 -#define RUBY_RELEASE_CODE 20010219 +#define RUBY_RELEASE_CODE 20010220 -- cgit v1.2.3