Fixup a few logic errors testing set flag bits. Moved a few bits of code

which only occasionally need to be executed ... minor performance tweak.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@19299 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
CaS 2004-05-13 09:38:03 +00:00
parent 306c074d6c
commit 80741506f0

View file

@ -611,9 +611,6 @@ static inline int getDigits(const char *from, char *to, int limit)
unsigned had = 0; unsigned had = 0;
unsigned int pos; unsigned int pos;
BOOL hadPercent = NO; BOOL hadPercent = NO;
NSString *dForm;
NSString *tForm;
NSString *TForm;
NSMutableData *fd; NSMutableData *fd;
BOOL changedFormat = NO; BOOL changedFormat = NO;
BOOL error = NO; BOOL error = NO;
@ -635,16 +632,6 @@ static inline int getDigits(const char *from, char *to, int limit)
description = @""; description = @"";
} }
TForm = [locale objectForKey: NSTimeDateFormatString];
if (TForm == nil)
TForm = @"%X %x";
dForm = [locale objectForKey: NSShortDateFormatString];
if (dForm == nil)
dForm = @"%y-%m-%d";
tForm = [locale objectForKey: NSTimeFormatString];
if (tForm == nil)
tForm = @"%H-%M-%S";
/* /*
* Get format into a buffer, leaving room for expansion in case it has * Get format into a buffer, leaving room for expansion in case it has
* escapes that need to be converted. * escapes that need to be converted.
@ -681,7 +668,11 @@ static inline int getDigits(const char *from, char *to, int limit)
if (c == 'c') if (c == 'c')
{ {
sub = TForm; sub = [locale objectForKey: NSTimeDateFormatString];
if (sub == nil)
{
sub = @"%X %x";
}
} }
else if (c == 'R') else if (c == 'R')
{ {
@ -693,11 +684,19 @@ static inline int getDigits(const char *from, char *to, int limit)
} }
else if (c == 'X') else if (c == 'X')
{ {
sub = tForm; sub = [locale objectForKey: NSTimeFormatString];
if (sub == nil)
{
sub = @"%H-%M-%S";
}
} }
else if (c == 'x') else if (c == 'x')
{ {
sub = dForm; sub = [locale objectForKey: NSShortDateFormatString];
if (sub == nil)
{
sub = @"%y-%m-%d";
}
} }
if (sub != nil) if (sub != nil)
@ -1183,12 +1182,12 @@ static inline int getDigits(const char *from, char *to, int limit)
NSCalendarDate *now = [[NSCalendarDate alloc] init]; NSCalendarDate *now = [[NSCalendarDate alloc] init];
[now setTimeZone: gmtZone]; [now setTimeZone: gmtZone];
if ((had | hadY) == 0) if ((had & hadY) == 0)
{ {
year = [now yearOfCommonEra]; year = [now yearOfCommonEra];
had |= hadY; had |= hadY;
} }
if ((had | hadw) == 0) if ((had & hadw) == 0)
{ {
dayOfWeek = [now dayOfWeek]; dayOfWeek = [now dayOfWeek];
had |= hadw; had |= hadw;
@ -1230,7 +1229,7 @@ static inline int getDigits(const char *from, char *to, int limit)
/* /*
* If the year has not been set ... use this year ... as on MacOS-X * If the year has not been set ... use this year ... as on MacOS-X
*/ */
if ((had | hadY) == 0) if ((had & hadY) == 0)
{ {
NSCalendarDate *now = [[NSCalendarDate alloc] init]; NSCalendarDate *now = [[NSCalendarDate alloc] init];