mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 00:30:53 +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>
|
2011-01-26 Stefan Bidigaray <stefanbidi@gmail.com>
|
||||||
|
|
||||||
* Source/NSLocale.m: Minor memory mgt fixes.
|
* Source/NSLocale.m: Minor memory mgt fixes.
|
||||||
|
|
|
@ -105,7 +105,7 @@ static NSDateFormatterBehavior _defaultBehavior = 0;
|
||||||
udat_toPattern (_formatter, 0, value, length, &err);
|
udat_toPattern (_formatter, 0, value, length, &err);
|
||||||
}
|
}
|
||||||
|
|
||||||
_dateFormat = [NSString stringWithCharacters: value length: length];
|
_dateFormat = [[NSString alloc] initWithCharacters: value length: length];
|
||||||
|
|
||||||
if (length > BUFFER_SIZE)
|
if (length > BUFFER_SIZE)
|
||||||
NSZoneFree ([self zone], value);
|
NSZoneFree ([self zone], value);
|
||||||
|
|
|
@ -541,6 +541,7 @@ static NSRecursiveLock *classLock = nil;
|
||||||
[[[dict objectForKey: NSLocaleCalendar] calendarIdentifier] UTF8String];
|
[[[dict objectForKey: NSLocaleCalendar] calendarIdentifier] UTF8String];
|
||||||
const char *collation =
|
const char *collation =
|
||||||
[[dict objectForKey: NSLocaleCollationIdentifier] UTF8String];
|
[[dict objectForKey: NSLocaleCollationIdentifier] UTF8String];
|
||||||
|
const char *currency = [[dict objectForKey: NSLocaleCurrencyCode] UTF8String];
|
||||||
|
|
||||||
// A locale cannot be constructed without a language.
|
// A locale cannot be constructed without a language.
|
||||||
if (language == NULL)
|
if (language == NULL)
|
||||||
|
@ -552,16 +553,22 @@ static NSRecursiveLock *classLock = nil;
|
||||||
|
|
||||||
// I'm not using uloc_setKeywordValue() here because the format is easy
|
// 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.
|
// enough to reproduce and has the added advatange that we doesn't need ICU.
|
||||||
|
if (calendar || calendar || currency)
|
||||||
|
[string appendString: @"@"];
|
||||||
if (calendar)
|
if (calendar)
|
||||||
[string appendFormat: @"@calendar=%s", calendar];
|
[string appendFormat: @"calendar=%s", calendar];
|
||||||
if (collation)
|
if (collation)
|
||||||
{
|
{
|
||||||
if (calendar)
|
if (calendar)
|
||||||
[string appendString: @";"];
|
[string appendString: @";"];
|
||||||
else
|
|
||||||
[string appendString: @"@"];
|
|
||||||
[string appendFormat: @"collation=%s", collation];
|
[string appendFormat: @"collation=%s", collation];
|
||||||
}
|
}
|
||||||
|
if (currency)
|
||||||
|
{
|
||||||
|
if (calendar || currency)
|
||||||
|
[string appendString: @";"];
|
||||||
|
[string appendFormat: @"currency=%s", currency];
|
||||||
|
}
|
||||||
|
|
||||||
result = [NSString stringWithString: string];
|
result = [NSString stringWithString: string];
|
||||||
RELEASE(string);
|
RELEASE(string);
|
||||||
|
@ -858,7 +865,7 @@ static NSRecursiveLock *classLock = nil;
|
||||||
else
|
else
|
||||||
result = @"U.S.";
|
result = @"U.S.";
|
||||||
}
|
}
|
||||||
ulocdata_close (localeDate);
|
ulocdata_close (localeData);
|
||||||
return result;
|
return result;
|
||||||
#else
|
#else
|
||||||
return nil;
|
return nil;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue