From: Michael Ow Date: Wed, 6 Feb 2013 23:39:05 +0000 (+0000) Subject: ICU-9912 Fix default timezone detection on Solaris X-Git-Tag: milestone-59-0-1~3169 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=07f5400f59f48de6fd5683071193fc4f6b66a6e3;p=icu ICU-9912 Fix default timezone detection on Solaris X-SVN-Rev: 33133 --- diff --git a/icu4c/source/common/putil.cpp b/icu4c/source/common/putil.cpp index 4694aa9a806..e700bffac78 100644 --- a/icu4c/source/common/putil.cpp +++ b/icu4c/source/common/putil.cpp @@ -1,7 +1,7 @@ /* ****************************************************************************** * -* Copyright (C) 1997-2012, International Business Machines +* Copyright (C) 1997-2013, International Business Machines * Corporation and others. All Rights Reserved. * ****************************************************************************** @@ -97,7 +97,7 @@ # define ICU_NO_USER_DATA_OVERRIDE 1 #elif U_PLATFORM == U_PF_OS390 # include "unicode/ucnv.h" /* Needed for UCNV_SWAP_LFNL_OPTION_STRING */ -#elif U_PLATFORM_IS_DARWIN_BASED || U_PLATFORM_IS_LINUX_BASED || U_PLATFORM == U_PF_BSD +#elif U_PLATFORM_IS_DARWIN_BASED || U_PLATFORM_IS_LINUX_BASED || U_PLATFORM == U_PF_BSD || U_PLATFORM == U_PF_SOLARIS # include # include #elif U_PLATFORM == U_PF_QNX @@ -671,12 +671,16 @@ uprv_timezone() extern U_IMPORT char *U_TZNAME[]; #endif -#if !UCONFIG_NO_FILE_IO && (U_PLATFORM_IS_DARWIN_BASED || U_PLATFORM_IS_LINUX_BASED || U_PLATFORM == U_PF_BSD) +#if !UCONFIG_NO_FILE_IO && (U_PLATFORM_IS_DARWIN_BASED || U_PLATFORM_IS_LINUX_BASED || U_PLATFORM == U_PF_BSD || U_PLATFORM == U_PF_SOLARIS) /* These platforms are likely to use Olson timezone IDs. */ #define CHECK_LOCALTIME_LINK 1 #if U_PLATFORM_IS_DARWIN_BASED #include #define TZZONEINFO (TZDIR "/") +#elif U_PLATFORM == U_PF_SOLARIS +#define TZDEFAULT "/etc/localtime" +#define TZZONEINFO "/usr/share/lib/zoneinfo/" +#define TZ_ENV_CHECK "localtime" #else #define TZDEFAULT "/etc/localtime" #define TZZONEINFO "/usr/share/zoneinfo/" @@ -1006,8 +1010,12 @@ uprv_tzname(int n) /* This code can be temporarily disabled to test tzname resolution later on. */ #ifndef DEBUG_TZNAME tzid = getenv("TZ"); - if (tzid != NULL && isValidOlsonID(tzid)) - { + if (tzid != NULL && isValidOlsonID(tzid) +#if U_PLATFORM == U_PF_SOLARIS + /* When TZ equals localtime on Solaris, check the /etc/localtime file. */ + && uprv_strcmp(tzid, TZ_ENV_CHECK) != 0 +#endif + ) { /* This might be a good Olson ID. */ skipZoneIDPrefix(&tzid); return tzid;