mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 00:11:26 +00:00
Add currency code when creating locale identifiers. And fix a crash in NSDateFormatter due to double release.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@31956 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
807395c0a1
commit
3029c5982c
3 changed files with 18 additions and 5 deletions
|
@ -1,3 +1,9 @@
|
|||
2011-01-26 Stefan Bidigaray <stefanbidi@gmail.com>
|
||||
|
||||
* Source/NSLocale.m: Add currency code to locale identifier, if present.
|
||||
* Source/NSDateFormatter.m: Fix crash on dealloc because of autoreleased
|
||||
object.
|
||||
|
||||
2011-01-26 Stefan Bidigaray <stefanbidi@gmail.com>
|
||||
|
||||
* Source/NSLocale.m: Minor memory mgt fixes.
|
||||
|
|
|
@ -105,7 +105,7 @@ static NSDateFormatterBehavior _defaultBehavior = 0;
|
|||
udat_toPattern (_formatter, 0, value, length, &err);
|
||||
}
|
||||
|
||||
_dateFormat = [NSString stringWithCharacters: value length: length];
|
||||
_dateFormat = [[NSString alloc] initWithCharacters: value length: length];
|
||||
|
||||
if (length > BUFFER_SIZE)
|
||||
NSZoneFree ([self zone], value);
|
||||
|
|
|
@ -541,6 +541,7 @@ static NSRecursiveLock *classLock = nil;
|
|||
[[[dict objectForKey: NSLocaleCalendar] calendarIdentifier] UTF8String];
|
||||
const char *collation =
|
||||
[[dict objectForKey: NSLocaleCollationIdentifier] UTF8String];
|
||||
const char *currency = [[dict objectForKey: NSLocaleCurrencyCode] UTF8String];
|
||||
|
||||
// A locale cannot be constructed without a language.
|
||||
if (language == NULL)
|
||||
|
@ -552,16 +553,22 @@ static NSRecursiveLock *classLock = nil;
|
|||
|
||||
// I'm not using uloc_setKeywordValue() here because the format is easy
|
||||
// enough to reproduce and has the added advatange that we doesn't need ICU.
|
||||
if (calendar || calendar || currency)
|
||||
[string appendString: @"@"];
|
||||
if (calendar)
|
||||
[string appendFormat: @"@calendar=%s", calendar];
|
||||
[string appendFormat: @"calendar=%s", calendar];
|
||||
if (collation)
|
||||
{
|
||||
if (calendar)
|
||||
[string appendString: @";"];
|
||||
else
|
||||
[string appendString: @"@"];
|
||||
[string appendFormat: @"collation=%s", collation];
|
||||
}
|
||||
if (currency)
|
||||
{
|
||||
if (calendar || currency)
|
||||
[string appendString: @";"];
|
||||
[string appendFormat: @"currency=%s", currency];
|
||||
}
|
||||
|
||||
result = [NSString stringWithString: string];
|
||||
RELEASE(string);
|
||||
|
@ -858,7 +865,7 @@ static NSRecursiveLock *classLock = nil;
|
|||
else
|
||||
result = @"U.S.";
|
||||
}
|
||||
ulocdata_close (localeDate);
|
||||
ulocdata_close (localeData);
|
||||
return result;
|
||||
#else
|
||||
return nil;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue