Initialise locale early

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@9665 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-Macdonald 2001-04-23 08:55:58 +00:00
parent 403be4b258
commit 87c9d2e2e5
3 changed files with 25 additions and 3 deletions

View file

@ -1,3 +1,10 @@
2001-04-23 Richard Frith-Macdonald <rfm@gnu.org>
* Source/GSLocale.m: Only call setlocale() in GSSetLocaleC()
* Source/NSObject.m: ([+initialize]) call GSSetLocaleC() after other
initialisation, to try to ensure that locale stuff is set up early
before any attempt is made to use locale dependent code.
2001-04-22 Nicola Pero <n.pero@mi.flashnet.it>
* Testing/benchmark.m: Modified messages to give a better idea of

View file

@ -35,6 +35,18 @@
#include <Foundation/NSUserDefaults.h>
#include <Foundation/NSBundle.h>
/*
* Function called by [NSObject +initialize] to setup locale information
* from environment variables. Must *not* use any ObjC code since it needs
* to run before any ObjC classes are fully initialised so that they can
* make use of locale information.
*/
const char*
GSSetLocaleC(const char *loc)
{
return setlocale(LC_ALL, loc);
}
/* Set the locale for libc functions from the supplied string or from
the environment if not specified. This function should be called
as soon as possible after the start of the program. Passing
@ -51,7 +63,7 @@ GSSetLocale(NSString *locale)
{
clocale = [locale cString];
}
clocale = setlocale(LC_ALL, clocale);
clocale = GSSetLocaleC(clocale);
if (clocale == NULL || strcmp(clocale, "C") == 0
|| strcmp(clocale, "POSIX") == 0)
@ -154,7 +166,7 @@ GSDomainFromDefaultLocale(void)
}
/* FIXME: Get currency format from localeconv */
str1 = [NSString stringWithCString: setlocale(LC_ALL, NULL)];
str1 = GSSetLocale(nil);
[dict setObject: str1 forKey: NSLocale];
str2 = GSLanguageFromLocale(str1);
if (str2)

View file

@ -570,7 +570,10 @@ static BOOL double_release_check_enabled = NO;
{
if (self == [NSObject class])
{
extern void GSBuildStrings(); // See externs.m
extern void GSBuildStrings(); // See externs.m
extern const char* GSSetLocaleC(); // See GSLocale.m
GSSetLocaleC(""); // Set up locale from environment.
#ifdef __MINGW__
// See libgnustep-base-entry.m