Parse length and location with scanInteger and not scanInt

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@39169 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Riccardo Mottola 2015-11-13 00:06:18 +00:00
parent 1451a8181c
commit c9d5a3d2cb
2 changed files with 13 additions and 8 deletions

View file

@ -1,3 +1,8 @@
2015-11-13 Riccardo Mottola <rm@gnu.org>
* Source/NSRange.m: (NSRangeFromString)
Parse length and location with scanInteger and not scanInt (suggested by Fred Kiefer to fix 64bit)
2015-11-02 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSXMLElement.m: (insertChild:atIndex:) if the child already

View file

@ -1,5 +1,5 @@
/** NSRange - range functions
* Copyright (C) 1993, 1994, 1995 Free Software Foundation, Inc.
* Copyright (C) 1993-2015 Free Software Foundation, Inc.
*
* Written by: Adam Fedor <fedor@boulder.colorado.edu>
* Date: Mar 1995
@ -36,10 +36,10 @@
static Class NSStringClass = 0;
static Class NSScannerClass = 0;
static SEL scanIntSel;
static SEL scanIntegerSel;
static SEL scanStringSel;
static SEL scannerSel;
static BOOL (*scanIntImp)(NSScanner*, SEL, int*);
static BOOL (*scanIntegerImp)(NSScanner*, SEL, NSInteger*);
static BOOL (*scanStringImp)(NSScanner*, SEL, NSString*, NSString**);
static id (*scannerImp)(Class, SEL, NSString*);
@ -50,11 +50,11 @@ setupCache(void)
{
NSStringClass = [NSString class];
NSScannerClass = [NSScanner class];
scanIntSel = @selector(scanInt:);
scanIntegerSel = @selector(scanInteger:);
scanStringSel = @selector(scanString:intoString:);
scannerSel = @selector(scannerWithString:);
scanIntImp = (BOOL (*)(NSScanner*, SEL, int*))
[NSScannerClass instanceMethodForSelector: scanIntSel];
scanIntegerImp = (BOOL (*)(NSScanner*, SEL, NSInteger*))
[NSScannerClass instanceMethodForSelector: scanIntegerSel];
scanStringImp = (BOOL (*)(NSScanner*, SEL, NSString*, NSString**))
[NSScannerClass instanceMethodForSelector: scanStringSel];
scannerImp = (id (*)(Class, SEL, NSString*))
@ -73,11 +73,11 @@ NSRangeFromString(NSString *aString)
if ((*scanStringImp)(scanner, scanStringSel, @"{", NULL)
&& (*scanStringImp)(scanner, scanStringSel, @"location", NULL)
&& (*scanStringImp)(scanner, scanStringSel, @"=", NULL)
&& (*scanIntImp)(scanner, scanIntSel, (int*)&range.location)
&& (*scanIntegerImp)(scanner, scanIntegerSel, (NSInteger*)&range.location)
&& (*scanStringImp)(scanner, scanStringSel, @",", NULL)
&& (*scanStringImp)(scanner, scanStringSel, @"length", NULL)
&& (*scanStringImp)(scanner, scanStringSel, @"=", NULL)
&& (*scanIntImp)(scanner, scanIntSel, (int*)&range.length)
&& (*scanIntegerImp)(scanner, scanIntegerSel, (NSInteger*)&range.length)
&& (*scanStringImp)(scanner, scanStringSel, @"}", NULL))
return range;
else