mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
Fix allowing floats on input
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@32450 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
f56cc75a10
commit
946dc8d864
2 changed files with 25 additions and 3 deletions
|
@ -1,3 +1,8 @@
|
|||
2011-03-04 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSNumberFormatter.m: Fix -setAllowsFloats to only operate
|
||||
in input strings.
|
||||
|
||||
2011-03-03 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSKeyValueObserving.m: Fix possible thread race condition.
|
||||
|
|
|
@ -406,6 +406,24 @@ static NSUInteger _defaultBehavior = NSNumberFormatterBehavior10_4;
|
|||
/* FIXME: This is just a quick hack implementation. */
|
||||
NSLog(@"NSNumberFormatter-getObjectValue:forString:... not fully implemented");
|
||||
|
||||
if (nil == string)
|
||||
{
|
||||
if (0 != error)
|
||||
{
|
||||
*error = _(@"nil string");
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
if (NO == [self allowsFloats] && [string rangeOfString: @"."].length > 0)
|
||||
{
|
||||
if (0 != error)
|
||||
{
|
||||
*error = _(@"floating point values not allowed");
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
/* Just assume nothing else has been setup and do a simple conversion. */
|
||||
if ([self hasThousandSeparators])
|
||||
{
|
||||
|
@ -930,9 +948,8 @@ static NSUInteger _defaultBehavior = NSNumberFormatterBehavior10_4;
|
|||
displayThousandsSeparators = YES;
|
||||
}
|
||||
|
||||
if ([self allowsFloats]
|
||||
&& (NSNotFound
|
||||
!= [useFormat rangeOfString: defaultDecimalSeparator].location))
|
||||
if (NSNotFound
|
||||
!= [useFormat rangeOfString: defaultDecimalSeparator].location)
|
||||
{
|
||||
decimalPlaceRange = [useFormat rangeOfString: defaultDecimalSeparator
|
||||
options: NSBackwardsSearch];
|
||||
|
|
Loading…
Reference in a new issue