Locale fix

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@15255 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-Macdonald 2002-12-05 10:16:46 +00:00
parent 52bf284361
commit d4d32c775f
2 changed files with 24 additions and 8 deletions

View file

@ -1,3 +1,9 @@
2002-12-05 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSUserDefaults.m: Fix uninitialised local variable 'locale'
which was causing a crash ... not 100% sure my fix is making the code
work as intended. Could Adam please check it?
2002-12-04 Adam Fedor <fedor@gnu.org>
* Headers/gnustep/base/GSLocale.h: Add category arg to

View file

@ -435,22 +435,29 @@ static BOOL setSharedDefaults = NO; /* Flag to prevent infinite recursion */
}
else if (added_locale == NO)
{
NSString *locale;
NSString *locale = nil;
#ifdef HAVE_LOCALE_H
locale = GSSetLocale(LC_MESSAGES, nil);
#endif
if (locale == nil)
continue;
{
continue;
}
/* See if we can get the dictionary from i18n functions.
Note that we get the dict from the current locale regardless
of what 'lang' is, since it should match anyway. */
/* Also, I don't think that the i18n routines can handle more than
one locale, but tell me if I'm wrong... */
if (GSLanguageFromLocale(locale))
lang = GSLanguageFromLocale(locale);
{
lang = GSLanguageFromLocale(locale);
}
dict = GSDomainFromDefaultLocale();
if (dict)
[sharedDefaults setVolatileDomain: dict forName: lang];
if (dict != nil)
{
[sharedDefaults setVolatileDomain: dict forName: lang];
}
added_locale = YES;
}
}
@ -475,8 +482,11 @@ static BOOL setSharedDefaults = NO; /* Flag to prevent infinite recursion */
+ (NSArray*) userLanguages
{
NSArray *currLang = nil;
NSString *locale;
NSString *locale = nil;
#ifdef HAVE_LOCALE_H
locale = GSSetLocale(LC_MESSAGES, nil);
#endif
[classLock lock];
if (userLanguages != nil)
{
@ -516,12 +526,12 @@ static BOOL setSharedDefaults = NO; /* Flag to prevent infinite recursion */
currLang
= [[self standardUserDefaults] stringArrayForKey: @"NSLanguages"];
}
if (currLang == nil && locale != 0 && GSLanguageFromLocale(locale))
if (currLang == nil && locale != nil && GSLanguageFromLocale(locale))
{
currLang = [NSArray arrayWithObject: GSLanguageFromLocale(locale)];
}
#ifdef __MINGW__
if (currLang == nil && locale != 0)
if (currLang == nil && locale != nil)
{
/* Check for language as the first part of the locale string */
NSRange under = [locale rangeOfString: @"_"];