Signed-off-by: Jinoh Kang jinoh.kang.kr@gmail.com --- dlls/kernel32/tests/locale.c | 169 +++++++++++++++++++++++++++++++++++ 1 file changed, 169 insertions(+)
diff --git a/dlls/kernel32/tests/locale.c b/dlls/kernel32/tests/locale.c index cad2577379b..a5c2ad1068d 100644 --- a/dlls/kernel32/tests/locale.c +++ b/dlls/kernel32/tests/locale.c @@ -7008,6 +7008,171 @@ static void test_geo_name(void) RegCloseKey(key); }
+static const LCID locales_with_optional_calendars[] = { + MAKELCID(MAKELANGID(LANG_ARABIC, SUBLANG_ARABIC_SAUDI_ARABIA), SORT_DEFAULT), + MAKELCID(MAKELANGID(LANG_ARABIC, SUBLANG_ARABIC_LEBANON), SORT_DEFAULT), + MAKELCID(MAKELANGID(LANG_ARABIC, SUBLANG_ARABIC_EGYPT), SORT_DEFAULT), + MAKELCID(MAKELANGID(LANG_ARABIC, SUBLANG_ARABIC_ALGERIA), SORT_DEFAULT), + MAKELCID(MAKELANGID(LANG_ARABIC, SUBLANG_ARABIC_BAHRAIN), SORT_DEFAULT), + MAKELCID(MAKELANGID(LANG_ARABIC, SUBLANG_ARABIC_IRAQ), SORT_DEFAULT), + MAKELCID(MAKELANGID(LANG_ARABIC, SUBLANG_ARABIC_JORDAN), SORT_DEFAULT), + MAKELCID(MAKELANGID(LANG_ARABIC, SUBLANG_ARABIC_KUWAIT), SORT_DEFAULT), + MAKELCID(MAKELANGID(LANG_ARABIC, SUBLANG_ARABIC_LIBYA), SORT_DEFAULT), + MAKELCID(MAKELANGID(LANG_ARABIC, SUBLANG_ARABIC_MOROCCO), SORT_DEFAULT), + MAKELCID(MAKELANGID(LANG_ARABIC, SUBLANG_ARABIC_OMAN), SORT_DEFAULT), + MAKELCID(MAKELANGID(LANG_ARABIC, SUBLANG_ARABIC_QATAR), SORT_DEFAULT), + MAKELCID(MAKELANGID(LANG_ARABIC, SUBLANG_ARABIC_SYRIA), SORT_DEFAULT), + MAKELCID(MAKELANGID(LANG_ARABIC, SUBLANG_ARABIC_TUNISIA), SORT_DEFAULT), + MAKELCID(MAKELANGID(LANG_ARABIC, SUBLANG_ARABIC_UAE), SORT_DEFAULT), + MAKELCID(MAKELANGID(LANG_ARABIC, SUBLANG_ARABIC_YEMEN), SORT_DEFAULT), + MAKELCID(MAKELANGID(LANG_CHINESE, SUBLANG_CHINESE_TRADITIONAL), SORT_DEFAULT), + MAKELCID(MAKELANGID(LANG_DIVEHI, SUBLANG_DEFAULT), SORT_DEFAULT), + MAKELCID(MAKELANGID(LANG_PERSIAN, SUBLANG_DEFAULT), SORT_DEFAULT), + MAKELCID(MAKELANGID(LANG_HEBREW, SUBLANG_DEFAULT), SORT_DEFAULT), + MAKELCID(MAKELANGID(LANG_JAPANESE, SUBLANG_DEFAULT), SORT_DEFAULT), + MAKELCID(MAKELANGID(LANG_KOREAN, SUBLANG_KOREAN), SORT_DEFAULT), + MAKELCID(MAKELANGID(LANG_THAI, SUBLANG_DEFAULT), SORT_DEFAULT), + MAKELCID(MAKELANGID(LANG_URDU, SUBLANG_URDU_PAKISTAN), SORT_DEFAULT) +}; + +static BOOL CALLBACK calinfo_procA(LPSTR calinfo) +{ + (void)calinfo; + return TRUE; +} + +static void test_EnumCalendarInfoA(void) +{ + INT i; + + if (!strcmp(winetest_platform, "wine")) + { + skip("EnumCalendarInfo broken on Wine (test would hang with an infinite loop)\n"); + return; + } + + ok( EnumCalendarInfoA( calinfo_procA, + LOCALE_USER_DEFAULT, + ENUM_ALL_CALENDARS, + CAL_RETURN_NUMBER | CAL_ICALINTVALUE ), + "EnumCalendarInfoA for user default locale failed: %u\n", GetLastError() ); + + for (i = 0; i < ARRAY_SIZE( locales_with_optional_calendars ); i++) + { + LCID lcid = locales_with_optional_calendars[i]; + ok( EnumCalendarInfoA( calinfo_procA, + lcid, + ENUM_ALL_CALENDARS, + CAL_RETURN_NUMBER | CAL_ICALINTVALUE ) || + broken( GetLastError() == ERROR_INVALID_FLAGS ) /* no locale */, + "EnumCalendarInfoA for LCID %#06x failed: %u\n", lcid, GetLastError() ); + } +} + +static BOOL CALLBACK calinfo_procW(LPWSTR calinfo) +{ + (void)calinfo; + return TRUE; +} + +static void test_EnumCalendarInfoW(void) +{ + INT i; + + if (!strcmp(winetest_platform, "wine")) + { + skip("EnumCalendarInfo broken on Wine (test would hang with an infinite loop)\n"); + return; + } + + ok( EnumCalendarInfoW( calinfo_procW, + LOCALE_USER_DEFAULT, + ENUM_ALL_CALENDARS, + CAL_RETURN_NUMBER | CAL_ICALINTVALUE ), + "EnumCalendarInfoW for user default locale failed: %u\n", GetLastError() ); + + for (i = 0; i < ARRAY_SIZE( locales_with_optional_calendars ); i++) + { + LCID lcid = locales_with_optional_calendars[i]; + ok( EnumCalendarInfoW( calinfo_procW, + lcid, + ENUM_ALL_CALENDARS, + CAL_RETURN_NUMBER | CAL_ICALINTVALUE ) || + broken( GetLastError() == ERROR_INVALID_FLAGS ) /* no locale */, + "EnumCalendarInfoW for LCID %#06x failed: %u\n", lcid, GetLastError() ); + } +} + +static BOOL CALLBACK calinfoex_procA(LPSTR calinfo, LCID calid) +{ + (void)calinfo; + (void)calid; + return TRUE; +} + +static void test_EnumCalendarInfoExA(void) +{ + INT i; + + if (!strcmp(winetest_platform, "wine")) + { + skip("EnumCalendarInfo broken on Wine (test would hang with an infinite loop)\n"); + return; + } + + ok( EnumCalendarInfoExA( calinfoex_procA, + LOCALE_USER_DEFAULT, + ENUM_ALL_CALENDARS, + CAL_RETURN_NUMBER | CAL_ICALINTVALUE ), + "EnumCalendarInfoExA for user default locale failed: %u\n", GetLastError() ); + + for (i = 0; i < ARRAY_SIZE( locales_with_optional_calendars ); i++) + { + LCID lcid = locales_with_optional_calendars[i]; + ok( EnumCalendarInfoExA( calinfoex_procA, + lcid, + ENUM_ALL_CALENDARS, + CAL_RETURN_NUMBER | CAL_ICALINTVALUE ) || + broken( GetLastError() == ERROR_INVALID_FLAGS ) /* no locale */, + "EnumCalendarInfoExA for LCID %#06x failed: %u\n", lcid, GetLastError() ); + } +} + +static BOOL CALLBACK calinfoex_procW(LPWSTR calinfo, LCID calid) +{ + (void)calinfo; + (void)calid; + return TRUE; +} + +static void test_EnumCalendarInfoExW(void) +{ + INT i; + + if (!strcmp(winetest_platform, "wine")) + { + skip("EnumCalendarInfo broken on Wine (test would hang with an infinite loop)\n"); + return; + } + + ok( EnumCalendarInfoExW( calinfoex_procW, + LOCALE_USER_DEFAULT, + ENUM_ALL_CALENDARS, + CAL_RETURN_NUMBER | CAL_ICALINTVALUE ), + "EnumCalendarInfoExW for user default locale failed: %u\n", GetLastError() ); + + for (i = 0; i < ARRAY_SIZE( locales_with_optional_calendars ); i++) + { + LCID lcid = locales_with_optional_calendars[i]; + ok( EnumCalendarInfoExW( calinfoex_procW, + lcid, + ENUM_ALL_CALENDARS, + CAL_RETURN_NUMBER | CAL_ICALINTVALUE ) || + broken( GetLastError() == ERROR_INVALID_FLAGS ) /* no locale */, + "EnumCalendarInfoExW for LCID %#06x failed: %u\n", lcid, GetLastError() ); + } +} + START_TEST(locale) { InitFunctionPointers(); @@ -7060,4 +7225,8 @@ START_TEST(locale) test_NLSVersion(); test_geo_name(); test_sorting(); + test_EnumCalendarInfoA(); + test_EnumCalendarInfoW(); + test_EnumCalendarInfoExA(); + test_EnumCalendarInfoExW(); }
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52129 Signed-off-by: Jinoh Kang jinoh.kang.kr@gmail.com --- dlls/kernel32/tests/locale.c | 24 ------------------------ dlls/kernelbase/locale.c | 24 +++++++++++++++--------- 2 files changed, 15 insertions(+), 33 deletions(-)
diff --git a/dlls/kernel32/tests/locale.c b/dlls/kernel32/tests/locale.c index a5c2ad1068d..94c9ce3ad1b 100644 --- a/dlls/kernel32/tests/locale.c +++ b/dlls/kernel32/tests/locale.c @@ -7045,12 +7045,6 @@ static void test_EnumCalendarInfoA(void) { INT i;
- if (!strcmp(winetest_platform, "wine")) - { - skip("EnumCalendarInfo broken on Wine (test would hang with an infinite loop)\n"); - return; - } - ok( EnumCalendarInfoA( calinfo_procA, LOCALE_USER_DEFAULT, ENUM_ALL_CALENDARS, @@ -7079,12 +7073,6 @@ static void test_EnumCalendarInfoW(void) { INT i;
- if (!strcmp(winetest_platform, "wine")) - { - skip("EnumCalendarInfo broken on Wine (test would hang with an infinite loop)\n"); - return; - } - ok( EnumCalendarInfoW( calinfo_procW, LOCALE_USER_DEFAULT, ENUM_ALL_CALENDARS, @@ -7114,12 +7102,6 @@ static void test_EnumCalendarInfoExA(void) { INT i;
- if (!strcmp(winetest_platform, "wine")) - { - skip("EnumCalendarInfo broken on Wine (test would hang with an infinite loop)\n"); - return; - } - ok( EnumCalendarInfoExA( calinfoex_procA, LOCALE_USER_DEFAULT, ENUM_ALL_CALENDARS, @@ -7149,12 +7131,6 @@ static void test_EnumCalendarInfoExW(void) { INT i;
- if (!strcmp(winetest_platform, "wine")) - { - skip("EnumCalendarInfo broken on Wine (test would hang with an infinite loop)\n"); - return; - } - ok( EnumCalendarInfoExW( calinfoex_procW, LOCALE_USER_DEFAULT, ENUM_ALL_CALENDARS, diff --git a/dlls/kernelbase/locale.c b/dlls/kernelbase/locale.c index 10f3b2698b5..779d6071ab0 100644 --- a/dlls/kernelbase/locale.c +++ b/dlls/kernelbase/locale.c @@ -2722,13 +2722,13 @@ static DWORD get_timezone_id( const TIME_ZONE_INFORMATION *info, LARGE_INTEGER t /****************************************************************************** * Internal_EnumCalendarInfo (kernelbase.@) */ -BOOL WINAPI DECLSPEC_HOTPATCH Internal_EnumCalendarInfo( CALINFO_ENUMPROCW proc, LCID lcid, CALID id, +BOOL WINAPI DECLSPEC_HOTPATCH Internal_EnumCalendarInfo( CALINFO_ENUMPROCW proc, LCID lcid, CALID id_or_all, CALTYPE type, BOOL unicode, BOOL ex, BOOL exex, LPARAM lparam ) { WCHAR buffer[256]; - DWORD optional = 0; - INT ret; + CALID calendars[2], id; + INT ret, i;
if (!proc) { @@ -2736,16 +2736,24 @@ BOOL WINAPI DECLSPEC_HOTPATCH Internal_EnumCalendarInfo( CALINFO_ENUMPROCW proc, return FALSE; }
- if (id == ENUM_ALL_CALENDARS) + if (id_or_all == ENUM_ALL_CALENDARS) { if (!GetLocaleInfoW( lcid, LOCALE_ICALENDARTYPE | LOCALE_RETURN_NUMBER, - (WCHAR *)&id, sizeof(id) / sizeof(WCHAR) )) return FALSE; + (WCHAR *)&calendars[0], sizeof(calendars[0]) / sizeof(WCHAR) )) return FALSE; if (!GetLocaleInfoW( lcid, LOCALE_IOPTIONALCALENDAR | LOCALE_RETURN_NUMBER, - (WCHAR *)&optional, sizeof(optional) / sizeof(WCHAR) )) optional = 0; + (WCHAR *)&calendars[1], sizeof(calendars[1]) / sizeof(WCHAR) )) calendars[1] = 0; + } + else + { + calendars[0] = id_or_all; + calendars[1] = 0; }
- for (;;) + for (i = 0; i < ARRAY_SIZE(calendars); i++) { + id = calendars[i]; + if (!id) continue; + if (type & CAL_RETURN_NUMBER) ret = GetCalendarInfoW( lcid, id, type, NULL, 0, (LPDWORD)buffer ); else if (unicode) @@ -2764,8 +2772,6 @@ BOOL WINAPI DECLSPEC_HOTPATCH Internal_EnumCalendarInfo( CALINFO_ENUMPROCW proc, else ret = proc( buffer ); } if (!ret) break; - if (!optional) break; - id = optional; } return TRUE; }