1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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
This commit is contained in:
matz 2001-02-20 07:42:03 +00:00
parent 86833594ff
commit 88eef2d7fe
7 changed files with 65 additions and 9 deletions

View file

@ -1,3 +1,15 @@
Tue Feb 20 16:37:58 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
* 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 <matz@ruby-lang.org>
* string.c (rb_str_substr): "a"[1,2] should return ""; need

10
README
View file

@ -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 <ruby-talk-ctl@netlab.co.jp>.
in the mail body (not subject) to the address <ruby-talk-ctl@ruby-lang.org>.
* How to compile and install

View file

@ -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;

View file

@ -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 <time.h>
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)

View file

@ -387,7 +387,7 @@ sigsegv(sig)
#endif
#ifdef SIGPIPE
static RETSIGTYPE sigsegv _((int));
static RETSIGTYPE sigpipe _((int));
static RETSIGTYPE
sigpipe(sig)
int sig;

8
time.c
View file

@ -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;

View file

@ -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