util.c: ignore too long fraction part
* util.c (ruby_strtod): ignore too long fraction part, which does not affect the result. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43775 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
e71bb2c54e
commit
5cb83d9dab
@ -1,3 +1,8 @@
|
|||||||
|
Fri Nov 22 12:43:52 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* util.c (ruby_strtod): ignore too long fraction part, which does not
|
||||||
|
affect the result.
|
||||||
|
|
||||||
Fri Nov 22 12:17:14 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Fri Nov 22 12:17:14 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* ext/openssl/lib/openssl/buffering.rb (OpenSSL::Buffering#initialize):
|
* ext/openssl/lib/openssl/buffering.rb (OpenSSL::Buffering#initialize):
|
||||||
|
@ -613,4 +613,10 @@ class TestFloat < Test::Unit::TestCase
|
|||||||
# always not flonum
|
# always not flonum
|
||||||
assert_raise(TypeError) { a = Float::INFINITY; def a.foo; end }
|
assert_raise(TypeError) { a = Float::INFINITY; def a.foo; end }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_long_string
|
||||||
|
assert_separately([], <<-'end;')
|
||||||
|
assert_in_epsilon(10.0, ("1."+"1"*300000).to_f*9)
|
||||||
|
end;
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
14
util.c
14
util.c
@ -716,6 +716,11 @@ extern void *MALLOC(size_t);
|
|||||||
#else
|
#else
|
||||||
#define MALLOC malloc
|
#define MALLOC malloc
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef FREE
|
||||||
|
extern void FREE(void*);
|
||||||
|
#else
|
||||||
|
#define FREE free
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef Omit_Private_Memory
|
#ifndef Omit_Private_Memory
|
||||||
#ifndef PRIVATE_MEM
|
#ifndef PRIVATE_MEM
|
||||||
@ -1006,7 +1011,7 @@ Balloc(int k)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
ACQUIRE_DTOA_LOCK(0);
|
ACQUIRE_DTOA_LOCK(0);
|
||||||
if ((rv = freelist[k]) != 0) {
|
if (k <= Kmax && (rv = freelist[k]) != 0) {
|
||||||
freelist[k] = rv->next;
|
freelist[k] = rv->next;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -1016,7 +1021,7 @@ Balloc(int k)
|
|||||||
#else
|
#else
|
||||||
len = (sizeof(Bigint) + (x-1)*sizeof(ULong) + sizeof(double) - 1)
|
len = (sizeof(Bigint) + (x-1)*sizeof(ULong) + sizeof(double) - 1)
|
||||||
/sizeof(double);
|
/sizeof(double);
|
||||||
if (pmem_next - private_mem + len <= PRIVATE_mem) {
|
if (k <= Kmax && pmem_next - private_mem + len <= PRIVATE_mem) {
|
||||||
rv = (Bigint*)pmem_next;
|
rv = (Bigint*)pmem_next;
|
||||||
pmem_next += len;
|
pmem_next += len;
|
||||||
}
|
}
|
||||||
@ -1035,6 +1040,10 @@ static void
|
|||||||
Bfree(Bigint *v)
|
Bfree(Bigint *v)
|
||||||
{
|
{
|
||||||
if (v) {
|
if (v) {
|
||||||
|
if (v->k > Kmax) {
|
||||||
|
FREE(v);
|
||||||
|
return;
|
||||||
|
}
|
||||||
ACQUIRE_DTOA_LOCK(0);
|
ACQUIRE_DTOA_LOCK(0);
|
||||||
v->next = freelist[v->k];
|
v->next = freelist[v->k];
|
||||||
freelist[v->k] = v;
|
freelist[v->k] = v;
|
||||||
@ -2098,6 +2107,7 @@ break2:
|
|||||||
for (; c >= '0' && c <= '9'; c = *++s) {
|
for (; c >= '0' && c <= '9'; c = *++s) {
|
||||||
have_dig:
|
have_dig:
|
||||||
nz++;
|
nz++;
|
||||||
|
if (nf > DBL_DIG * 2) continue;
|
||||||
if (c -= '0') {
|
if (c -= '0') {
|
||||||
nf += nz;
|
nf += nz;
|
||||||
for (i = 1; i < nz; i++)
|
for (i = 1; i < nz; i++)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user