* time.c (time_mload): ignore invalid digits in submicro.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13987 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2007-11-20 12:50:29 +00:00
Родитель 01dacec2b4
Коммит 43e55c6bc4
2 изменённых файлов: 14 добавлений и 6 удалений

Просмотреть файл

@ -1,3 +1,7 @@
Tue Nov 20 21:46:46 2007 Tanaka Akira <akr@fsij.org>
* time.c (time_mload): ignore invalid digits in submicro.
Tue Nov 20 20:33:32 2007 Koichi Sasada <ko1@atdot.net>
* include/ruby/ruby.h: rename RFloat#double_value -> float_value.

16
time.c
Просмотреть файл

@ -2244,9 +2244,6 @@ time_mload(VALUE time, VALUE str)
nsec = usec * 1000;
}
else {
unsigned char *ptr;
long len;
p &= ~(1UL<<31);
gmt = (p >> 30) & 0x1;
tm.tm_year = (p >> 14) & 0xffff;
@ -2262,15 +2259,22 @@ time_mload(VALUE time, VALUE str)
nsec = usec * 1000;
if (submicro != Qnil) {
unsigned char *ptr;
long len;
int digit;
ptr = (unsigned char*)StringValuePtr(submicro);
len = RSTRING_LEN(submicro);
if (0 < len) {
nsec += (ptr[0] >> 4) * 100;
nsec += (ptr[0] & 0xf) * 10;
if (10 <= (digit = ptr[0] >> 4)) goto end_submicro;
nsec += digit * 100;
if (10 <= (digit = ptr[0] & 0xf)) goto end_submicro;
nsec += digit * 10;
}
if (1 < len) {
nsec += (ptr[1] >> 4);
if (10 <= (digit = ptr[1] >> 4)) goto end_submicro;
nsec += digit;
}
end_submicro: ;
}
}
time_overflow_p(&sec, &nsec);