From 91952d3f9adbc6ce59f391faa102135cb4ef6c59 Mon Sep 17 00:00:00 2001 From: Norm Ross Date: Mon, 11 Nov 2024 11:05:35 -0800 Subject: [PATCH 1/2] Fix ICU loading on 1809 --- src/tz.cpp | 42 +++++++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/src/tz.cpp b/src/tz.cpp index aa0dc7b6..af18fef8 100644 --- a/src/tz.cpp +++ b/src/tz.cpp @@ -327,20 +327,20 @@ namespace { return _Result; } - struct __std_tzdb_leap_info { - uint16_t _Year; - uint16_t _Month; - uint16_t _Day; - uint16_t _Hour; - uint16_t _Negative; - uint16_t _Reserved; - }; - - enum class __std_tzdb_error { - _Success = 0, - _Win_error = 1, - _Icu_error = 2, - }; + //struct __std_tzdb_leap_info { + // uint16_t _Year; + // uint16_t _Month; + // uint16_t _Day; + // uint16_t _Hour; + // uint16_t _Negative; + // uint16_t _Reserved; + //}; + + //enum class __std_tzdb_error { + // _Success = 0, + // _Win_error = 1, + // _Icu_error = 2, + //}; // from stl/src/tzdb.cpp @@ -387,16 +387,19 @@ namespace { const HMODULE _Icu_Module, const HMODULE _IcuIn_Module, const HMODULE _IcuUc_Module, _STD atomic<_Ty>& _Stored_Pfn, LPCSTR _Fn_name, DWORD& _Last_error) noexcept { const HMODULE _icus[3] = {_Icu_Module, _IcuIn_Module, _IcuUc_Module}; + DWORD last_error = E_FAIL; for (int i = 0; i < 3; i++) { - if (_icus[i] == nullptr) break; + if (_icus[i] == nullptr) continue; const auto _Pfn = reinterpret_cast<_Ty>(GetProcAddress(_icus[i], _Fn_name)); if (_Pfn != nullptr) { _Stored_Pfn.store(_Pfn, _STD memory_order_relaxed); + last_error = S_OK; break; } else { - _Last_error = GetLastError(); + last_error = GetLastError(); } } + if (!SUCCEEDED(last_error)) _Last_error = last_error; } [[nodiscard]] _Icu_api_level _Init_icu_functions(_Icu_api_level _Level) noexcept { @@ -481,7 +484,12 @@ namespace { DWORD dwFVISize = GetFileVersionInfoSizeW(_Icu_DLL_Name.c_str(), &dwDummy); LPBYTE lpVersionInfo = new BYTE[dwFVISize]; if (GetFileVersionInfoW(_Icu_DLL_Name.c_str(), 0, dwFVISize, lpVersionInfo) == 0) { - return _Level; + delete[] lpVersionInfo; + DWORD dwFVISize = GetFileVersionInfoSizeW(_IcuIn_DLL_Name.c_str(), &dwDummy); + lpVersionInfo = new BYTE[dwFVISize]; + if (GetFileVersionInfoW(_IcuIn_DLL_Name.c_str(), 0, dwFVISize, lpVersionInfo) == 0) { + return _Level; + } } UINT uLen; From 89701507e49e0da01c48ad31fd7413d89a812645 Mon Sep 17 00:00:00 2001 From: Norm Ross <68429847+senstar-nross@users.noreply.github.com> Date: Mon, 11 Nov 2024 15:41:05 -0500 Subject: [PATCH 2/2] Uncomment the __std_tzdb_leap_info and the __std_tzdb_error Conflicted in the test env but not doing a proper CMake build --- src/tz.cpp | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/tz.cpp b/src/tz.cpp index af18fef8..38161f47 100644 --- a/src/tz.cpp +++ b/src/tz.cpp @@ -327,20 +327,20 @@ namespace { return _Result; } - //struct __std_tzdb_leap_info { - // uint16_t _Year; - // uint16_t _Month; - // uint16_t _Day; - // uint16_t _Hour; - // uint16_t _Negative; - // uint16_t _Reserved; - //}; - - //enum class __std_tzdb_error { - // _Success = 0, - // _Win_error = 1, - // _Icu_error = 2, - //}; + struct __std_tzdb_leap_info { + uint16_t _Year; + uint16_t _Month; + uint16_t _Day; + uint16_t _Hour; + uint16_t _Negative; + uint16_t _Reserved; + }; + + enum class __std_tzdb_error { + _Success = 0, + _Win_error = 1, + _Icu_error = 2, + }; // from stl/src/tzdb.cpp