mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-25 01:31:08 +00:00
Only get default locale at the point when it's actually needed
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@39651 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
f306de43e8
commit
a577d2d316
1 changed files with 21 additions and 25 deletions
|
@ -84,6 +84,8 @@ static NSString* (*abrIMP)(id, SEL, id);
|
|||
static NSString* (*absAbrIMP)(id, SEL, id);
|
||||
static NSString* (*dstAbrIMP)(id, SEL, id);
|
||||
|
||||
#define LOCALE (nil == locale ? (locale = GSPrivateDefaultLocale()) : locale)
|
||||
|
||||
|
||||
/*
|
||||
* Return the offset from GMT for a date in a timezone ...
|
||||
|
@ -732,13 +734,9 @@ static inline int getDigits(const char *from, char *to, int limit, BOOL *error)
|
|||
}
|
||||
source = [description cString];
|
||||
sourceLen = strlen(source);
|
||||
if (locale == nil)
|
||||
{
|
||||
locale = GSPrivateDefaultLocale();
|
||||
}
|
||||
if (fmt == nil)
|
||||
{
|
||||
fmt = [locale objectForKey: NSTimeDateFormatString];
|
||||
fmt = [LOCALE objectForKey: NSTimeDateFormatString];
|
||||
if (fmt == nil)
|
||||
{
|
||||
fmt = @"";
|
||||
|
@ -781,7 +779,7 @@ static inline int getDigits(const char *from, char *to, int limit, BOOL *error)
|
|||
|
||||
if (c == 'c')
|
||||
{
|
||||
sub = [locale objectForKey: NSTimeDateFormatString];
|
||||
sub = [LOCALE objectForKey: NSTimeDateFormatString];
|
||||
if (sub == nil)
|
||||
{
|
||||
sub = @"%X %x";
|
||||
|
@ -805,7 +803,7 @@ static inline int getDigits(const char *from, char *to, int limit, BOOL *error)
|
|||
}
|
||||
else if (c == 'X')
|
||||
{
|
||||
sub = [locale objectForKey: NSTimeFormatString];
|
||||
sub = [LOCALE objectForKey: NSTimeFormatString];
|
||||
if (sub == nil)
|
||||
{
|
||||
sub = @"%H-%M-%S";
|
||||
|
@ -813,7 +811,7 @@ static inline int getDigits(const char *from, char *to, int limit, BOOL *error)
|
|||
}
|
||||
else if (c == 'x')
|
||||
{
|
||||
sub = [locale objectForKey: NSShortDateFormatString];
|
||||
sub = [LOCALE objectForKey: NSShortDateFormatString];
|
||||
if (sub == nil)
|
||||
{
|
||||
sub = @"%y-%m-%d";
|
||||
|
@ -955,7 +953,7 @@ static inline int getDigits(const char *from, char *to, int limit, BOOL *error)
|
|||
NSArray *dayNames;
|
||||
|
||||
currDay = [[NSString alloc] initWithCString: tmpStr];
|
||||
dayNames = [locale objectForKey: NSShortWeekDayNameArray];
|
||||
dayNames = [LOCALE objectForKey: NSShortWeekDayNameArray];
|
||||
for (tmpIdx = 0; tmpIdx < 7; tmpIdx++)
|
||||
{
|
||||
if ([[dayNames objectAtIndex: tmpIdx] isEqual:
|
||||
|
@ -1007,7 +1005,7 @@ static inline int getDigits(const char *from, char *to, int limit, BOOL *error)
|
|||
NSArray *dayNames;
|
||||
|
||||
currDay = [[NSString alloc] initWithCString: tmpStr];
|
||||
dayNames = [locale objectForKey: NSWeekDayNameArray];
|
||||
dayNames = [LOCALE objectForKey: NSWeekDayNameArray];
|
||||
for (tmpIdx = 0; tmpIdx < 7; tmpIdx++)
|
||||
{
|
||||
if ([[dayNames objectAtIndex: tmpIdx] isEqual:
|
||||
|
@ -1051,7 +1049,7 @@ static inline int getDigits(const char *from, char *to, int limit, BOOL *error)
|
|||
NSArray *monthNames;
|
||||
|
||||
currMonth = [[NSString alloc] initWithCString: tmpStr];
|
||||
monthNames = [locale objectForKey: NSShortMonthNameArray];
|
||||
monthNames = [LOCALE objectForKey: NSShortMonthNameArray];
|
||||
|
||||
for (tmpIdx = 0; tmpIdx < 12; tmpIdx++)
|
||||
{
|
||||
|
@ -1104,7 +1102,7 @@ static inline int getDigits(const char *from, char *to, int limit, BOOL *error)
|
|||
NSArray *monthNames;
|
||||
|
||||
currMonth = [[NSString alloc] initWithCString: tmpStr];
|
||||
monthNames = [locale objectForKey: NSMonthNameArray];
|
||||
monthNames = [LOCALE objectForKey: NSMonthNameArray];
|
||||
|
||||
for (tmpIdx = 0; tmpIdx < 12; tmpIdx++)
|
||||
{
|
||||
|
@ -1210,7 +1208,7 @@ static inline int getDigits(const char *from, char *to, int limit, BOOL *error)
|
|||
NSArray *amPMNames;
|
||||
|
||||
currAMPM = [NSString stringWithUTF8String: tmpStr];
|
||||
amPMNames = [locale objectForKey: NSAMPMDesignation];
|
||||
amPMNames = [LOCALE objectForKey: NSAMPMDesignation];
|
||||
|
||||
/*
|
||||
* The time addition is handled below because this
|
||||
|
@ -1994,24 +1992,24 @@ static void outputValueWithFormat(int v, char *fldfmt, DescriptionInfo *info)
|
|||
break;
|
||||
|
||||
case 'c':
|
||||
[self _format: [locale objectForKey: NSTimeFormatString]
|
||||
[self _format: [LOCALE objectForKey: NSTimeFormatString]
|
||||
locale: locale
|
||||
info: info];
|
||||
Grow(info, 1);
|
||||
info->t[info->offset++] = ' ';
|
||||
[self _format: [locale objectForKey: NSDateFormatString]
|
||||
[self _format: [LOCALE objectForKey: NSDateFormatString]
|
||||
locale: locale
|
||||
info: info];
|
||||
break;
|
||||
|
||||
case 'X':
|
||||
[self _format: [locale objectForKey: NSTimeFormatString]
|
||||
[self _format: [LOCALE objectForKey: NSTimeFormatString]
|
||||
locale: locale
|
||||
info: info];
|
||||
break;
|
||||
|
||||
case 'x':
|
||||
[self _format: [locale objectForKey: NSDateFormatString]
|
||||
[self _format: [LOCALE objectForKey: NSDateFormatString]
|
||||
locale: locale
|
||||
info: info];
|
||||
break;
|
||||
|
@ -2057,9 +2055,9 @@ static void outputValueWithFormat(int v, char *fldfmt, DescriptionInfo *info)
|
|||
NSArray *months;
|
||||
|
||||
if (mname)
|
||||
months = [locale objectForKey: NSShortMonthNameArray];
|
||||
months = [LOCALE objectForKey: NSShortMonthNameArray];
|
||||
else
|
||||
months = [locale objectForKey: NSMonthNameArray];
|
||||
months = [LOCALE objectForKey: NSMonthNameArray];
|
||||
if (info->md > [months count])
|
||||
{
|
||||
mtag = NO;
|
||||
|
@ -2153,9 +2151,9 @@ static void outputValueWithFormat(int v, char *fldfmt, DescriptionInfo *info)
|
|||
NSArray *days;
|
||||
|
||||
if (dname)
|
||||
days = [locale objectForKey: NSShortWeekDayNameArray];
|
||||
days = [LOCALE objectForKey: NSShortWeekDayNameArray];
|
||||
else
|
||||
days = [locale objectForKey: NSWeekDayNameArray];
|
||||
days = [LOCALE objectForKey: NSWeekDayNameArray];
|
||||
if (v < [days count])
|
||||
{
|
||||
NSString *name;
|
||||
|
@ -2258,7 +2256,7 @@ static void outputValueWithFormat(int v, char *fldfmt, DescriptionInfo *info)
|
|||
// Is it the am/pm indicator
|
||||
case 'p':
|
||||
{
|
||||
NSArray *a = [locale objectForKey: NSAMPMDesignation];
|
||||
NSArray *a = [LOCALE objectForKey: NSAMPMDesignation];
|
||||
NSString *ampm;
|
||||
|
||||
if (info->hd >= 12)
|
||||
|
@ -2440,10 +2438,8 @@ static void outputValueWithFormat(int v, char *fldfmt, DescriptionInfo *info)
|
|||
NSString *result;
|
||||
DescriptionInfo info;
|
||||
|
||||
if (locale == nil)
|
||||
locale = GSPrivateDefaultLocale();
|
||||
if (format == nil)
|
||||
format = [locale objectForKey: NSTimeDateFormatString];
|
||||
format = [LOCALE objectForKey: NSTimeDateFormatString];
|
||||
|
||||
GSBreakTime(_seconds_since_ref + offset(_time_zone, self),
|
||||
&info.yd, &info.md, &info.dom, &info.hd, &info.mnd, &info.sd, &info.mil);
|
||||
|
|
Loading…
Reference in a new issue