discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Missing implementations in NSScanner class


From: Niels Grewe
Subject: Re: Missing implementations in NSScanner class
Date: Thu, 16 Jan 2014 15:54:49 +0000

Hi Mathias,

first of all: Thanks for your patches! Unfortunately, this one is not correct 
for 32bit systems. The reason is that NSInteger is pointer sized, so it’s a 
32bit quantity on 32bit platforms. On 32bit OS X/iOS, calling -scanInteger: 
with a string representing a larger value (say β€ž9223372036854775807β€œ, aka 
LLONG_MAX), will give you the maximum value an integer can hold, while your 
solution will just do some implementation defined thing when casting the 64bit 
value to 32bits. (I think most of the time, you just loose the higher bits, so 
for β€ž9223372036854775807", you might get -1 instead of 2147483647, which would 
the correct result given the Apple implementation).

Cheers,

Niels

Am 16.01.2014 um 15:52 schrieb Mathias Bauer <mathias_bauer@gmx.net>:

> Hi,
> 
> I discovered that NSScanner misses some "scan..." methods. At least in one 
> case it should be trivial to add it:
> 
>> - (BOOL) scanInteger: (NSInteger *)value
>> {
>>      long long result;
>>      BOOL ret = [self scanLongLong:&result];
>>      if (value && ret)
>>              *value = (NSInteger)result;
>>      return ret;
>> }
> 
> Would it be possible to add this as a patch?
> 
> Regards,
> Mathias
> 
> _______________________________________________
> Discuss-gnustep mailing list
> Discuss-gnustep@gnu.org
> https://lists.gnu.org/mailman/listinfo/discuss-gnustep




reply via email to

[Prev in Thread] Current Thread [Next in Thread]