From ade067638efeb69b5100f59d9128dbc461ddf14f Mon Sep 17 00:00:00 2001 From: Jeff Genovy <29107334+jefgen@users.noreply.github.com> Date: Fri, 23 Jun 2017 23:28:11 +0000 Subject: [PATCH] ICU-13164 Fixes for compilation and test errors when building for Windows/MinGW. X-SVN-Rev: 40203 --- icu4c/source/common/locmap.cpp | 61 +++++++++++++++++------- icu4c/source/config/mh-mingw | 4 ++ icu4c/source/config/mh-mingw64 | 4 ++ icu4c/source/io/ufile.cpp | 2 +- icu4c/source/test/intltest/windttst.cpp | 2 + icu4c/source/test/intltest/winnmtst.cpp | 2 + icu4c/source/tools/toolutil/pkg_genc.cpp | 3 +- 7 files changed, 60 insertions(+), 18 deletions(-) diff --git a/icu4c/source/common/locmap.cpp b/icu4c/source/common/locmap.cpp index 97dc00c7735..18994fb8602 100644 --- a/icu4c/source/common/locmap.cpp +++ b/icu4c/source/common/locmap.cpp @@ -190,7 +190,10 @@ ILCID_POSIX_ELEMENT_ARRAY(0x0423, be, be_BY) ILCID_POSIX_ELEMENT_ARRAY(0x0402, bg, bg_BG) -ILCID_POSIX_ELEMENT_ARRAY(0x0466, bin, bin_NG) +ILCID_POSIX_SUBTABLE(bin) { + {0x66, "bin"}, + {0x0466, "bin_NG"} +}; ILCID_POSIX_SUBTABLE(bn) { {0x45, "bn"}, @@ -214,7 +217,13 @@ ILCID_POSIX_SUBTABLE(ca) { }; ILCID_POSIX_ELEMENT_ARRAY(0x0483, co, co_FR) -ILCID_POSIX_ELEMENT_ARRAY(0x045c, chr,chr_US) + +ILCID_POSIX_SUBTABLE(chr) { + {0x05c, "chr"}, + {0x7c5c, "chr_Cher"}, + {0x045c, "chr_Cher_US"}, + {0x045c, "chr_US"} +}; // ICU has chosen different names for these. ILCID_POSIX_SUBTABLE(ckb) { @@ -263,10 +272,10 @@ ILCID_POSIX_SUBTABLE(en) { {0x2C09, "en_TT"}, {0x0409, "en_US"}, {0x007f, "en_US_POSIX"}, /* duplicate for round-tripping */ - {0x2409, "en_VI"}, /* Virgin Islands AKA Caribbean Islands (en_CB). On Windows8+ This is 0x1000 or dynamically assigned */ + {0x2409, "en_029"}, {0x1c09, "en_ZA"}, {0x3009, "en_ZW"}, - {0x2409, "en_029"}, + {0x2409, "en_VI"}, /* Virgin Islands AKA Caribbean Islands (en_CB). On Windows8+ This is 0x1000 or dynamically assigned */ {0x0409, "en_AS"}, /* Alias for en_US. Leave last. On Windows8+ This is 0x1000 or dynamically assigned */ {0x0409, "en_GU"}, /* Alias for en_US. Leave last. On Windows8+ This is 0x1000 or dynamically assigned */ {0x0409, "en_MH"}, /* Alias for en_US. Leave last. On Windows8+ This is 0x1000 or dynamically assigned */ @@ -419,7 +428,12 @@ ILCID_POSIX_SUBTABLE(hsb) { ILCID_POSIX_ELEMENT_ARRAY(0x040e, hu, hu_HU) ILCID_POSIX_ELEMENT_ARRAY(0x042b, hy, hy_AM) -ILCID_POSIX_ELEMENT_ARRAY(0x0469, ibb, ibb_NG) + +ILCID_POSIX_SUBTABLE(ibb) { + {0x69, "ibb"}, + {0x0469, "ibb_NG"} +}; + ILCID_POSIX_ELEMENT_ARRAY(0x0421, id, id_ID) ILCID_POSIX_ELEMENT_ARRAY(0x0470, ig, ig_NG) ILCID_POSIX_ELEMENT_ARRAY(0x0478, ii, ii_CN) @@ -458,13 +472,18 @@ ILCID_POSIX_ELEMENT_ARRAY(0x0471, kr, kr_NG) ILCID_POSIX_SUBTABLE(ks) { /* We could add PK and CN too */ {0x60, "ks"}, - {0x0860, "ks_IN"}, /* Documentation doesn't mention script */ {0x0460, "ks_Arab_IN"}, {0x0860, "ks_Deva_IN"} }; ILCID_POSIX_ELEMENT_ARRAY(0x0440, ky, ky_KG) /* Kyrgyz is spoken in Kyrgyzstan */ -ILCID_POSIX_ELEMENT_ARRAY(0x0476, la, la_IT) /* TODO: Verify the country */ + +ILCID_POSIX_SUBTABLE(la) { + {0x76, "la"}, + {0x0476, "la_001"}, + {0x0476, "la_IT"} /*Left in for compatibility*/ +}; + ILCID_POSIX_ELEMENT_ARRAY(0x046e, lb, lb_LU) ILCID_POSIX_ELEMENT_ARRAY(0x0454, lo, lo_LA) ILCID_POSIX_ELEMENT_ARRAY(0x0427, lt, lt_LT) @@ -535,15 +554,19 @@ ILCID_POSIX_SUBTABLE(or_IN) { {0x0448, "or_IN"}, }; - ILCID_POSIX_SUBTABLE(pa) { {0x46, "pa"}, {0x0446, "pa_IN"}, - {0x0846, "pa_PK"}, - {0x0846, "pa_Arab_PK"} + {0x0846, "pa_Arab_PK"}, + {0x0846, "pa_PK"} +}; + +ILCID_POSIX_SUBTABLE(pap) { + {0x79, "pap"}, + {0x0479, "pap_029"}, + {0x0479, "pap_AN"} /*Left in for compatibility*/ }; -ILCID_POSIX_ELEMENT_ARRAY(0x0479, pap, pap_AN) ILCID_POSIX_ELEMENT_ARRAY(0x0415, pl, pl_PL) ILCID_POSIX_ELEMENT_ARRAY(0x0463, ps, ps_AF) @@ -619,9 +642,11 @@ ILCID_POSIX_ELEMENT_ARRAY(0x0485, sah,sah_RU) ILCID_POSIX_SUBTABLE(sd) { {0x59, "sd"}, - {0x0459, "sd_IN"}, {0x0459, "sd_Deva_IN"}, - {0x0859, "sd_PK"} + {0x0459, "sd_IN"}, + {0x0859, "sd_Arab_PK"}, + {0x0859, "sd_PK"}, + {0x7c59, "sd_Arab"} }; ILCID_POSIX_SUBTABLE(se) { @@ -645,9 +670,8 @@ ILCID_POSIX_ELEMENT_ARRAY(0x045b, si, si_LK) ILCID_POSIX_ELEMENT_ARRAY(0x041b, sk, sk_SK) ILCID_POSIX_ELEMENT_ARRAY(0x0424, sl, sl_SI) -ILCID_POSIX_SUBTABLE(so) { /* TODO: Verify the country */ +ILCID_POSIX_SUBTABLE(so) { {0x77, "so"}, - {0x0477, "so_ET"}, {0x0477, "so_SO"} }; @@ -739,7 +763,12 @@ ILCID_POSIX_SUBTABLE(ve) { /* TODO: Verify the country */ ILCID_POSIX_ELEMENT_ARRAY(0x042a, vi, vi_VN) ILCID_POSIX_ELEMENT_ARRAY(0x0488, wo, wo_SN) ILCID_POSIX_ELEMENT_ARRAY(0x0434, xh, xh_ZA) -ILCID_POSIX_ELEMENT_ARRAY(0x043d, yi, yi) + +ILCID_POSIX_SUBTABLE(yi) { + {0x003d, "yi"}, + {0x043d, "yi_001"} +}; + ILCID_POSIX_ELEMENT_ARRAY(0x046a, yo, yo_NG) // Windows & ICU tend to different names for some of these diff --git a/icu4c/source/config/mh-mingw b/icu4c/source/config/mh-mingw index b8d2ee0589d..94e6439758e 100644 --- a/icu4c/source/config/mh-mingw +++ b/icu4c/source/config/mh-mingw @@ -28,6 +28,10 @@ else STATICCPPFLAGS = -DU_STATIC_IMPLEMENTATION endif +## ICU requires a minimum target of Windows 7, and MinGW does not set this by default. +## https://msdn.microsoft.com/en-us/library/aa383745.aspx +CPPFLAGS += -DWINVER=0x0601 -D_WIN32_WINNT=0x0601 + ## Flags for position independent code SHAREDLIBCFLAGS = SHAREDLIBCXXFLAGS = diff --git a/icu4c/source/config/mh-mingw64 b/icu4c/source/config/mh-mingw64 index 188d2aa7482..6d0c5575329 100644 --- a/icu4c/source/config/mh-mingw64 +++ b/icu4c/source/config/mh-mingw64 @@ -28,6 +28,10 @@ else STATICCPPFLAGS = -DU_STATIC_IMPLEMENTATION endif +## ICU requires a minimum target of Windows 7, and MinGW does not set this by default. +## https://msdn.microsoft.com/en-us/library/aa383745.aspx +CPPFLAGS += -DWINVER=0x0601 -D_WIN32_WINNT=0x0601 + ## Flags for position independent code SHAREDLIBCFLAGS = SHAREDLIBCXXFLAGS = diff --git a/icu4c/source/io/ufile.cpp b/icu4c/source/io/ufile.cpp index 6cbb897555d..1d8c221cdcb 100644 --- a/icu4c/source/io/ufile.cpp +++ b/icu4c/source/io/ufile.cpp @@ -160,7 +160,7 @@ u_fopen_u(const UChar *filename, // TODO: test this code path, including wperm. wchar_t wperm[40] = {}; size_t retVal; - mbstowcs_s(&retVal, wperm, perm, _TRUNCATE); + mbstowcs_s(&retVal, wperm, UPRV_LENGTHOF(wperm), perm, _TRUNCATE); FILE *systemFile = _wfopen((const wchar_t *)filename, wperm); if (systemFile) { result = finit_owner(systemFile, locale, codepage, TRUE); diff --git a/icu4c/source/test/intltest/windttst.cpp b/icu4c/source/test/intltest/windttst.cpp index 467ddb7ab78..dea6ebf2475 100644 --- a/icu4c/source/test/intltest/windttst.cpp +++ b/icu4c/source/test/intltest/windttst.cpp @@ -43,6 +43,8 @@ # define NOMCX # include +#include + static const char *getCalendarType(int32_t type) { switch (type) diff --git a/icu4c/source/test/intltest/winnmtst.cpp b/icu4c/source/test/intltest/winnmtst.cpp index b65ad73dd62..84fc278c129 100644 --- a/icu4c/source/test/intltest/winnmtst.cpp +++ b/icu4c/source/test/intltest/winnmtst.cpp @@ -48,6 +48,8 @@ # include # include +#include + #define NEW_ARRAY(type,count) (type *) uprv_malloc((count) * sizeof(type)) #define DELETE_ARRAY(array) uprv_free((void *) (array)) diff --git a/icu4c/source/tools/toolutil/pkg_genc.cpp b/icu4c/source/tools/toolutil/pkg_genc.cpp index c4e2fbb68a8..0cf7a57ee11 100644 --- a/icu4c/source/tools/toolutil/pkg_genc.cpp +++ b/icu4c/source/tools/toolutil/pkg_genc.cpp @@ -47,6 +47,7 @@ #include "unicode/uclean.h" #include "uoptions.h" #include "pkg_genc.h" +#include "filetools.h" #define MAX_COLUMN ((uint32_t)(0xFFFFFFFFU)) @@ -284,7 +285,7 @@ writeAssemblyCode(const char *filename, const char *destdir, const char *optEntr } #if defined (WINDOWS_WITH_GNUC) && U_PLATFORM != U_PF_CYGWIN - /* Need to fix the file seperator character when using MinGW. */ + /* Need to fix the file separator character when using MinGW. */ swapFileSepChar(outFilePath, U_FILE_SEP_CHAR, '/'); #endif