mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
merge revision(s) 39766,39769: [Backport #8101]
* time.c (GetTimeval): check if already initialized instance. * time.c (GetNewTimeval): check if newly created instance. * time.c (time_init_0, time_init_1, time_init_copy, time_mload): must be newly created instance. [ruby-core:53436] [Bug #8099] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@40711 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
588c13973a
commit
9d5681ad97
4 changed files with 57 additions and 11 deletions
|
@ -1,3 +1,12 @@
|
||||||
|
Tue May 14 09:36:14 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* time.c (GetTimeval): check if already initialized instance.
|
||||||
|
|
||||||
|
* time.c (GetNewTimeval): check if newly created instance.
|
||||||
|
|
||||||
|
* time.c (time_init_0, time_init_1, time_init_copy, time_mload): must
|
||||||
|
be newly created instance. [ruby-core:53436] [Bug #8099]
|
||||||
|
|
||||||
Thu Apr 11 11:24:42 2013 Akinori MUSHA <knu@iDaemons.org>
|
Thu Apr 11 11:24:42 2013 Akinori MUSHA <knu@iDaemons.org>
|
||||||
|
|
||||||
* lib/ipaddr.rb (IPAddr#in6_addr): Fix a typo with the closing
|
* lib/ipaddr.rb (IPAddr#in6_addr): Fix a typo with the closing
|
||||||
|
|
|
@ -378,6 +378,15 @@ class TestTime < Test::Unit::TestCase
|
||||||
assert_kind_of(Integer, T2000.hash)
|
assert_kind_of(Integer, T2000.hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_reinitialize
|
||||||
|
bug8099 = '[ruby-core:53436] [Bug #8099]'
|
||||||
|
t2000 = get_t2000
|
||||||
|
assert_raise(TypeError, bug8099) {
|
||||||
|
t2000.send(:initialize, 2013, 03, 14)
|
||||||
|
}
|
||||||
|
assert_equal(get_t2000, t2000, bug8099)
|
||||||
|
end
|
||||||
|
|
||||||
def test_init_copy
|
def test_init_copy
|
||||||
assert_equal(T2000, T2000.dup)
|
assert_equal(T2000, T2000.dup)
|
||||||
assert_raise(TypeError) do
|
assert_raise(TypeError) do
|
||||||
|
|
42
time.c
42
time.c
|
@ -1809,10 +1809,11 @@ struct time_object {
|
||||||
int tm_got;
|
int tm_got;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define GetTimeval(obj, tobj) \
|
#define GetTimeval(obj, tobj) ((tobj) = get_timeval(obj))
|
||||||
TypedData_Get_Struct((obj), struct time_object, &time_data_type, (tobj))
|
#define GetNewTimeval(obj, tobj) ((tobj) = get_new_timeval(obj))
|
||||||
|
|
||||||
#define IsTimeval(obj) rb_typeddata_is_kind_of((obj), &time_data_type)
|
#define IsTimeval(obj) rb_typeddata_is_kind_of((obj), &time_data_type)
|
||||||
|
#define TIME_INIT_P(tobj) ((tobj)->gmt != -1)
|
||||||
|
|
||||||
#define TIME_UTC_P(tobj) ((tobj)->gmt == 1)
|
#define TIME_UTC_P(tobj) ((tobj)->gmt == 1)
|
||||||
#define TIME_SET_UTC(tobj) ((tobj)->gmt = 1)
|
#define TIME_SET_UTC(tobj) ((tobj)->gmt = 1)
|
||||||
|
@ -1875,12 +1876,35 @@ time_s_alloc(VALUE klass)
|
||||||
struct time_object *tobj;
|
struct time_object *tobj;
|
||||||
|
|
||||||
obj = TypedData_Make_Struct(klass, struct time_object, &time_data_type, tobj);
|
obj = TypedData_Make_Struct(klass, struct time_object, &time_data_type, tobj);
|
||||||
|
tobj->gmt = -1;
|
||||||
tobj->tm_got=0;
|
tobj->tm_got=0;
|
||||||
tobj->timew = WINT2FIXWV(0);
|
tobj->timew = WINT2FIXWV(0);
|
||||||
|
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct time_object *
|
||||||
|
get_timeval(VALUE obj)
|
||||||
|
{
|
||||||
|
struct time_object *tobj;
|
||||||
|
TypedData_Get_Struct(obj, struct time_object, &time_data_type, tobj);
|
||||||
|
if (!TIME_INIT_P(tobj)) {
|
||||||
|
rb_raise(rb_eTypeError, "uninitialized %"PRIiVALUE, CLASS_OF(obj));
|
||||||
|
}
|
||||||
|
return tobj;
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct time_object *
|
||||||
|
get_new_timeval(VALUE obj)
|
||||||
|
{
|
||||||
|
struct time_object *tobj;
|
||||||
|
TypedData_Get_Struct(obj, struct time_object, &time_data_type, tobj);
|
||||||
|
if (TIME_INIT_P(tobj)) {
|
||||||
|
rb_raise(rb_eTypeError, "already initialized %"PRIiVALUE, CLASS_OF(obj));
|
||||||
|
}
|
||||||
|
return tobj;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
time_modify(VALUE time)
|
time_modify(VALUE time)
|
||||||
{
|
{
|
||||||
|
@ -1947,7 +1971,8 @@ time_init_0(VALUE time)
|
||||||
struct timespec ts;
|
struct timespec ts;
|
||||||
|
|
||||||
time_modify(time);
|
time_modify(time);
|
||||||
GetTimeval(time, tobj);
|
GetNewTimeval(time, tobj);
|
||||||
|
tobj->gmt = 0;
|
||||||
tobj->tm_got=0;
|
tobj->tm_got=0;
|
||||||
tobj->timew = WINT2FIXWV(0);
|
tobj->timew = WINT2FIXWV(0);
|
||||||
#ifdef HAVE_CLOCK_GETTIME
|
#ifdef HAVE_CLOCK_GETTIME
|
||||||
|
@ -2188,7 +2213,8 @@ time_init_1(int argc, VALUE *argv, VALUE time)
|
||||||
validate_vtm(&vtm);
|
validate_vtm(&vtm);
|
||||||
|
|
||||||
time_modify(time);
|
time_modify(time);
|
||||||
GetTimeval(time, tobj);
|
GetNewTimeval(time, tobj);
|
||||||
|
tobj->gmt = 0;
|
||||||
tobj->tm_got=0;
|
tobj->tm_got=0;
|
||||||
tobj->timew = WINT2FIXWV(0);
|
tobj->timew = WINT2FIXWV(0);
|
||||||
|
|
||||||
|
@ -2304,7 +2330,8 @@ time_new_timew(VALUE klass, wideval_t timew)
|
||||||
VALUE time = time_s_alloc(klass);
|
VALUE time = time_s_alloc(klass);
|
||||||
struct time_object *tobj;
|
struct time_object *tobj;
|
||||||
|
|
||||||
GetTimeval(time, tobj);
|
tobj = DATA_PTR(time); /* skip type check */
|
||||||
|
tobj->gmt = 0;
|
||||||
tobj->timew = timew;
|
tobj->timew = timew;
|
||||||
|
|
||||||
return time;
|
return time;
|
||||||
|
@ -3430,7 +3457,7 @@ time_init_copy(VALUE copy, VALUE time)
|
||||||
if (copy == time) return copy;
|
if (copy == time) return copy;
|
||||||
time_modify(copy);
|
time_modify(copy);
|
||||||
GetTimeval(time, tobj);
|
GetTimeval(time, tobj);
|
||||||
GetTimeval(copy, tcopy);
|
GetNewTimeval(copy, tcopy);
|
||||||
MEMCPY(tcopy, tobj, struct time_object, 1);
|
MEMCPY(tcopy, tobj, struct time_object, 1);
|
||||||
|
|
||||||
return copy;
|
return copy;
|
||||||
|
@ -4807,7 +4834,8 @@ end_submicro: ;
|
||||||
timew = timegmw(&vtm);
|
timew = timegmw(&vtm);
|
||||||
}
|
}
|
||||||
|
|
||||||
GetTimeval(time, tobj);
|
GetNewTimeval(time, tobj);
|
||||||
|
tobj->gmt = 0;
|
||||||
tobj->tm_got = 0;
|
tobj->tm_got = 0;
|
||||||
tobj->timew = timew;
|
tobj->timew = timew;
|
||||||
if (gmt) {
|
if (gmt) {
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
#define RUBY_VERSION "1.9.3"
|
#define RUBY_VERSION "1.9.3"
|
||||||
#define RUBY_PATCHLEVEL 415
|
#define RUBY_PATCHLEVEL 416
|
||||||
|
|
||||||
#define RUBY_RELEASE_DATE "2013-04-11"
|
#define RUBY_RELEASE_DATE "2013-05-14"
|
||||||
#define RUBY_RELEASE_YEAR 2013
|
#define RUBY_RELEASE_YEAR 2013
|
||||||
#define RUBY_RELEASE_MONTH 4
|
#define RUBY_RELEASE_MONTH 5
|
||||||
#define RUBY_RELEASE_DAY 11
|
#define RUBY_RELEASE_DAY 14
|
||||||
|
|
||||||
#include "ruby/version.h"
|
#include "ruby/version.h"
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue