Try to avoid problems on evil systems where the timezone file has wrong name.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@30530 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2010-06-01 19:30:28 +00:00
parent 2edf2f4bfb
commit b326d69195
2 changed files with 22 additions and 20 deletions

View file

@ -2,6 +2,8 @@
* Source/NSTimeZone.m: add diagnostic to report the source of the
timezone name when we can't create the local timezone.
Use tzset()/tzname in preference to the name of the default timezone
file ... in case of evil systems where the file has the wrong name.
2010-06-01 Richard Frith-Macdonald <rfm@gnu.org>

View file

@ -47,8 +47,8 @@
2) the GNUSTEP_TZ environment variable
3) the file LOCAL_TIME_FILE in _time_zone_path()
4) the TZ environment variable
5) TZDEFAULT defined in tzfile.h on platforms which have it
6) tzset() & tznam[] for platforms which have it
5) tzset() & tznam[] for platforms which have it
6) TZDEFAULT defined in tzfile.h on platforms which have it
7) Windows registry, for Win32 systems
8) or the fallback time zone (which is UTC)
with the ones listed first having precedence.
@ -886,8 +886,8 @@ static NSMapTable *absolutes = 0;
* 2) the GNUSTEP_TZ environment variable<br/ >
* 3) the file "localtime" in System/Library/Libraries/Resources/NSTimeZone<br/ >
* 4) the TZ environment variable<br/ >
* 5) The system zone settings (typically in /etc/localtime)<br/ >
* 6) tzset and tznam on platforms which have it<br/ >
* 5) tzset and tznam on platforms which have it<br/ >
* 6) The system zone settings (typically in /etc/localtime)<br/ >
* 7) Windows registry, on Win32 systems<br/ >
* 8) or the fallback time zone (which is UTC)<br/ >
* </p>
@ -1408,6 +1408,18 @@ static NSMapTable *absolutes = 0;
localZoneString = [[[NSProcessInfo processInfo]
environment] objectForKey: @"TZ"];
}
#if HAVE_TZSET
/*
* Try to get timezone from tzset and tzname
*/
if (localZoneString == nil)
{
localZoneSource = @"function: 'tzset()/tzname'";
tzset();
if (tzname[0] != NULL && *tzname[0] != '\0')
localZoneString = [NSString stringWithUTF8String: tzname[0]];
}
#endif
if (localZoneString == nil)
{
/* Get the zone name from the localtime file, assuming the file
@ -1416,8 +1428,8 @@ static NSMapTable *absolutes = 0;
#if defined(HAVE_TZHEAD) && defined(TZDEFAULT)
tzdir = RETAIN([NSString stringWithUTF8String: TZDIR]);
localZoneString = [NSString stringWithUTF8String: TZDEFAULT];
localZoneSource = [NSString stringWithFormat: @"file: '%@'",
localZoneString];
localZoneSource = [NSString stringWithFormat:
@"file (TZDEFAULT): '%@'", localZoneString];
localZoneString = [localZoneString stringByResolvingSymlinksInPath];
#else
NSFileManager *dflt = [NSFileManager defaultManager];
@ -1425,8 +1437,8 @@ static NSMapTable *absolutes = 0;
if ([dflt fileExistsAtPath: SYSTEM_TIME_FILE])
{
localZoneString = SYSTEM_TIME_FILE;
localZoneSource = [NSString stringWithFormat: @"file: '%@'",
localZoneString];
localZoneSource = [NSString stringWithFormat:
@"file (SYSTEM_TIME_FILE): '%@'", localZoneString];
localZoneString
= [localZoneString stringByResolvingSymlinksInPath];
/* Guess what tzdir is */
@ -1466,18 +1478,6 @@ static NSMapTable *absolutes = 0;
localZoneString = nil;
}
}
#if HAVE_TZSET
/*
* Try to get timezone from tzset and tzname
*/
if (localZoneString == nil)
{
localZoneSource = @"function: 'tzset()/tzname'";
tzset();
if (tzname[0] != NULL && *tzname[0] != '\0')
localZoneString = [NSString stringWithUTF8String: tzname[0]];
}
#endif
#if defined(__MINGW__)
/*