From 94459b88d40bdcb926dcfecd136865350e6643d3 Mon Sep 17 00:00:00 2001 From: James Hawkins Date: Wed, 21 May 2008 20:28:16 -0500 Subject: [PATCH] mlang: Only return the locale language name if no country name exists. --- dlls/mlang/mlang.c | 3 +++ dlls/mlang/tests/Makefile.in | 2 +- dlls/mlang/tests/mlang.c | 30 ++++++++++++++++++++++++++++++ 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/dlls/mlang/mlang.c b/dlls/mlang/mlang.c index a60ad706c6b..2f73f1f71a6 100644 --- a/dlls/mlang/mlang.c +++ b/dlls/mlang/mlang.c @@ -704,10 +704,13 @@ static inline INT lcid_to_rfc1766A( LCID lcid, LPSTR rfc1766, INT len ) static inline INT lcid_to_rfc1766W( LCID lcid, LPWSTR rfc1766, INT len ) { INT n = GetLocaleInfoW( lcid, LOCALE_SISO639LANGNAME, rfc1766, len ); + INT save = n; if (n) { rfc1766[n - 1] = '-'; n += GetLocaleInfoW( lcid, LOCALE_SISO3166CTRYNAME, rfc1766 + n, len - n ); + if (n == save) + rfc1766[n - 1] = '\0'; LCMapStringW( LOCALE_USER_DEFAULT, LCMAP_LOWERCASE, rfc1766, n, rfc1766, len ); return n; } diff --git a/dlls/mlang/tests/Makefile.in b/dlls/mlang/tests/Makefile.in index 0df144021cf..81b6505f283 100644 --- a/dlls/mlang/tests/Makefile.in +++ b/dlls/mlang/tests/Makefile.in @@ -3,7 +3,7 @@ TOPOBJDIR = ../../.. SRCDIR = @srcdir@ VPATH = @srcdir@ TESTDLL = mlang.dll -IMPORTS = uuid ole32 gdi32 kernel32 +IMPORTS = uuid oleaut32 ole32 gdi32 kernel32 CTESTS = \ mlang.c diff --git a/dlls/mlang/tests/mlang.c b/dlls/mlang/tests/mlang.c index c036f7a425c..dcb8d7dde36 100644 --- a/dlls/mlang/tests/mlang.c +++ b/dlls/mlang/tests/mlang.c @@ -44,6 +44,17 @@ #define TRACE_2 OutputDebugStringA +static CHAR string1[MAX_PATH], string2[MAX_PATH]; + +#define ok_w2(format, szString1, szString2) \ +\ + if (lstrcmpW(szString1, szString2) != 0) \ + { \ + WideCharToMultiByte(CP_ACP, 0, szString1, -1, string1, MAX_PATH, NULL, NULL); \ + WideCharToMultiByte(CP_ACP, 0, szString2, -1, string2, MAX_PATH, NULL, NULL); \ + ok(0, format, string1, string2); \ + } + static BOOL (WINAPI *pGetCPInfoExA)(UINT,DWORD,LPCPINFOEXA); static void test_multibyte_to_unicode_translations(IMultiLanguage2 *iML2) @@ -734,6 +745,24 @@ static void test_GetLcidFromRfc1766(IMultiLanguage2 *iML2) ok(lcid == 0x409, "got wrong lcid: %04x\n", lcid); } +static void test_GetRfc1766FromLcid(IMultiLanguage2 *iML2) +{ + HRESULT hr; + BSTR rfcstr; + LCID lcid; + + static WCHAR kok[] = {'k','o','k',0}; + + hr = IMultiLanguage2_GetLcidFromRfc1766(iML2, &lcid, kok); + ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); + + hr = IMultiLanguage2_GetRfc1766FromLcid(iML2, lcid, &rfcstr); + ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); + ok_w2("Expected \"%s\", got \"%s\"n", kok, rfcstr); + + SysFreeString(rfcstr); +} + START_TEST(mlang) { IMultiLanguage2 *iML2 = NULL; @@ -752,6 +781,7 @@ START_TEST(mlang) test_rfc1766(iML2); test_GetLcidFromRfc1766(iML2); + test_GetRfc1766FromLcid(iML2); test_EnumCodePages(iML2, 0); test_EnumCodePages(iML2, MIMECONTF_MIME_LATEST);