ICU-953 Don't do static initialization, except for GMT.

X-SVN-Rev: 5028
This commit is contained in:
George Rhoten 2001-06-20 21:11:13 +00:00
parent d938ddf1ca
commit 3aa133d5b7
2 changed files with 24 additions and 13 deletions

View File

@ -43,22 +43,19 @@
#include "tzdat.h" #include "tzdat.h"
#include "cstring.h" #include "cstring.h"
#ifdef _DEBUG
#include "unistrm.h"
#endif
// static initialization // static initialization
char TimeZone::fgClassID = 0; // Value is irrelevant char TimeZone::fgClassID = 0; // Value is irrelevant
TimeZone* TimeZone::fgDefaultZone = NULL; TimeZone* TimeZone::fgDefaultZone = NULL;
static const UnicodeString _internalTimeZoneGMT_ID = UNICODE_STRING("GMT", 3); const UChar TimeZone::GMT_ID[] = {0x47, 0x4D, 0x54, 0x00}; /* "GMT" */
const UnicodeString TimeZone::GMT_ID = ::_internalTimeZoneGMT_ID;
const int32_t TimeZone::GMT_ID_LENGTH = 3; const int32_t TimeZone::GMT_ID_LENGTH = 3;
const UnicodeString TimeZone::CUSTOM_ID = UNICODE_STRING("Custom", 6); const UChar TimeZone::CUSTOM_ID[] =
{
0x43, 0x75, 0x73, 0x74, 0x6F, 0x6D, 0x00 /* "Custom" */
};
static const SimpleTimeZone _internalTimeZoneGMT(0, ::_internalTimeZoneGMT_ID); const TimeZone* TimeZone::GMT = getGMT();
const TimeZone* TimeZone::GMT = &::_internalTimeZoneGMT;
// See header file for documentation of the following // See header file for documentation of the following
const TZHeader * TimeZone::DATA = 0; const TZHeader * TimeZone::DATA = 0;
@ -70,6 +67,15 @@ UBool TimeZone::DATA_LOADED = FALSE;
UDataMemory* TimeZone::UDATA_POINTER = 0; UDataMemory* TimeZone::UDATA_POINTER = 0;
UMTX TimeZone::LOCK; UMTX TimeZone::LOCK;
// -------------------------------------
const TimeZone*
TimeZone::getGMT(void)
{
static const SimpleTimeZone SIMPLE_GMT(0, GMT_ID);
return &SIMPLE_GMT;
}
/** /**
* Attempt to load the system zone data from icudata.dll (or its * Attempt to load the system zone data from icudata.dll (or its
* equivalent). After this call returns DATA_LOADED will be true. * equivalent). After this call returns DATA_LOADED will be true.

View File

@ -31,7 +31,6 @@
#include "unicode/udata.h" #include "unicode/udata.h"
class SimpleTimeZone;
struct TZHeader; struct TZHeader;
struct OffsetIndex; struct OffsetIndex;
struct CountryIndex; struct CountryIndex;
@ -532,9 +531,10 @@ private:
static TimeZone* fgDefaultZone; // default time zone (lazy evaluated) static TimeZone* fgDefaultZone; // default time zone (lazy evaluated)
static const UnicodeString GMT_ID; static const UChar GMT_ID[];
static const int32_t GMT_ID_LENGTH; static const int32_t GMT_ID_LENGTH;
static const UnicodeString CUSTOM_ID; static const UChar CUSTOM_ID[];
static const TimeZone GMT_OBJ;
//////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////
// Pointers into memory-mapped icudata. Writing to this memory // Pointers into memory-mapped icudata. Writing to this memory
@ -601,8 +601,13 @@ private:
*/ */
static void initDefault(void); static void initDefault(void);
/**
* Get the the GMT TimeZone.
*/
static const TimeZone *getGMT(void);
// See source file for documentation // See source file for documentation
static void loadZoneData(void); static void loadZoneData(void);
// See source file for documentation // See source file for documentation
static UBool U_CALLCONV isDataAcceptable(void *context, static UBool U_CALLCONV isDataAcceptable(void *context,