mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 00:30:53 +00:00
Fix for issue 459
This commit is contained in:
parent
7cc1c72ac6
commit
f180575e37
1 changed files with 28 additions and 26 deletions
|
@ -609,7 +609,8 @@ _GSICUCollatorCreate(NSStringCompareOptions mask, const char *localeCString)
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) dealloc {
|
- (void) dealloc
|
||||||
|
{
|
||||||
RELEASE(locale);
|
RELEASE(locale);
|
||||||
if (collator != NULL)
|
if (collator != NULL)
|
||||||
{
|
{
|
||||||
|
@ -630,33 +631,37 @@ _GSICUCollatorCreate(NSStringCompareOptions mask, const char *localeCString)
|
||||||
static UCollator *
|
static UCollator *
|
||||||
GSICUCachedCollator(NSStringCompareOptions mask, NSLocale *locale)
|
GSICUCachedCollator(NSStringCompareOptions mask, NSLocale *locale)
|
||||||
{
|
{
|
||||||
NSThread *current;
|
NSThread *current;
|
||||||
GSICUCollatorCache *cache;
|
GSICUCollatorCache *cache;
|
||||||
|
|
||||||
current = [NSThread currentThread];
|
current = [NSThread currentThread];
|
||||||
cache = [current _stringCollatorCache];
|
cache = [current _stringCollatorCache];
|
||||||
if (nil == cache) {
|
if (nil == cache)
|
||||||
cache = [[GSICUCollatorCache alloc] initWithMask: mask locale: locale];
|
|
||||||
[current _setStringCollatorCache: cache];
|
|
||||||
[cache release];
|
|
||||||
return cache->collator;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Do a pointer comparison first to avoid the overhead of isEqual:
|
|
||||||
// The locale instance is likely a global constant object.
|
|
||||||
// If this fails, do a full comparison.
|
|
||||||
if ((cache->locale == locale || [cache->locale isEqual: locale]) && mask == cache->mask)
|
|
||||||
{
|
{
|
||||||
return cache->collator;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
cache = [[GSICUCollatorCache alloc] initWithMask: mask locale: locale];
|
cache = [[GSICUCollatorCache alloc] initWithMask: mask locale: locale];
|
||||||
[current _setStringCollatorCache: cache];
|
[current _setStringCollatorCache: cache];
|
||||||
[cache release];
|
[cache release];
|
||||||
return cache->collator;
|
return cache->collator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Do a pointer comparison first to avoid the overhead of isEqual:
|
||||||
|
* The locale instance is likely a global constant object.
|
||||||
|
* If this fails, do a full comparison.
|
||||||
|
*/
|
||||||
|
if ((cache->locale == locale || [cache->locale isEqual: locale])
|
||||||
|
&& mask == cache->mask)
|
||||||
|
{
|
||||||
|
return cache->collator;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cache = [[GSICUCollatorCache alloc] initWithMask: mask locale: locale];
|
||||||
|
[current _setStringCollatorCache: cache];
|
||||||
|
[cache release];
|
||||||
|
return cache->collator;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
#endif // GS_USE_ICU
|
||||||
|
|
||||||
|
|
||||||
@implementation NSString
|
@implementation NSString
|
||||||
|
@ -772,7 +777,7 @@ register_printf_atsign ()
|
||||||
0))
|
0))
|
||||||
#else
|
#else
|
||||||
arginfo_func))
|
arginfo_func))
|
||||||
#endif
|
#endif // PRINTF_ATSIGN_VA_LIST
|
||||||
[NSException raise: NSGenericException
|
[NSException raise: NSGenericException
|
||||||
format: @"register printf handling of %%@ failed"];
|
format: @"register printf handling of %%@ failed"];
|
||||||
#elif defined(HAVE_REGISTER_PRINTF_FUNCTION)
|
#elif defined(HAVE_REGISTER_PRINTF_FUNCTION)
|
||||||
|
@ -781,10 +786,10 @@ register_printf_atsign ()
|
||||||
0))
|
0))
|
||||||
#else
|
#else
|
||||||
arginfo_func))
|
arginfo_func))
|
||||||
#endif
|
#endif // PRINTF_ATSIGN_VA_LIST
|
||||||
[NSException raise: NSGenericException
|
[NSException raise: NSGenericException
|
||||||
format: @"register printf handling of %%@ failed"];
|
format: @"register printf handling of %%@ failed"];
|
||||||
#endif
|
#endif // defined(HAVE_REGISTER_PRINTF_FUNCTION)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -872,7 +877,6 @@ register_printf_atsign ()
|
||||||
return AUTORELEASE(newString);
|
return AUTORELEASE(newString);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
|
|
||||||
+ (void) atExit
|
+ (void) atExit
|
||||||
{
|
{
|
||||||
|
@ -6393,14 +6397,12 @@ static NSFileManager *fm = nil;
|
||||||
uint8_t substringType;
|
uint8_t substringType;
|
||||||
BOOL isReverse;
|
BOOL isReverse;
|
||||||
BOOL substringNotRequired;
|
BOOL substringNotRequired;
|
||||||
BOOL localized;
|
|
||||||
NSUInteger currentLocation;
|
NSUInteger currentLocation;
|
||||||
BOOL stop = NO;
|
BOOL stop = NO;
|
||||||
|
|
||||||
substringType = opts & 0xFF;
|
substringType = opts & 0xFF;
|
||||||
isReverse = opts & NSStringEnumerationReverse;
|
isReverse = opts & NSStringEnumerationReverse;
|
||||||
substringNotRequired = opts & NSStringEnumerationSubstringNotRequired;
|
substringNotRequired = opts & NSStringEnumerationSubstringNotRequired;
|
||||||
localized = opts & NSStringEnumerationLocalized;
|
|
||||||
|
|
||||||
if (isReverse)
|
if (isReverse)
|
||||||
{
|
{
|
||||||
|
@ -6511,7 +6513,7 @@ static NSFileManager *fm = nil;
|
||||||
/* @ss=standard will use lists of common abbreviations,
|
/* @ss=standard will use lists of common abbreviations,
|
||||||
* such as Mr., Mrs., etc.
|
* such as Mr., Mrs., etc.
|
||||||
*/
|
*/
|
||||||
locale = localized
|
locale = (opts & NSStringEnumerationLocalized)
|
||||||
? [[[[NSLocale currentLocale] localeIdentifier]
|
? [[[[NSLocale currentLocale] localeIdentifier]
|
||||||
stringByAppendingString: @"@ss=standard"] UTF8String]
|
stringByAppendingString: @"@ss=standard"] UTF8String]
|
||||||
: "en_US_POSIX";
|
: "en_US_POSIX";
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue