From b996c9bca5f2c742fb303007c62222ceefd65999 Mon Sep 17 00:00:00 2001 From: fedor Date: Thu, 5 Dec 2002 04:24:43 +0000 Subject: [PATCH] Update def of GSSetLocale git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@15249 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 9 +++++++++ Headers/gnustep/base/GSLocale.h | 3 ++- Source/GSLocale.m | 12 ++++++------ Source/NSObject.m | 9 +++++++-- Source/NSUserDefaults.m | 9 +++++++-- 5 files changed, 31 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9cb2d7d6d..4cdc5c991 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2002-12-04 Adam Fedor + + * Headers/gnustep/base/GSLocale.h: Add category arg to + SetLocale functions. + * Source/GSLocale.m (GSSetLocaleC, GSSetLocale): Update for change. + * Source/NSObject.m (+initialize): Idem. + * Source/NSUserDefaults.m ([NSUserDefaults +standardUserDefaults]): + Idem. + 2002-12-04 Richard Frith-Macdonald * Source/NSSerializer.m: bugfix deserialisation ... was trying to diff --git a/Headers/gnustep/base/GSLocale.h b/Headers/gnustep/base/GSLocale.h index e80699064..d7306458c 100644 --- a/Headers/gnustep/base/GSLocale.h +++ b/Headers/gnustep/base/GSLocale.h @@ -29,7 +29,8 @@ @class NSDictionary; -GS_EXPORT NSString *GSSetLocale(NSString *locale); +GS_EXPORT const char *GSSetLocaleC(int category, const char *loc); +GS_EXPORT NSString *GSSetLocale(int category, NSString *locale); GS_EXPORT NSDictionary *GSDomainFromDefaultLocale(void); diff --git a/Source/GSLocale.m b/Source/GSLocale.m index 0e2ceec1c..65a79057e 100644 --- a/Source/GSLocale.m +++ b/Source/GSLocale.m @@ -43,9 +43,9 @@ * make use of locale information. */ const char* -GSSetLocaleC(const char *loc) +GSSetLocaleC(int category, const char *loc) { - return setlocale(LC_CTYPE, loc); + return setlocale(category, loc); } /* Set the locale for libc functions from the supplied string or from @@ -55,7 +55,7 @@ GSSetLocaleC(const char *loc) whatever is specified by setlocale) Passing nil will just return the current locale. */ NSString * -GSSetLocale(NSString *locale) +GSSetLocale(int category, NSString *locale) { const char *clocale; @@ -64,7 +64,7 @@ GSSetLocale(NSString *locale) { clocale = [locale cString]; } - clocale = GSSetLocaleC(clocale); + clocale = GSSetLocaleC(category, clocale); if (clocale == NULL || strcmp(clocale, "C") == 0 || strcmp(clocale, "POSIX") == 0) @@ -184,7 +184,7 @@ GSDomainFromDefaultLocale(void) /* FIXME: Get currency format from localeconv */ - str1 = GSSetLocale(nil); + str1 = GSSetLocale(LC_MESSAGES, nil); if (str1 != nil) { [dict setObject: str1 forKey: NSLocale]; @@ -213,7 +213,7 @@ GSDomainFromDefaultLocale(void) #else /* HAVE_LOCALE_H */ NSString * -GSSetLocale(NSString *locale) +GSSetLocale(int category, NSString *locale) { return nil; } diff --git a/Source/NSObject.m b/Source/NSObject.m index ff2426325..504aaaf4e 100644 --- a/Source/NSObject.m +++ b/Source/NSObject.m @@ -44,6 +44,10 @@ #include #include #include +#include +#ifdef HAVE_LOCALE_H +#include +#endif #include "GSPrivate.h" @@ -770,7 +774,6 @@ static BOOL double_release_check_enabled = NO; if (self == [NSObject class]) { extern void GSBuildStrings(void); // See externs.m - extern const char* GSSetLocaleC(const char*); // See GSLocale.m #ifdef __MINGW__ // See libgnustep-base-entry.m @@ -791,7 +794,9 @@ static BOOL double_release_check_enabled = NO; } #endif - GSSetLocaleC(""); // Set up locale from environment. +#ifdef HAVE_LOCALE_H + GSSetLocaleC(LC_ALL, ""); // Set up locale from environment. +#endif // Create the global lock gnustep_global_lock = [NSRecursiveLock new]; diff --git a/Source/NSUserDefaults.m b/Source/NSUserDefaults.m index 35f6d876f..fb24ce1df 100644 --- a/Source/NSUserDefaults.m +++ b/Source/NSUserDefaults.m @@ -53,6 +53,9 @@ #include #include #include +#ifdef HAVE_LOCALE_H +#include +#endif #include "GSPrivate.h" @@ -432,7 +435,10 @@ static BOOL setSharedDefaults = NO; /* Flag to prevent infinite recursion */ } else if (added_locale == NO) { - NSString *locale = GSSetLocale(nil); + NSString *locale; +#ifdef HAVE_LOCALE_H + locale = GSSetLocale(LC_MESSAGES, nil); +#endif if (locale == nil) continue; /* See if we can get the dictionary from i18n functions. @@ -479,7 +485,6 @@ static BOOL setSharedDefaults = NO; /* Flag to prevent infinite recursion */ return AUTORELEASE(userLanguages); } userLanguages = RETAIN([NSMutableArray arrayWithCapacity: 5]); - locale = GSSetLocale(@""); if (sharedDefaults == nil) { /* Create our own defaults to get "NSLanguages" since sharedDefaults