mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 08:41:03 +00:00
Fixed a long standing NSNumberFormatter bug in conjunction with zero padding
and (old) NSNumberFormatterBehavior10_0 git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@39245 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
82c85333b5
commit
5f9bfda3f5
3 changed files with 20 additions and 5 deletions
|
@ -1271,16 +1271,18 @@ static NSUInteger _defaultBehavior = NSNumberFormatterBehavior10_4;
|
|||
|
||||
//sort out the padding for the integer part
|
||||
intPartRange = [useFormat rangeOfCharacterFromSet: placeHolders];
|
||||
if (NSMaxRange(intPartRange) < ([useFormat length] - 1))
|
||||
if (intPartRange.location != NSNotFound)
|
||||
{
|
||||
int nextFormatCharLoc = intPartRange.location;
|
||||
while (([placeHolders characterIsMember:
|
||||
[useFormat characterAtIndex: NSMaxRange(intPartRange)]]
|
||||
[useFormat characterAtIndex: nextFormatCharLoc]]
|
||||
|| [[useFormat substringWithRange:
|
||||
NSMakeRange(NSMaxRange(intPartRange), 1)] isEqual:
|
||||
NSMakeRange(nextFormatCharLoc, 1)] isEqual:
|
||||
defaultThousandsSeparator])
|
||||
&& NSMaxRange(intPartRange) < [useFormat length] - 1)
|
||||
&& nextFormatCharLoc < [useFormat length] - 1)
|
||||
{
|
||||
intPartRange.length++;
|
||||
nextFormatCharLoc++;
|
||||
}
|
||||
}
|
||||
intPad = [[[useFormat substringWithRange: intPartRange]
|
||||
|
@ -1298,7 +1300,7 @@ static NSUInteger _defaultBehavior = NSNumberFormatterBehavior10_4;
|
|||
NSRange ipRange;
|
||||
|
||||
ipRange =
|
||||
NSMakeRange(0, [intPad length] - [intPartString length] + 1);
|
||||
NSMakeRange(0, [intPad length] - [intPartString length]);
|
||||
[intPartString insertString:
|
||||
[intPad substringWithRange: ipRange] atIndex: 0];
|
||||
[intPartString replaceOccurrencesOfString: @"_"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue