Commit 72b86f96 authored by Jason Millard's avatar Jason Millard Committed by Alexandre Julliard

oleaut32: Fix VarAbs function for BSTR with positive values.

parent 23f0df42
......@@ -3145,6 +3145,14 @@ static void test_VarAbs(void)
hres = pVarAbs(&v,&vDst);
ok(hres == S_OK && V_VT(&vDst) == VT_R8 && V_R8(&vDst) == 1.1,
"VarAbs: expected 0x0,%d,%g, got 0x%lX,%d,%g\n", VT_R8, 1.1, hres, V_VT(&vDst), V_R8(&vDst));
V_VT(&v) = VT_BSTR;
V_BSTR(&v) = SysAllocString(L"30000");
memset(&vDst,0,sizeof(vDst));
hres = pVarAbs(&v,&vDst);
ok(hres == S_OK && V_VT(&vDst) == VT_R8 && V_R8(&vDst) == 30000.0,
"VarAbs: expected 0x0,%d,%g, got 0x%lX,%d,%g\n", VT_R8, 30000.0, hres, V_VT(&vDst), V_R8(&vDst));
SysFreeString(V_BSTR(&v));
}
static HRESULT (WINAPI *pVarNot)(LPVARIANT,LPVARIANT);
......
......@@ -4329,7 +4329,6 @@ VarOr_Exit:
*/
HRESULT WINAPI VarAbs(LPVARIANT pVarIn, LPVARIANT pVarOut)
{
VARIANT varIn;
HRESULT hRet = S_OK;
VARIANT temp;
......@@ -4373,11 +4372,10 @@ HRESULT WINAPI VarAbs(LPVARIANT pVarIn, LPVARIANT pVarOut)
if (V_R4(pVarOut) < 0.0) V_R4(pVarOut) = -V_R4(pVarOut);
break;
case VT_BSTR:
hRet = VarR8FromStr(V_BSTR(pVarIn), LOCALE_USER_DEFAULT, 0, &V_R8(&varIn));
hRet = VarR8FromStr(V_BSTR(pVarIn), LOCALE_USER_DEFAULT, 0, &V_R8(pVarOut));
if (FAILED(hRet))
break;
V_VT(pVarOut) = VT_R8;
pVarIn = &varIn;
/* Fall through ... */
case VT_DATE:
case VT_R8:
......
......@@ -1672,6 +1672,7 @@ Call ok(Abs(True) = 1, "Abs(True) = " & Abs(True))
Call ok(getVT(Abs(True)) = "VT_I2", "getVT(Abs(True)) = " & getVT(Abs(True)))
Call ok(Abs(CByte(1)) = 1, "Abs(CByte(1)) = " & Abs(CByte(1)))
Call ok(getVT(Abs(CByte(1))) = "VT_UI1", "getVT(Abs(CByte(1))) = " & getVT(Abs(CByte(1))))
Call ok(Abs("30000") = 30000, "Abs(""30000"") = " & Abs("30000"))
Sub testAbsError(strings, error_num1, error_num2)
on error resume next
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment