mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 16:30:41 +00:00
property list deserialisation tweaks
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@35395 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
96a43795ee
commit
78206d0b38
6 changed files with 209 additions and 30 deletions
|
@ -3332,22 +3332,82 @@ static UCollator *GSICUCollatorOpen(NSStringCompareOptions mask, NSLocale *local
|
|||
|
||||
/**
|
||||
* <p>Returns the string's content as an int.<br/>
|
||||
* Current implementation uses C library <code>atoi()</code>, which does not
|
||||
* Current implementation uses a C runtime library function, which does not
|
||||
* detect conversion errors -- use with care!</p>
|
||||
*/
|
||||
- (int) intValue
|
||||
{
|
||||
return atoi([self UTF8String]);
|
||||
const char *ptr = [self UTF8String];
|
||||
|
||||
while (isspace(*ptr))
|
||||
{
|
||||
ptr++;
|
||||
}
|
||||
if ('-' == *ptr)
|
||||
{
|
||||
return (int)atoi(ptr);
|
||||
}
|
||||
else
|
||||
{
|
||||
uint64_t v;
|
||||
|
||||
#if defined(__MINGW__)
|
||||
v = _strtoui64(ptr, 0, 10);
|
||||
#else
|
||||
v = strtoul(ptr, 0, 10);
|
||||
#endif
|
||||
return (int)v;
|
||||
}
|
||||
}
|
||||
|
||||
- (NSInteger) integerValue
|
||||
{
|
||||
return atol([self UTF8String]);
|
||||
const char *ptr = [self UTF8String];
|
||||
|
||||
while (isspace(*ptr))
|
||||
{
|
||||
ptr++;
|
||||
}
|
||||
if ('-' == *ptr)
|
||||
{
|
||||
return (NSInteger)atoll(ptr);
|
||||
}
|
||||
else
|
||||
{
|
||||
uint64_t v;
|
||||
|
||||
#if defined(__MINGW__)
|
||||
v = _strtoui64(ptr, 0, 10);
|
||||
#else
|
||||
v = strtoull(ptr, 0, 10);
|
||||
#endif
|
||||
return (NSInteger)v;
|
||||
}
|
||||
}
|
||||
|
||||
- (long long) longLongValue
|
||||
{
|
||||
return atoll([self UTF8String]);
|
||||
const char *ptr = [self UTF8String];
|
||||
|
||||
while (isspace(*ptr))
|
||||
{
|
||||
ptr++;
|
||||
}
|
||||
if ('-' == *ptr)
|
||||
{
|
||||
return atoll(ptr);
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned long long l;
|
||||
|
||||
#if defined(__MINGW__)
|
||||
l = _strtoui64(ptr, 0, 10);
|
||||
#else
|
||||
l = strtoull(ptr, 0, 10);
|
||||
#endif
|
||||
return (long long)l;
|
||||
}
|
||||
}
|
||||
|
||||
// Working With Encodings
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue