mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 08:26:27 +00:00
allow longer double values.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@26991 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
5218659e48
commit
42978df814
1 changed files with 19 additions and 5 deletions
|
@ -1499,13 +1499,27 @@ doubleValue_c(GSStr self)
|
|||
}
|
||||
else
|
||||
{
|
||||
unsigned l = (end - ptr) < 32 ? (end - ptr) : 31;
|
||||
unichar buf[l+1];
|
||||
unichar *b = buf;
|
||||
unsigned s = 99;
|
||||
unichar b[100];
|
||||
unichar *u = b;
|
||||
double d = 0.0;
|
||||
|
||||
GSToUnicode(&b, &l, (const uint8_t*)ptr, l, internalEncoding, 0, 0);
|
||||
GSScanDouble(b, l, &d);
|
||||
/* use static buffer unless string is really long, in which case
|
||||
* we use the stack to allocate a bigger one.
|
||||
*/
|
||||
if (GSToUnicode(&u, &s, (const uint8_t*)ptr, end - ptr,
|
||||
internalEncoding, NSDefaultMallocZone(), GSUniTerminate) == NO)
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
if (GSScanDouble(u, end - ptr, &d) == NO)
|
||||
{
|
||||
d = 0.0;
|
||||
}
|
||||
if (u != b)
|
||||
{
|
||||
NSZoneFree(NSDefaultMallocZone(), u);
|
||||
}
|
||||
return d;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue