ext/oj/load.c in oj-2.0.0 vs ext/oj/load.c in oj-2.0.1
- old
+ new
@@ -823,11 +823,16 @@
static VALUE
read_time(ParseInfo pi) {
time_t v = 0;
long v2 = 0;
+ int neg = 0;
+ if ('-' == *pi->s) {
+ pi->s++;
+ neg = 1;
+ }
for (; '0' <= *pi->s && *pi->s <= '9'; pi->s++) {
v = v * 10 + (*pi->s - '0');
}
if ('.' == *pi->s) {
int cnt;
@@ -836,9 +841,16 @@
for (cnt = 9; 0 < cnt && '0' <= *pi->s && *pi->s <= '9'; pi->s++, cnt--) {
v2 = v2 * 10 + (*pi->s - '0');
}
for (; 0 < cnt; cnt--) {
v2 *= 10;
+ }
+ }
+ if (neg) {
+ v = -v;
+ if (0 < v2) {
+ v--;
+ v2 = 1000000000 - v2;
}
}
#if HAS_NANO_TIME
return rb_time_nano_new(v, v2);
#else