[#35719] Windows-31J <-> UTF-8 roundtrip — Tanaka Akira <akr@...>
以下のように Windows-31J と UTF-8 が roundtrip するかどうか
成瀬です。
In article <48932335.7010209@airemix.jp>,
成瀬です。
In article <48935EBD.3010603@airemix.jp>,
成瀬です。
[#35724] $SAFE=4の場合のReadline::HISTORY.each — Takao Kouji <kouji@...7.net>
knu さんへ
[#35726] "\x01\x00\x00\x00\x00\x00\x00\x21".encode("utf-8", "utf-32be", :invalid=>:replace) — Tanaka Akira <akr@...>
UTF-32BE で、文字として正しくない 4バイトと、文字として正し
[#35733] Re: [ruby-core:18078] We'll release 1.8.6/1.8.7 this Friday, #2 — Urabe Shyouhei <shyouhei@...>
というわけでそろそろリリースしようと思います。予定日は8月8日です。問題点
[#35745] [Bug:1.9] default_external depends on the order of -K and -E — sheepman <sh@...>
こんにちは sheepman です。
成瀬です。
Yuguiです。
[#35763] 文字コードがシンボルでないのは何故? — take_tk <ggb03124@...>
たけ(tk)です。
なかだです。
たけ(tk)です
[#35789] [Ruby 1.9 - Bug #407] (Open) String#<< — Shyouhei Urabe <redmine@...>
チケット #407 が報告されました。 (by Shyouhei Urabe)
まつもと ゆきひろです
Yukihiro Matsumoto さんは書きました:
まつもと ゆきひろです
成瀬です。
At 08:00 08/09/20, NARUSE, Yui wrote:
まつもと ゆきひろです
[#35811] fail to build extension libraries that includes some ruby header files — "Yusuke ENDOH" <mame@...>
遠藤です。
[#35834] 「サポートレベル」の定義、1.9.1のサポート予定プラットフォーム、メンテナ募集 — "Yugui (Yuki Sonoda)" <yugui@...>
Yuguiです。
[#35845] [Bug #437] test_strftime(TestTime) fails on Solaris — Shugo Maeda <redmine@...>
Bug #437: test_strftime(TestTime) fails on Solaris
前田です。
さとうふみやす @ OSS テクノロジです。
まつもと ゆきひろです
前田です。
まつもと ゆきひろです
前田です。
前田です。
まつもと ゆきひろです
前田です。
[#35851] [Feature:1.9] name referencing in sprintf — "Yusuke ENDOH" <mame@...>
遠藤です。
[#35863] Refactoring of enumerating prime numbers — "Yugui (Yuki Sonoda)" <yugui@...>
Yuguiです。
けいじゅ@いしつかです.
Yuguiです。
けいじゅ@いしつかです.
なかだです。
けいじゅ@いしつかです.
なかだです。
けいじゅ@いしつかです.
Yuguiです。
けいじゅ@いしつかです.
[#35899] [Bug #466] test_str_crypt(TestM17NComb) failed — Kazuhiro NISHIYAMA <redmine@...>
Bug #466: test_str_crypt(TestM17NComb) failed
[#35904] [Feature:1.9] pack format 'm' based on RFC 4648 — "Yusuke ENDOH" <mame@...>
遠藤です。
チケット #471 が更新されました。 (by Yuki Sonoda)
遠藤です。
In article <e0b1e5700809220338g5f3b5627p95e94744d5c10505@mail.gmail.com>,
遠藤です。
In article <e0b1e5700809231144n376fd4eencfe06c49ed66665e@mail.gmail.com>,
遠藤です。
[#35906] %N for Time#strftime — "Shugo Maeda" <shugo@...>
前田です。
In article <704d5db90808210811p7f3aef73h97913ade156323f3@mail.gmail.com>,
なかだです。
まつもと ゆきひろです
[#35922] [Bug #475] cgi.rbにNKFに依存したコードが入っている — Takeyuki Fujioka <redmine@...>
Bug #475: cgi.rbにNKFに依存したコードが入っている
[#35945] Re: [ruby-list:45386] Re: [ANN] REXMLのDoS脆弱性 — "Shugo Maeda" <shugo@...>
前田です。
前田です。
In message <704d5db90809010656k2042969bx3d8a4abdafeeea8e@mail.gmail.com>
[#35954] Re: [ruby-cvs:26052] Ruby:r18834 (trunk): * compile.c (defined_expr): should handle NODE_{AND,OR} as — SASADA Koichi <ko1@...>
ささだです.
まつもと ゆきひろです
ささだです.
まつもと ゆきひろです
ささだです.
まつもと ゆきひろです
[#35977] block parameter for Delagator — keiju@... (Keiju ISHITSUKA)
けいじゅ@いしつかです.
[#35986] 1.9と1.8で、delegateのインスタンスのクラス名の違う — Fujioka <fuj@...>
xibbarこと藤岡です。
まつもと ゆきひろです
けいじゅ@いしつかです.
藤岡です。
けいじゅ@いしつかです.
こんにちは、なかむら(う)です。
[#36008] [Bug #505] 1.upto 2 {|i| p i } — Shyouhei Urabe <redmine@...>
Bug #505: 1.upto 2 {|i| p i }
[#36028] [Bug #513] Tempfile yields [BUG] Stack consistency error — Shyouhei Urabe <redmine@...>
Bug #513: Tempfile yields [BUG] Stack consistency error
[#36033] [Bug #515] String#rindexが期待通りに動かない — Takeyuki Fujioka <redmine@...>
Bug #515: String#rindexが期待通りに動かない
[#36048] TypeError from Encoding.compatible? (r18920) — Yukihiro Matsumoto <matz@...>
まつもと ゆきひろです
[#36066] Numeric#scalar? — Tadayoshi Funaba <tadf@...>
1.9 の Numeric#scalar? について、適当でないのでは (real? などのほうがい
原です。
> やはり、scalar? はずれているんじゃないかな。real? の方がいい
原です。
> ここで、scalar? を疑問視する理由を復習すると、たとえば、「複
1.9.1 までに時間がないので scalar? だけ何とかしたいと思っていましたが、
前田です。
原です。
[ruby-dev:35912] Re: %N for Time#strftime
なかだです。
At Fri, 22 Aug 2008 13:31:07 +0900,
Yukihiro Matsumoto wrote in [ruby-dev:35911]:
> |> > のように書けるのですが、こちらはPerlのとは意味が違って、9より大きい値を指定
> |> > した時に、指定した桁数になるように前に0を詰める機能で、N以外の変換指定文
> |> > 字でも使えるようです。
> |>
> |> ちょっと試してみて思ったのですが、9 より大きな値を指定した時
> |> は 0 を右につけるべきじゃないですかね。
> |
> |+1
>
> 私もそう思います。コミット、コミット。
date/format.rbとstrftime.cで同じようなことをやっていると一貫させ
るのがめんどうなので、Timeでもtime_tの範囲を越える範囲を表現でき
るようにして、DateTimeでもTime#strftimeを使うというのはどうでしょ
うか。
とりあえずtime.cだけ。
Index: time.c
===================================================================
--- time.c (revision 18772)
+++ time.c (working copy)
@@ -23,5 +23,6 @@
VALUE rb_cTime;
-static VALUE time_utc_offset _((VALUE));
+static VALUE time_utc_offset(VALUE);
+static time_t make_time_t(struct tm *, int);
static ID id_divmod, id_mul, id_submicro;
@@ -30,6 +31,8 @@ struct time_object {
struct timespec ts;
struct tm tm;
- int gmt;
- int tm_got;
+ union {
+ struct {int gmt:1, tm_got:1, ts_got:1;} bits;
+ int flags;
+ } as;
};
@@ -43,4 +46,7 @@ time_free(void *tobj)
}
+#define IS_TIME(time) (TYPE(time) == T_DATA && RDATA(time)->dfree == time_free)
+
+
static VALUE
time_s_alloc(VALUE klass)
@@ -50,5 +56,5 @@ time_s_alloc(VALUE klass)
obj = Data_Make_Struct(klass, struct time_object, 0, time_free, tobj);
- tobj->tm_got=0;
+ tobj->as.flags = 0;
tobj->ts.tv_sec = 0;
tobj->ts.tv_nsec = 0;
@@ -96,5 +102,5 @@ time_init(VALUE time)
time_modify(time);
GetTimeval(time, tobj);
- tobj->tm_got=0;
+ tobj->as.flags = 0;
tobj->ts.tv_sec = 0;
tobj->ts.tv_nsec = 0;
@@ -113,4 +119,5 @@ time_init(VALUE time)
}
#endif
+ tobj->as.bits.ts_got = 1;
return time;
@@ -160,4 +167,6 @@ time_new_internal(VALUE klass, time_t se
tobj->ts.tv_sec = sec;
tobj->ts.tv_nsec = nsec;
+ tobj->as.flags = 0;
+ tobj->as.bits.ts_got = 1;
return time;
@@ -270,7 +279,11 @@ rb_time_timeval(VALUE time)
struct timeval t;
- if (TYPE(time) == T_DATA && RDATA(time)->dfree == time_free) {
+ if (IS_TIME(time)) {
GetTimeval(time, tobj);
- t.tv_sec = tobj->ts.tv_sec;
+ if (!tobj->as.bits.ts_got) {
+ tobj->ts.tv_sec = make_time_t(&tobj->tm, tobj->as.bits.gmt);
+ tobj->as.bits.ts_got = 1;
+ }
+ t.tv_sec = tobj->ts.tv_sec;
t.tv_usec = tobj->ts.tv_nsec / 1000;
return t;
@@ -279,14 +292,22 @@ rb_time_timeval(VALUE time)
}
+static struct timespec
+get_timespec(struct time_object *tobj)
+{
+ if (!tobj->as.bits.ts_got) {
+ tobj->ts.tv_sec = make_time_t(&tobj->tm, tobj->as.bits.gmt);
+ tobj->as.bits.ts_got = 1;
+ }
+ return tobj->ts;
+}
+
struct timespec
rb_time_timespec(VALUE time)
{
struct time_object *tobj;
- struct timespec t;
- if (TYPE(time) == T_DATA && RDATA(time)->dfree == time_free) {
+ if (IS_TIME(time)) {
GetTimeval(time, tobj);
- t = tobj->ts;
- return t;
+ return get_timespec(tobj);
}
return time_timespec(time, Qfalse);
@@ -328,10 +349,10 @@ time_s_at(int argc, VALUE *argv, VALUE k
}
t = time_new_internal(klass, ts.tv_sec, ts.tv_nsec);
- if (TYPE(time) == T_DATA && RDATA(time)->dfree == time_free) {
+ if (IS_TIME(time)) {
struct time_object *tobj, *tobj2;
GetTimeval(time, tobj);
GetTimeval(t, tobj2);
- tobj2->gmt = tobj->gmt;
+ tobj2->as.bits.gmt = tobj->as.bits.gmt;
}
return t;
@@ -589,5 +610,5 @@ typedef unsigned LONG_LONG unsigned_time
static time_t
-search_time_t(struct tm *tptr, int utc_p)
+search_time_t(struct tm *tptr, const int utc_p)
{
time_t guess, guess_lo, guess_hi;
@@ -897,10 +918,15 @@ time_utc_or_local(int argc, VALUE *argv,
struct tm tm;
VALUE time;
+ struct time_object *tobj;
long nsec;
time_arg(argc, argv, &tm, &nsec);
- time = time_new_internal(klass, make_time_t(&tm, utc_p), nsec);
- if (utc_p) return time_gmtime(time);
- return time_localtime(time);
+ time = time_s_alloc(klass);
+ GetTimeval(time, tobj);
+ tobj->tm = tm;
+ tobj->ts.tv_nsec = nsec;
+ tobj->as.bits.tm_got = 1;
+ tobj->as.bits.gmt = utc_p != 0;
+ return time;
}
@@ -993,4 +1019,5 @@ time_to_i(VALUE time)
GetTimeval(time, tobj);
+ get_timespec(tobj);
return LONG2NUM(tobj->ts.tv_sec);
}
@@ -1017,4 +1044,5 @@ time_to_f(VALUE time)
GetTimeval(time, tobj);
+ get_timespec(tobj);
return DOUBLE2NUM((double)tobj->ts.tv_sec+(double)tobj->ts.tv_nsec/1e9);
}
@@ -1038,4 +1066,5 @@ time_usec(VALUE time)
GetTimeval(time, tobj);
+ get_timespec(tobj);
return LONG2NUM(tobj->ts.tv_nsec/1000);
}
@@ -1064,4 +1093,5 @@ time_nsec(VALUE time)
GetTimeval(time, tobj);
+ get_timespec(tobj);
return LONG2NUM(tobj->ts.tv_nsec);
}
@@ -1093,6 +1123,8 @@ time_cmp(VALUE time1, VALUE time2)
GetTimeval(time1, tobj1);
- if (TYPE(time2) == T_DATA && RDATA(time2)->dfree == time_free) {
+ if (IS_TIME(time2)) {
GetTimeval(time2, tobj2);
+ get_timespec(tobj1);
+ get_timespec(tobj2);
if (tobj1->ts.tv_sec == tobj2->ts.tv_sec) {
if (tobj1->ts.tv_nsec == tobj2->ts.tv_nsec) return INT2FIX(0);
@@ -1132,6 +1164,8 @@ time_eql(VALUE time1, VALUE time2)
GetTimeval(time1, tobj1);
- if (TYPE(time2) == T_DATA && RDATA(time2)->dfree == time_free) {
+ if (IS_TIME(time2)) {
GetTimeval(time2, tobj2);
+ get_timespec(tobj1);
+ get_timespec(tobj2);
if (tobj1->ts.tv_sec == tobj2->ts.tv_sec) {
if (tobj1->ts.tv_nsec == tobj2->ts.tv_nsec) return Qtrue;
@@ -1166,5 +1200,5 @@ time_utc_p(VALUE time)
GetTimeval(time, tobj);
- if (tobj->gmt) return Qtrue;
+ if (tobj->as.bits.gmt) return Qtrue;
return Qfalse;
}
@@ -1180,9 +1214,8 @@ static VALUE
time_hash(VALUE time)
{
- struct time_object *tobj;
+ struct timespec ts = rb_time_timespec(time);
long hash;
- GetTimeval(time, tobj);
- hash = tobj->ts.tv_sec ^ tobj->ts.tv_nsec;
+ hash = ts.tv_sec ^ ts.tv_nsec;
return LONG2FIX(hash);
}
@@ -1196,5 +1229,5 @@ time_init_copy(VALUE copy, VALUE time)
if (copy == time) return copy;
time_modify(copy);
- if (TYPE(time) != T_DATA || RDATA(time)->dfree != time_free) {
+ if (!IS_TIME(time)) {
rb_raise(rb_eTypeError, "wrong argument type");
}
@@ -1236,6 +1269,6 @@ time_localtime(VALUE time)
GetTimeval(time, tobj);
- if (!tobj->gmt) {
- if (tobj->tm_got)
+ if (!tobj->as.bits.gmt) {
+ if (tobj->as.bits.tm_got)
return time;
}
@@ -1243,11 +1276,11 @@ time_localtime(VALUE time)
time_modify(time);
}
- t = tobj->ts.tv_sec;
+ t = get_timespec(tobj).tv_sec;
tm_tmp = LOCALTIME(&t, result);
if (!tm_tmp)
rb_raise(rb_eArgError, "localtime error");
tobj->tm = *tm_tmp;
- tobj->tm_got = 1;
- tobj->gmt = 0;
+ tobj->as.bits.tm_got = 1;
+ tobj->as.bits.gmt = 0;
return time;
}
@@ -1280,6 +1313,6 @@ time_gmtime(VALUE time)
GetTimeval(time, tobj);
- if (tobj->gmt) {
- if (tobj->tm_got)
+ if (tobj->as.bits.gmt) {
+ if (tobj->as.bits.tm_got)
return time;
}
@@ -1287,4 +1320,5 @@ time_gmtime(VALUE time)
time_modify(time);
}
+ get_timespec(tobj);
t = tobj->ts.tv_sec;
tm_tmp = GMTIME(&t, result);
@@ -1292,6 +1326,6 @@ time_gmtime(VALUE time)
rb_raise(rb_eArgError, "gmtime error");
tobj->tm = *tm_tmp;
- tobj->tm_got = 1;
- tobj->gmt = 1;
+ tobj->as.bits.tm_got = 1;
+ tobj->as.bits.gmt = 1;
return time;
}
@@ -1363,6 +1397,6 @@ time_asctime(VALUE time)
GetTimeval(time, tobj);
- if (tobj->tm_got == 0) {
- time_get_tm(time, tobj->gmt);
+ if (tobj->as.bits.tm_got == 0) {
+ time_get_tm(time, tobj->as.bits.gmt);
}
s = ASCTIME(&tobj->tm, buf);
@@ -1400,14 +1434,14 @@ time_to_s(VALUE time)
GetTimeval(time, tobj);
- if (tobj->tm_got == 0) {
- time_get_tm(time, tobj->gmt);
+ if (tobj->as.bits.tm_got == 0) {
+ time_get_tm(time, tobj->as.bits.gmt);
}
- if (tobj->gmt == 1) {
+ if (tobj->as.bits.gmt) {
len = rb_strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S UTC",
- &tobj->tm, &tobj->ts, tobj->gmt);
+ &tobj->tm, &tobj->ts, tobj->as.bits.gmt);
}
else {
len = rb_strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S %z",
- &tobj->tm, &tobj->ts, tobj->gmt);
+ &tobj->tm, &tobj->ts, tobj->as.bits.gmt);
}
return rb_str_new(buf, len);
@@ -1428,4 +1462,5 @@ time_add(struct time_object *tobj, VALUE
sign = -sign;
}
+ get_timespec(tobj);
d = modf(v, &f);
sec_off = (unsigned_time_t)f;
@@ -1448,7 +1483,7 @@ time_add(struct time_object *tobj, VALUE
}
result = rb_time_nano_new(sec, nsec);
- if (tobj->gmt) {
+ if (tobj->as.bits.gmt) {
GetTimeval(result, tobj);
- tobj->gmt = 1;
+ tobj->as.bits.gmt = 1;
}
return result;
@@ -1472,5 +1507,5 @@ time_plus(VALUE time1, VALUE time2)
GetTimeval(time1, tobj);
- if (TYPE(time2) == T_DATA && RDATA(time2)->dfree == time_free) {
+ if (IS_TIME(time2)) {
rb_raise(rb_eTypeError, "time + time?");
}
@@ -1499,9 +1534,11 @@ time_minus(VALUE time1, VALUE time2)
GetTimeval(time1, tobj);
- if (TYPE(time2) == T_DATA && RDATA(time2)->dfree == time_free) {
+ if (IS_TIME(time2)) {
struct time_object *tobj2;
double f;
GetTimeval(time2, tobj2);
+ get_timespec(tobj);
+ get_timespec(tobj2);
if (tobj->ts.tv_sec < tobj2->ts.tv_sec)
f = -(double)(unsigned_time_t)(tobj2->ts.tv_sec - tobj->ts.tv_sec);
@@ -1532,8 +1569,9 @@ time_succ(VALUE time)
GetTimeval(time, tobj);
- gmt = tobj->gmt;
+ get_timespec(tobj);
+ gmt = tobj->as.bits.gmt;
time = rb_time_nano_new(tobj->ts.tv_sec + 1, tobj->ts.tv_nsec);
GetTimeval(time, tobj);
- tobj->gmt = gmt;
+ tobj->as.bits.gmt = gmt;
return time;
}
@@ -1564,6 +1602,6 @@ time_sec(VALUE time)
GetTimeval(time, tobj);
- if (tobj->tm_got == 0) {
- time_get_tm(time, tobj->gmt);
+ if (!tobj->as.bits.tm_got) {
+ time_get_tm(time, tobj->as.bits.gmt);
}
return INT2FIX(tobj->tm.tm_sec);
@@ -1586,6 +1624,6 @@ time_min(VALUE time)
GetTimeval(time, tobj);
- if (tobj->tm_got == 0) {
- time_get_tm(time, tobj->gmt);
+ if (!tobj->as.bits.tm_got) {
+ time_get_tm(time, tobj->as.bits.gmt);
}
return INT2FIX(tobj->tm.tm_min);
@@ -1608,6 +1646,6 @@ time_hour(VALUE time)
GetTimeval(time, tobj);
- if (tobj->tm_got == 0) {
- time_get_tm(time, tobj->gmt);
+ if (!tobj->as.bits.tm_got) {
+ time_get_tm(time, tobj->as.bits.gmt);
}
return INT2FIX(tobj->tm.tm_hour);
@@ -1632,6 +1670,6 @@ time_mday(VALUE time)
GetTimeval(time, tobj);
- if (tobj->tm_got == 0) {
- time_get_tm(time, tobj->gmt);
+ if (!tobj->as.bits.tm_got) {
+ time_get_tm(time, tobj->as.bits.gmt);
}
return INT2FIX(tobj->tm.tm_mday);
@@ -1656,6 +1694,6 @@ time_mon(VALUE time)
GetTimeval(time, tobj);
- if (tobj->tm_got == 0) {
- time_get_tm(time, tobj->gmt);
+ if (!tobj->as.bits.tm_got) {
+ time_get_tm(time, tobj->as.bits.gmt);
}
return INT2FIX(tobj->tm.tm_mon+1);
@@ -1678,6 +1716,6 @@ time_year(VALUE time)
GetTimeval(time, tobj);
- if (tobj->tm_got == 0) {
- time_get_tm(time, tobj->gmt);
+ if (!tobj->as.bits.tm_got) {
+ time_get_tm(time, tobj->as.bits.gmt);
}
return LONG2NUM((long)tobj->tm.tm_year+1900);
@@ -1708,6 +1746,6 @@ time_wday(VALUE time)
GetTimeval(time, tobj);
- if (tobj->tm_got == 0) {
- time_get_tm(time, tobj->gmt);
+ if (!tobj->as.bits.tm_got) {
+ time_get_tm(time, tobj->as.bits.gmt);
}
return INT2FIX(tobj->tm.tm_wday);
@@ -1717,6 +1755,6 @@ time_wday(VALUE time)
struct time_object *tobj;\
GetTimeval(time, tobj);\
- if (tobj->tm_got == 0) {\
- time_get_tm(time, tobj->gmt);\
+ if (!tobj->as.bits.tm_got) {\
+ time_get_tm(time, tobj->as.bits.gmt);\
}\
return (tobj->tm.tm_wday == (n)) ? Qtrue : Qfalse;\
@@ -1851,6 +1889,6 @@ time_yday(VALUE time)
GetTimeval(time, tobj);
- if (tobj->tm_got == 0) {
- time_get_tm(time, tobj->gmt);
+ if (!tobj->as.bits.tm_got) {
+ time_get_tm(time, tobj->as.bits.gmt);
}
return INT2FIX(tobj->tm.tm_yday+1);
@@ -1888,6 +1926,6 @@ time_isdst(VALUE time)
GetTimeval(time, tobj);
- if (tobj->tm_got == 0) {
- time_get_tm(time, tobj->gmt);
+ if (!tobj->as.bits.tm_got) {
+ time_get_tm(time, tobj->as.bits.gmt);
}
return tobj->tm.tm_isdst?Qtrue:Qfalse;
@@ -1917,9 +1955,9 @@ time_zone(VALUE time)
GetTimeval(time, tobj);
- if (tobj->tm_got == 0) {
- time_get_tm(time, tobj->gmt);
+ if (!tobj->as.bits.tm_got) {
+ time_get_tm(time, tobj->as.bits.gmt);
}
- if (tobj->gmt == 1) {
+ if (tobj->as.bits.gmt) {
return rb_str_new2("UTC");
}
@@ -1930,5 +1968,5 @@ time_zone(VALUE time)
#else
len = rb_strftime(buf, sizeof(buf), "%Z",
- &tobj->tm, &tobj->ts, tobj->gmt);
+ &tobj->tm, &tobj->ts, tobj->as.bits.gmt);
return rb_str_new(buf, len);
#endif
@@ -1956,9 +1994,9 @@ time_utc_offset(VALUE time)
GetTimeval(time, tobj);
- if (tobj->tm_got == 0) {
- time_get_tm(time, tobj->gmt);
+ if (!tobj->as.bits.tm_got) {
+ time_get_tm(time, tobj->as.bits.gmt);
}
- if (tobj->gmt == 1) {
+ if (tobj->as.bits.gmt) {
return INT2FIX(0);
}
@@ -1972,4 +2010,5 @@ time_utc_offset(VALUE time)
IF_HAVE_GMTIME_R(struct tm result);
l = &tobj->tm;
+ get_timespec(tobj);
t = tobj->ts.tv_sec;
u = GMTIME(&t, result);
@@ -2013,6 +2052,6 @@ time_to_a(VALUE time)
GetTimeval(time, tobj);
- if (tobj->tm_got == 0) {
- time_get_tm(time, tobj->gmt);
+ if (!tobj->as.bits.tm_got) {
+ time_get_tm(time, tobj->as.bits.gmt);
}
return rb_ary_new3(10,
@@ -2119,6 +2158,6 @@ time_strftime(VALUE time, VALUE format)
GetTimeval(time, tobj);
- if (tobj->tm_got == 0) {
- time_get_tm(time, tobj->gmt);
+ if (!tobj->as.bits.tm_got) {
+ time_get_tm(time, tobj->as.bits.gmt);
}
StringValue(format);
@@ -2138,5 +2177,5 @@ time_strftime(VALUE time, VALUE format)
str = rb_str_new(0, 0);
while (p < pe) {
- len = rb_strftime_alloc(&buf, p, &tobj->tm, &tobj->ts, tobj->gmt);
+ len = rb_strftime_alloc(&buf, p, &tobj->tm, &tobj->ts, tobj->as.bits.gmt);
rb_str_cat(str, buf, len);
p += strlen(p);
@@ -2152,5 +2191,5 @@ time_strftime(VALUE time, VALUE format)
else {
len = rb_strftime_alloc(&buf, RSTRING_PTR(format),
- &tobj->tm, &tobj->ts, tobj->gmt);
+ &tobj->tm, &tobj->ts, tobj->as.bits.gmt);
}
str = rb_str_new(buf, len);
@@ -2174,4 +2213,5 @@ time_mdump(VALUE time)
int nsec;
int i;
+ int gmt;
VALUE str;
IF_HAVE_GMTIME_R(struct tm result);
@@ -2179,12 +2219,18 @@ time_mdump(VALUE time)
GetTimeval(time, tobj);
- t = tobj->ts.tv_sec;
- tm = GMTIME(&t, result);
+ if (tobj->as.bits.tm_got) {
+ tm = &tobj->tm;
+ }
+ else {
+ t = tobj->ts.tv_sec;
+ tm = GMTIME(&t, result);
+ }
if ((tm->tm_year & 0xffff) != tm->tm_year)
rb_raise(rb_eArgError, "year too big to marshal: %ld", (long)tm->tm_year);
+ gmt = tobj->as.bits.gmt;
p = 0x1UL << 31 | /* 1 */
- tobj->gmt << 30 | /* 1 */
+ gmt << 30 | /* 1 */
tm->tm_year << 14 | /* 16 */
tm->tm_mon << 10 | /* 4 */
@@ -2286,9 +2332,15 @@ time_mload(VALUE time, VALUE str)
}
+ GetTimeval(time, tobj);
if ((p & (1UL<<31)) == 0) {
- gmt = 0;
sec = p;
usec = s;
nsec = usec * 1000;
+ time_overflow_p(&sec, &nsec);
+ tobj->as.bits.tm_got = 0;
+ tobj->as.bits.ts_got = 1;
+ tobj->as.bits.gmt = 0;
+ tobj->ts.tv_sec = sec;
+ tobj->ts.tv_nsec = nsec;
}
else {
@@ -2303,5 +2355,4 @@ time_mload(VALUE time, VALUE str)
tm.tm_isdst = 0;
- sec = make_time_t(&tm, Qtrue);
usec = (long)(s & 0xfffff);
nsec = usec * 1000;
@@ -2323,14 +2374,12 @@ time_mload(VALUE time, VALUE str)
nsec += digit;
}
-end_submicro: ;
}
+ end_submicro:
+ tobj->as.bits.tm_got = 1;
+ tobj->as.bits.ts_got = 1;
+ tobj->as.bits.gmt = gmt;
+ tobj->tm = tm;
+ tobj->ts.tv_nsec = nsec;
}
- time_overflow_p(&sec, &nsec);
-
- GetTimeval(time, tobj);
- tobj->tm_got = 0;
- tobj->gmt = gmt;
- tobj->ts.tv_sec = sec;
- tobj->ts.tv_nsec = nsec;
return time;
--
--- 僕の前にBugはない。
--- 僕の後ろにBugはできる。
中田 伸悦