Make NSLocale use information about libicu availablity (perviously, it would

never build the ICU stuff because the corresponding macro wasn't defined).



git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@30995 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Niels Grewe 2010-07-19 07:54:52 +00:00
parent b666cd6884
commit 4848c265e9
4 changed files with 68 additions and 57 deletions

View file

@ -1,3 +1,12 @@
2010-07-19 Niels Grewe <niels.grewe@halbordnung.de>
* Headers/Additions/GNUstepBase/GSConfig.h: Define GS_USE_ICU when
the configure script indicates libicu availablity.
* Headers/Foundation/Foundation.h: Import NSLocale.h
* Source/NSLocale.m: Change tests to use GS_USE_ICU.
Make sure that the parts of NSLocale relying on ICU actually get built
when libicu is available.
2010-07-17 Quentin Mathe <quentin.mathe@gmail.com> 2010-07-17 Quentin Mathe <quentin.mathe@gmail.com>
* Tools/autogsdoc.m: * Tools/autogsdoc.m:

View file

@ -223,6 +223,7 @@ typedef struct {
#define GS_MIXEDABI @GS_MIXEDABI@ #define GS_MIXEDABI @GS_MIXEDABI@
#define GS_USE_AVAHI @HAVE_AVAHI@ #define GS_USE_AVAHI @HAVE_AVAHI@
#define GS_USE_MDNS @HAVE_MDNS@ #define GS_USE_MDNS @HAVE_MDNS@
#define GS_USE_ICU @HAVE_ICU@
#import <GNUstepBase/preface.h> #import <GNUstepBase/preface.h>
#endif /* included_GSConfig_h */ #endif /* included_GSConfig_h */

View file

@ -78,6 +78,7 @@
#import <Foundation/NSKeyedArchiver.h> #import <Foundation/NSKeyedArchiver.h>
#import <Foundation/NSKeyValueCoding.h> #import <Foundation/NSKeyValueCoding.h>
#import <Foundation/NSKeyValueObserving.h> #import <Foundation/NSKeyValueObserving.h>
#import <Foundation/NSLocale.h>
#import <Foundation/NSLock.h> #import <Foundation/NSLock.h>
#import <Foundation/NSMapTable.h> #import <Foundation/NSMapTable.h>
#import <Foundation/NSMethodSignature.h> #import <Foundation/NSMethodSignature.h>

View file

@ -126,7 +126,7 @@ static NSArray *_currencyCodesWithType (uint32_t currType)
NSMutableArray *currencies = [[NSMutableArray alloc] initWithCapacity: 10]; NSMutableArray *currencies = [[NSMutableArray alloc] initWithCapacity: 10];
UErrorCode error = U_ZERO_ERROR; UErrorCode error = U_ZERO_ERROR;
UErrorCode status = U_ZERO_ERROR; UErrorCode status = U_ZERO_ERROR;
char *currCode; const char *currCode;
UEnumeration *codes = ucurr_openISOCurrencies (currType, &error); UEnumeration *codes = ucurr_openISOCurrencies (currType, &error);
if (U_FAILURE(error)) if (U_FAILURE(error))
return nil; return nil;
@ -180,7 +180,7 @@ static NSArray *_currencyCodesWithType (uint32_t currType)
{ {
static NSArray *available = nil; static NSArray *available = nil;
#if HAVE_ICU #if GS_USE_ICU == 1
if (nil == available) if (nil == available)
{ {
[classLock lock]; [classLock lock];
@ -222,7 +222,7 @@ static NSArray *_currencyCodesWithType (uint32_t currType)
+ (NSLocaleLanguageDirection) characterDirectionForLanguage: + (NSLocaleLanguageDirection) characterDirectionForLanguage:
(NSString *)isoLangCode (NSString *)isoLangCode
{ {
#if HAVE_ICU #if GS_USE_ICU == 1
ULayoutType result; ULayoutType result;
UErrorCode status = U_ZERO_ERROR; UErrorCode status = U_ZERO_ERROR;
@ -238,7 +238,7 @@ static NSArray *_currencyCodesWithType (uint32_t currType)
+ (NSDictionary *) componentsFromLocaleIdentifier: (NSString *) string + (NSDictionary *) componentsFromLocaleIdentifier: (NSString *) string
{ {
#if HAVE_ICU #if GS_USE_ICU == 1
char buffer[ULOC_LANG_CAPACITY]; char buffer[ULOC_LANG_CAPACITY];
int32_t strLength; int32_t strLength;
UErrorCode error = U_ZERO_ERROR; UErrorCode error = U_ZERO_ERROR;
@ -297,7 +297,7 @@ static NSArray *_currencyCodesWithType (uint32_t currType)
[classLock lock]; [classLock lock];
if (nil == currentLocale) if (nil == currentLocale)
{ {
#if HAVE_ICU #if GS_USE_ICU == 1
const char *cLocaleId = uloc_getDefault (); const char *cLocaleId = uloc_getDefault ();
NSString *localeId = [NSString stringWithCString: cLocaleId]; NSString *localeId = [NSString stringWithCString: cLocaleId];
currentLocale = [[NSLocale alloc] initWithLocaleIdentifier: localeId]; currentLocale = [[NSLocale alloc] initWithLocaleIdentifier: localeId];
@ -310,7 +310,7 @@ static NSArray *_currencyCodesWithType (uint32_t currType)
+ (NSArray *) commonISOCurrencyCodes + (NSArray *) commonISOCurrencyCodes
{ {
#if HAVE_ICU #if GS_USE_ICU == 1
return _currencyCodesWithType (UCURR_COMMON | UCURR_NON_DEPRECATED); return _currencyCodesWithType (UCURR_COMMON | UCURR_NON_DEPRECATED);
#else #else
return nil; // FIXME return nil; // FIXME
@ -319,7 +319,7 @@ static NSArray *_currencyCodesWithType (uint32_t currType)
+ (NSArray *) ISOCurrencyCodes + (NSArray *) ISOCurrencyCodes
{ {
#if HAVE_ICU #if GS_USE_ICU == 1
return _currencyCodesWithType (UCURR_ALL); return _currencyCodesWithType (UCURR_ALL);
#else #else
return nil; // FIXME return nil; // FIXME
@ -335,7 +335,7 @@ static NSArray *_currencyCodesWithType (uint32_t currType)
[classLock lock]; [classLock lock];
if (nil == countries) if (nil == countries)
{ {
#if HAVE_ICU #if GS_USE_ICU == 1
NSMutableArray *array = [[NSMutableArray alloc] initWithCapacity: 10]; NSMutableArray *array = [[NSMutableArray alloc] initWithCapacity: 10];
const char *const *codes = uloc_getISOCountries (); const char *const *codes = uloc_getISOCountries ();
@ -361,7 +361,7 @@ static NSArray *_currencyCodesWithType (uint32_t currType)
[classLock lock]; [classLock lock];
if (nil == languages) if (nil == languages)
{ {
#if HAVE_ICU #if GS_USE_ICU == 1
NSMutableArray *array = [[NSMutableArray alloc] initWithCapacity: 10]; NSMutableArray *array = [[NSMutableArray alloc] initWithCapacity: 10];
const char *const *codes = uloc_getISOCountries (); const char *const *codes = uloc_getISOCountries ();
@ -380,7 +380,7 @@ static NSArray *_currencyCodesWithType (uint32_t currType)
+ (NSLocaleLanguageDirection) lineDirectionForLanguage: (NSString *) isoLangCode + (NSLocaleLanguageDirection) lineDirectionForLanguage: (NSString *) isoLangCode
{ {
#if HAVE_ICU #if GS_USE_ICU == 1
ULayoutType result; ULayoutType result;
UErrorCode status = U_ZERO_ERROR; UErrorCode status = U_ZERO_ERROR;
@ -417,7 +417,7 @@ static NSArray *_currencyCodesWithType (uint32_t currType)
+ (NSString *) localeIdentifierFromComponents: (NSDictionary *) dict + (NSString *) localeIdentifierFromComponents: (NSDictionary *) dict
{ {
#if HAVE_ICU #if GS_USE_ICU == 1
char buffer[ULOC_FULLNAME_CAPACITY]; char buffer[ULOC_FULLNAME_CAPACITY];
UErrorCode status = U_ZERO_ERROR; UErrorCode status = U_ZERO_ERROR;
const char *language = [[dict objectForKey: NSLocaleLanguageCode] cString]; const char *language = [[dict objectForKey: NSLocaleLanguageCode] cString];
@ -452,7 +452,7 @@ static NSArray *_currencyCodesWithType (uint32_t currType)
+ (NSString *) localeIdentifierFromWindowsLocaleCode: (uint32_t) lcid + (NSString *) localeIdentifierFromWindowsLocaleCode: (uint32_t) lcid
{ {
#if HAVE_ICU #if GS_USE_ICU == 1
char buffer[ULOC_FULLNAME_CAPACITY]; char buffer[ULOC_FULLNAME_CAPACITY];
UErrorCode status = U_ZERO_ERROR; UErrorCode status = U_ZERO_ERROR;
@ -469,7 +469,7 @@ static NSArray *_currencyCodesWithType (uint32_t currType)
+ (uint32_t) windowsLocaleCodeFromLocaleIdentifier: (NSString *)localeIdentifier + (uint32_t) windowsLocaleCodeFromLocaleIdentifier: (NSString *)localeIdentifier
{ {
#if HAVE_ICU #if GS_USE_ICU == 1
return uloc_getLCID ([localeIdentifier cString]); return uloc_getLCID ([localeIdentifier cString]);
#else #else
return 0; // FIXME return 0; // FIXME
@ -478,7 +478,7 @@ static NSArray *_currencyCodesWithType (uint32_t currType)
- (NSString *) displayNameForKey: (id) key value: (id) value - (NSString *) displayNameForKey: (id) key value: (id) value
{ {
#if HAVE_ICU #if GS_USE_ICU == 1
int32_t length; int32_t length;
unichar buffer[ULOC_FULLNAME_CAPACITY]; unichar buffer[ULOC_FULLNAME_CAPACITY];
UErrorCode status; UErrorCode status;
@ -500,7 +500,7 @@ static NSArray *_currencyCodesWithType (uint32_t currType)
{ {
NSLocale *newLocale; NSLocale *newLocale;
NSString *localeId; NSString *localeId;
#if HAVE_ICU #if GS_USE_ICU == 1
int32_t length; int32_t length;
char cLocaleId[ULOC_FULLNAME_CAPACITY]; char cLocaleId[ULOC_FULLNAME_CAPACITY];
UErrorCode error = U_ZERO_ERROR; UErrorCode error = U_ZERO_ERROR;