mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-20 20:26:42 +00:00
Use new private method to scan double values.
This commit is contained in:
parent
657e49edeb
commit
3dc437524e
2 changed files with 30 additions and 49 deletions
|
@ -67,6 +67,7 @@
|
|||
#import "Foundation/NSLocale.h"
|
||||
#import "Foundation/NSLock.h"
|
||||
#import "Foundation/NSNotification.h"
|
||||
#import "Foundation/NSScanner.h"
|
||||
#import "Foundation/NSUserDefaults.h"
|
||||
#import "Foundation/FoundationErrors.h"
|
||||
// For private method _decodePropertyListForKey:
|
||||
|
@ -127,7 +128,9 @@ uni_tolower(unichar ch)
|
|||
|
||||
#import "GNUstepBase/Unicode.h"
|
||||
|
||||
extern BOOL GSScanDouble(unichar*, unsigned, double*);
|
||||
@interface NSScanner (Double)
|
||||
+ (BOOL) _scanDouble: (double*)value from: (NSString*)str;
|
||||
@end
|
||||
|
||||
@class GSString;
|
||||
@class GSMutableString;
|
||||
|
@ -200,19 +203,6 @@ static inline BOOL isWhiteSpace(unichar c)
|
|||
|
||||
#define GS_IS_WHITESPACE(X) isWhiteSpace(X)
|
||||
|
||||
static NSCharacterSet *nonspace = nil;
|
||||
|
||||
static void setupNonspace(void)
|
||||
{
|
||||
if (nil == nonspace)
|
||||
{
|
||||
NSCharacterSet *w;
|
||||
|
||||
w = [NSCharacterSet whitespaceAndNewlineCharacterSet];
|
||||
nonspace = [[w invertedSet] retain];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* A non-spacing character is one which is part of a 'user-perceived character'
|
||||
* where the user perceived character consists of a base character followed
|
||||
|
@ -3967,17 +3957,8 @@ GSICUCollatorOpen(NSStringCompareOptions mask, NSLocale *locale)
|
|||
*/
|
||||
- (double) doubleValue
|
||||
{
|
||||
unichar buf[32];
|
||||
double d = 0.0;
|
||||
NSRange r;
|
||||
|
||||
setupNonspace();
|
||||
r = [self rangeOfCharacterFromSet: nonspace];
|
||||
if (NSNotFound == r.location) return 0.0;
|
||||
r.length = [self length] - r.location;
|
||||
if (r.length > 32) r.length = 32;
|
||||
[self getCharacters: buf range: r];
|
||||
GSScanDouble(buf, r.length, &d);
|
||||
[NSScanner _scanDouble: &d from: self];
|
||||
return d;
|
||||
}
|
||||
|
||||
|
@ -3988,17 +3969,8 @@ GSICUCollatorOpen(NSStringCompareOptions mask, NSLocale *locale)
|
|||
*/
|
||||
- (float) floatValue
|
||||
{
|
||||
unichar buf[32];
|
||||
double d = 0.0;
|
||||
NSRange r;
|
||||
|
||||
setupNonspace();
|
||||
r = [self rangeOfCharacterFromSet: nonspace];
|
||||
if (NSNotFound == r.location) return 0.0;
|
||||
r.length = [self length] - r.location;
|
||||
if (r.length > 32) r.length = 32;
|
||||
[self getCharacters: buf range: r];
|
||||
GSScanDouble(buf, r.length, &d);
|
||||
[NSScanner _scanDouble: &d from: self];
|
||||
return (float)d;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue