summaryrefslogtreecommitdiff
path: root/Build/source
diff options
context:
space:
mode:
authorPeter Breitenlohner <peb@mppmu.mpg.de>2012-11-29 08:54:26 +0000
committerPeter Breitenlohner <peb@mppmu.mpg.de>2012-11-29 08:54:26 +0000
commit3ce72a12418976af7e9b910fccea0f2ad5966397 (patch)
tree13a54de2500c225313858821d620109256dac114 /Build/source
parentcbd4496de50480cd0601c6315529d70310ef2a79 (diff)
icu: Apply patch required for Windows 2000 (from Akira)
git-svn-id: svn://tug.org/texlive/trunk@28386 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source')
-rw-r--r--Build/source/libs/icu/icu-50.1-PATCHES/ChangeLog4
-rw-r--r--Build/source/libs/icu/icu-50.1-PATCHES/patch-04-Windows2000125
-rw-r--r--Build/source/libs/icu/icu-50.1/common/wintz.c84
3 files changed, 198 insertions, 15 deletions
diff --git a/Build/source/libs/icu/icu-50.1-PATCHES/ChangeLog b/Build/source/libs/icu/icu-50.1-PATCHES/ChangeLog
index 3c54ab7d70c..bdddb1c9b7b 100644
--- a/Build/source/libs/icu/icu-50.1-PATCHES/ChangeLog
+++ b/Build/source/libs/icu/icu-50.1-PATCHES/ChangeLog
@@ -1,3 +1,7 @@
+2012-11-29 Peter Breitenlohner <peb@mppmu.mpg.de>
+
+ * patch-04-Windows2000 (new): From Akira.
+
2012-11-16 Peter Breitenlohner <peb@mppmu.mpg.de>
* patch-84-c++11-bugfix (new): Required for gcc-4.7.
diff --git a/Build/source/libs/icu/icu-50.1-PATCHES/patch-04-Windows2000 b/Build/source/libs/icu/icu-50.1-PATCHES/patch-04-Windows2000
new file mode 100644
index 00000000000..09f92c8f640
--- /dev/null
+++ b/Build/source/libs/icu/icu-50.1-PATCHES/patch-04-Windows2000
@@ -0,0 +1,125 @@
+diff -ur icu-50.1.orig/source/common/wintz.c icu-50.1/source/common/wintz.c
+--- icu-50.1.orig/source/common/wintz.c 2012-11-05 18:14:42.000000000 +0100
++++ icu-50.1/source/common/wintz.c 2012-11-29 09:10:43.000000000 +0100
+@@ -265,6 +265,28 @@
+ TZI tziReg;
+ TIME_ZONE_INFORMATION apiTZI;
+
++ OSVERSIONINFO winosversion;
++ static int NewerThanWindows2000 = -1;
++
++ /* If the OS version is older than Windows XP, we use the
++ * code in ICU-49.1.2, since GetGeoInfo() is not available.
++ */
++
++ if (NewerThanWindows2000 == -1) {
++ if (GetVersionEx (&winosversion) == 0) {
++ /* GetVersionEx() failed for some reason. We assume
++ * the Windows OS is newer than Windows 2000.
++ */
++ NewerThanWindows2000 = 1;
++ } else if (winosversion.dwMajorVersion > 5 ||
++ (winosversion.dwMajorVersion == 5 &&
++ winosversion.dwMinorVersion > 0)) {
++ NewerThanWindows2000 = 1;
++ } else {
++ NewerThanWindows2000 = 0;
++ }
++ }
++
+ /* Obtain TIME_ZONE_INFORMATION from the API, and then convert it
+ to TZI. We could also interrogate the registry directly; we do
+ this below if needed. */
+@@ -285,9 +307,31 @@
+
+ tmpid[0] = 0;
+
+- id = GetUserGeoID(GEOCLASS_NATION);
+- errorCode = GetGeoInfo(id,GEO_ISO2,ISOcode,3,0);
++ if (NewerThanWindows2000 == 1) {
++ HINSTANCE hi;
++ PROC pgetusergeoid, pgetgeoinfo;
++
++ /* if LoadLibrary() and/or GetProcAdress() fail, we again
++ * set NewerThanWindows2000 = 0, and use the code in ICU 49.1.2.
++ */
++
++ hi = LoadLibrary ("kernel32.dll");
++ if (hi == NULL) {
++ NewerThanWindows2000 = 0;
++ } else {
++ pgetusergeoid = GetProcAddress (hi, "GetUserGeoID");
++ pgetgeoinfo = GetProcAddress (hi, "GetGeoInfoA");
++ }
++ if (!pgetusergeoid || !pgetgeoinfo)
++ NewerThanWindows2000 = 0;
+
++ if (NewerThanWindows2000 == 1) {
++ id = (int)pgetusergeoid (GEOCLASS_NATION);
++ errorCode = (int)pgetgeoinfo (id,GEO_ISO2,ISOcode,3,0);
++ }
++ if (hi)
++ FreeLibrary (hi);
++ }
+ bundle = ures_openDirect(NULL, "windowsZones", &status);
+ ures_getByKey(bundle, "mapTimezones", bundle, &status);
+
+@@ -310,14 +354,19 @@
+ tziKey.daylightBias = tziReg.daylightBias;
+
+ if (uprv_memcmp((char *)&tziKey, (char*)&tziReg, sizeof(tziKey)) == 0) {
+- const UChar* icuTZ = NULL;
+- if (errorCode != 0) {
+- icuTZ = ures_getStringByKey(winTZ, ISOcode, &len, &status);
+- }
+- if (errorCode==0 || icuTZ==NULL) {
+- /* fallback to default "001" and reset status */
+- status = U_ZERO_ERROR;
++ const UChar* icuTZ;
++ if (NewerThanWindows2000 == 0) {
+ icuTZ = ures_getStringByKey(winTZ, "001", &len, &status);
++ } else if (NewerThanWindows2000 == 1) {
++ icuTZ = NULL;
++ if (errorCode != 0) {
++ icuTZ = ures_getStringByKey(winTZ, ISOcode, &len, &status);
++ }
++ if (errorCode==0 || icuTZ==NULL) {
++ /* fallback to default "001" and reset status */
++ status = U_ZERO_ERROR;
++ icuTZ = ures_getStringByKey(winTZ, "001", &len, &status);
++ }
+ }
+
+ if (U_SUCCESS(status)) {
+@@ -336,12 +385,17 @@
+ * the current time zone information)
+ */
+ if (idFound || tmpid[0] == 0) {
+- /* if icuTZ has more than one city, take only the first (i.e. terminate icuTZ at first space) */
+- int index=0;
+- while (! (*icuTZ == '\0' || *icuTZ ==' ')) {
+- tmpid[index++]=*icuTZ++;
++ if (NewerThanWindows2000 == 0) {
++ uprv_memset(tmpid, 0, sizeof(tmpid));
++ u_austrncpy(tmpid, icuTZ, len);
++ } else if (NewerThanWindows2000 == 1) {
++ /* if icuTZ has more than one city, take only the first (i.e. terminate icuTZ at first space) */
++ int index=0;
++ while (! (*icuTZ == '\0' || *icuTZ ==' ')) {
++ tmpid[index++]=*icuTZ++;
++ }
++ tmpid[index]='\0';
+ }
+- tmpid[index]='\0';
+ }
+ }
+ }
+@@ -364,7 +418,7 @@
+ }
+
+ ures_close(bundle);
+-
++
+ return icuid;
+ }
+
diff --git a/Build/source/libs/icu/icu-50.1/common/wintz.c b/Build/source/libs/icu/icu-50.1/common/wintz.c
index a1da126a0db..aec1dec4c60 100644
--- a/Build/source/libs/icu/icu-50.1/common/wintz.c
+++ b/Build/source/libs/icu/icu-50.1/common/wintz.c
@@ -265,6 +265,28 @@ uprv_detectWindowsTimeZone() {
TZI tziReg;
TIME_ZONE_INFORMATION apiTZI;
+ OSVERSIONINFO winosversion;
+ static int NewerThanWindows2000 = -1;
+
+ /* If the OS version is older than Windows XP, we use the
+ * code in ICU-49.1.2, since GetGeoInfo() is not available.
+ */
+
+ if (NewerThanWindows2000 == -1) {
+ if (GetVersionEx (&winosversion) == 0) {
+ /* GetVersionEx() failed for some reason. We assume
+ * the Windows OS is newer than Windows 2000.
+ */
+ NewerThanWindows2000 = 1;
+ } else if (winosversion.dwMajorVersion > 5 ||
+ (winosversion.dwMajorVersion == 5 &&
+ winosversion.dwMinorVersion > 0)) {
+ NewerThanWindows2000 = 1;
+ } else {
+ NewerThanWindows2000 = 0;
+ }
+ }
+
/* Obtain TIME_ZONE_INFORMATION from the API, and then convert it
to TZI. We could also interrogate the registry directly; we do
this below if needed. */
@@ -285,9 +307,31 @@ uprv_detectWindowsTimeZone() {
tmpid[0] = 0;
- id = GetUserGeoID(GEOCLASS_NATION);
- errorCode = GetGeoInfo(id,GEO_ISO2,ISOcode,3,0);
+ if (NewerThanWindows2000 == 1) {
+ HINSTANCE hi;
+ PROC pgetusergeoid, pgetgeoinfo;
+ /* if LoadLibrary() and/or GetProcAdress() fail, we again
+ * set NewerThanWindows2000 = 0, and use the code in ICU 49.1.2.
+ */
+
+ hi = LoadLibrary ("kernel32.dll");
+ if (hi == NULL) {
+ NewerThanWindows2000 = 0;
+ } else {
+ pgetusergeoid = GetProcAddress (hi, "GetUserGeoID");
+ pgetgeoinfo = GetProcAddress (hi, "GetGeoInfoA");
+ }
+ if (!pgetusergeoid || !pgetgeoinfo)
+ NewerThanWindows2000 = 0;
+
+ if (NewerThanWindows2000 == 1) {
+ id = (int)pgetusergeoid (GEOCLASS_NATION);
+ errorCode = (int)pgetgeoinfo (id,GEO_ISO2,ISOcode,3,0);
+ }
+ if (hi)
+ FreeLibrary (hi);
+ }
bundle = ures_openDirect(NULL, "windowsZones", &status);
ures_getByKey(bundle, "mapTimezones", bundle, &status);
@@ -310,14 +354,19 @@ uprv_detectWindowsTimeZone() {
tziKey.daylightBias = tziReg.daylightBias;
if (uprv_memcmp((char *)&tziKey, (char*)&tziReg, sizeof(tziKey)) == 0) {
- const UChar* icuTZ = NULL;
- if (errorCode != 0) {
- icuTZ = ures_getStringByKey(winTZ, ISOcode, &len, &status);
- }
- if (errorCode==0 || icuTZ==NULL) {
- /* fallback to default "001" and reset status */
- status = U_ZERO_ERROR;
+ const UChar* icuTZ;
+ if (NewerThanWindows2000 == 0) {
icuTZ = ures_getStringByKey(winTZ, "001", &len, &status);
+ } else if (NewerThanWindows2000 == 1) {
+ icuTZ = NULL;
+ if (errorCode != 0) {
+ icuTZ = ures_getStringByKey(winTZ, ISOcode, &len, &status);
+ }
+ if (errorCode==0 || icuTZ==NULL) {
+ /* fallback to default "001" and reset status */
+ status = U_ZERO_ERROR;
+ icuTZ = ures_getStringByKey(winTZ, "001", &len, &status);
+ }
}
if (U_SUCCESS(status)) {
@@ -336,12 +385,17 @@ uprv_detectWindowsTimeZone() {
* the current time zone information)
*/
if (idFound || tmpid[0] == 0) {
- /* if icuTZ has more than one city, take only the first (i.e. terminate icuTZ at first space) */
- int index=0;
- while (! (*icuTZ == '\0' || *icuTZ ==' ')) {
- tmpid[index++]=*icuTZ++;
+ if (NewerThanWindows2000 == 0) {
+ uprv_memset(tmpid, 0, sizeof(tmpid));
+ u_austrncpy(tmpid, icuTZ, len);
+ } else if (NewerThanWindows2000 == 1) {
+ /* if icuTZ has more than one city, take only the first (i.e. terminate icuTZ at first space) */
+ int index=0;
+ while (! (*icuTZ == '\0' || *icuTZ ==' ')) {
+ tmpid[index++]=*icuTZ++;
+ }
+ tmpid[index]='\0';
}
- tmpid[index]='\0';
}
}
}
@@ -364,7 +418,7 @@ uprv_detectWindowsTimeZone() {
}
ures_close(bundle);
-
+
return icuid;
}