diff --git a/dlls/oleaut32/tests/vartest.c b/dlls/oleaut32/tests/vartest.c index 648c959b691..24ef171d0d6 100644 --- a/dlls/oleaut32/tests/vartest.c +++ b/dlls/oleaut32/tests/vartest.c @@ -46,6 +46,11 @@ static INT (WINAPI *pVariantTimeToSystemTime)(double,LPSYSTEMTIME); static INT (WINAPI *pDosDateTimeToVariantTime)(USHORT,USHORT,double*); static INT (WINAPI *pVariantTimeToDosDateTime)(double,USHORT*,USHORT *); +static const WCHAR sz12[] = {'1','2','\0'}; +/* the strings are localized */ +static WCHAR sz12_false[32]; +static WCHAR sz12_true[32]; + /* Get a conversion function ptr, return if function not available */ #define CHECKPTR(func) p##func = (void*)GetProcAddress(hOleaut32, #func); \ if (!p##func) { trace("function " # func " not available, not testing it\n"); return; } @@ -95,7 +100,24 @@ static int IS_ANCIENT = 0; static void init(void) { - hOleaut32 = GetModuleHandle("oleaut32.dll"); + BSTR bstr; + HRESULT res; + + res = VarBstrFromBool(VARIANT_TRUE, LANG_USER_DEFAULT, VAR_LOCALBOOL, &bstr); + ok(SUCCEEDED(res) && (lstrlenW(bstr) > 0), + "Expected localized string for 'True'\n"); + lstrcpyW(sz12_true, sz12); + if (bstr) lstrcatW(sz12_true, bstr); + SysFreeString(bstr); + + res = VarBstrFromBool(VARIANT_FALSE, LANG_USER_DEFAULT, VAR_LOCALBOOL, &bstr); + ok(SUCCEEDED(res) && (lstrlenW(bstr) > 0), + "Expected localized string for 'False'\n"); + lstrcpyW(sz12_false, sz12); + if (bstr) lstrcatW(sz12_false, bstr); + SysFreeString(bstr); + + hOleaut32 = GetModuleHandle("oleaut32.dll"); /* Is a given function exported from oleaut32? */ #define HAVE_FUNC(func) ((void*)GetProcAddress(hOleaut32, #func) != NULL) @@ -2007,7 +2029,6 @@ static HRESULT (WINAPI *pVarSub)(LPVARIANT,LPVARIANT,LPVARIANT); static void test_VarSub(void) { - static const WCHAR sz12[] = {'1','2','\0'}; VARIANT left, right, exp, result, cy, dec; VARTYPE i; BSTR lbstr, rbstr; @@ -4856,7 +4877,6 @@ static HRESULT (WINAPI *pVarMul)(LPVARIANT,LPVARIANT,LPVARIANT); static void test_VarMul(void) { - static const WCHAR sz12[] = {'1','2','\0'}; VARIANT left, right, exp, result, cy, dec; VARTYPE i; BSTR lbstr, rbstr; @@ -5028,7 +5048,6 @@ static HRESULT (WINAPI *pVarAdd)(LPVARIANT,LPVARIANT,LPVARIANT); static void test_VarAdd(void) { - static const WCHAR sz12[] = {'1','2','\0'}; VARIANT left, right, exp, result, cy, dec; VARTYPE i; BSTR lbstr, rbstr; @@ -5215,14 +5234,11 @@ static void test_VarCat(void) { LCID lcid; VARIANT left, right, result, expected; - static const WCHAR sz12[] = {'1','2','\0'}; static const WCHAR sz34[] = {'3','4','\0'}; static const WCHAR sz1234[] = {'1','2','3','4','\0'}; static const WCHAR date_sz12[] = {'9','/','3','0','/','1','9','8','0','1','2','\0'}; static const WCHAR sz12_date[] = {'1','2','9','/','3','0','/','1','9','8','0','\0'}; static const WCHAR sz_empty[] = {'\0'}; - static const WCHAR sz12_true[] = {'1','2','T','r','u','e','\0'}; - static const WCHAR sz12_false[] = {'1','2','F','a','l','s','e','\0'}; TCHAR orig_date_format[128]; VARTYPE leftvt, rightvt, resultvt; HRESULT hres; @@ -5416,8 +5432,8 @@ static void test_VarCat(void) hres = VarCat(&left,&right,&result); ok(hres == S_OK, "VarCat failed with error 0x%08x\n", hres); hres = VarCmp(&result,&expected,lcid,0); - ok(hres == VARCMP_EQ || - broken(hres == VARCMP_GT), "Expected VARCMP_EQ, got %08x\n", hres); + ok(hres == VARCMP_EQ, "Expected VARCMP_EQ, got %08x for %s, %s\n", + hres, variantstr(&result), variantstr(&expected)); VariantClear(&left); VariantClear(&right); @@ -5433,8 +5449,8 @@ static void test_VarCat(void) hres = VarCat(&left,&right,&result); ok(hres == S_OK, "VarCat failed with error 0x%08x\n", hres); hres = VarCmp(&result,&expected,lcid,0); - ok(hres == VARCMP_EQ || - broken(hres == VARCMP_GT), "Expected VARCMP_EQ, got %08x\n", hres); + ok(hres == VARCMP_EQ, "Expected VARCMP_EQ, got %08x for %s, %s\n", + hres, variantstr(&result), variantstr(&expected)); VariantClear(&left); VariantClear(&right); diff --git a/dlls/oleaut32/variant.c b/dlls/oleaut32/variant.c index 26a19bbbe85..909cf8a830c 100644 --- a/dlls/oleaut32/variant.c +++ b/dlls/oleaut32/variant.c @@ -40,6 +40,7 @@ #include "wine/unicode.h" #include "winerror.h" #include "variant.h" +#include "resource.h" #include "wine/debug.h" WINE_DEFAULT_DEBUG_CHANNEL(variant); @@ -2467,8 +2468,8 @@ HRESULT WINAPI VarCat(LPVARIANT left, LPVARIANT right, LPVARIANT out) { VARTYPE leftvt,rightvt,resultvt; HRESULT hres; - static const WCHAR str_true[] = {'T','r','u','e','\0'}; - static const WCHAR str_false[] = {'F','a','l','s','e','\0'}; + static WCHAR str_true[32]; + static WCHAR str_false[32]; static const WCHAR sz_empty[] = {'\0'}; leftvt = V_VT(left); rightvt = V_VT(right); @@ -2476,6 +2477,11 @@ HRESULT WINAPI VarCat(LPVARIANT left, LPVARIANT right, LPVARIANT out) TRACE("(%p->(%s%s),%p->(%s%s),%p)\n", left, debugstr_VT(left), debugstr_VF(left), right, debugstr_VT(right), debugstr_VF(right), out); + if (!str_true[0]) { + VARIANT_GetLocalisedText(LOCALE_USER_DEFAULT, IDS_FALSE, str_false); + VARIANT_GetLocalisedText(LOCALE_USER_DEFAULT, IDS_TRUE, str_true); + } + /* when both left and right are NULL the result is NULL */ if (leftvt == VT_NULL && rightvt == VT_NULL) { @@ -2558,7 +2564,7 @@ HRESULT WINAPI VarCat(LPVARIANT left, LPVARIANT right, LPVARIANT out) { if (leftvt == VT_BOOL) { - /* Bools are handled as True/False strings instead of 0/-1 as in MSDN */ + /* Bools are handled as localized True/False strings instead of 0/-1 as in MSDN */ V_VT(&bstrvar_left) = VT_BSTR; if (V_BOOL(left) == TRUE) V_BSTR(&bstrvar_left) = SysAllocString(str_true); @@ -2598,7 +2604,7 @@ HRESULT WINAPI VarCat(LPVARIANT left, LPVARIANT right, LPVARIANT out) { if (rightvt == VT_BOOL) { - /* Bools are handled as True/False strings instead of 0/-1 as in MSDN */ + /* Bools are handled as localized True/False strings instead of 0/-1 as in MSDN */ V_VT(&bstrvar_right) = VT_BSTR; if (V_BOOL(right) == TRUE) V_BSTR(&bstrvar_right) = SysAllocString(str_true); diff --git a/dlls/oleaut32/variant.h b/dlls/oleaut32/variant.h index 41f8a9af6ee..c881b24d60f 100644 --- a/dlls/oleaut32/variant.h +++ b/dlls/oleaut32/variant.h @@ -123,3 +123,6 @@ typedef struct tagVARIANT_NUMBER_CHARS WCHAR cCurrencyDecimalPoint; WCHAR cCurrencyDigitSeparator; } VARIANT_NUMBER_CHARS; + + +BOOL VARIANT_GetLocalisedText(LANGID, DWORD, WCHAR *); diff --git a/dlls/oleaut32/vartype.c b/dlls/oleaut32/vartype.c index 7843a7b1862..2d5ae7d8ea4 100644 --- a/dlls/oleaut32/vartype.c +++ b/dlls/oleaut32/vartype.c @@ -5961,7 +5961,13 @@ HRESULT WINAPI VarBoolFromCy(CY cyIn, VARIANT_BOOL *pBoolOut) return S_OK; } -static BOOL VARIANT_GetLocalisedText(LANGID langId, DWORD dwId, WCHAR *lpszDest) +/************************************************************************ + * VARIANT_GetLocalisedText [internal] + * + * Get a localized string from the resources + * + */ +BOOL VARIANT_GetLocalisedText(LANGID langId, DWORD dwId, WCHAR *lpszDest) { HRSRC hrsrc;