vbscript: Added RTrim implementation.

This commit is contained in:
Jacek Caban 2012-10-02 10:34:07 +02:00 committed by Alexandre Julliard
parent 71a4a1d43a
commit ed3d0e00ae
2 changed files with 35 additions and 2 deletions

View File

@ -879,8 +879,29 @@ static HRESULT Global_LTrim(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VAR
static HRESULT Global_RTrim(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
{
FIXME("\n");
return E_NOTIMPL;
BSTR str, conv_str = NULL;
WCHAR *ptr;
HRESULT hres;
TRACE("%s\n", debugstr_variant(arg));
if(V_VT(arg) == VT_BSTR) {
str = V_BSTR(arg);
}else {
hres = to_string(arg, &conv_str);
if(FAILED(hres))
return hres;
str = conv_str;
}
for(ptr = str+SysStringLen(str); ptr-1 > str && isspaceW(*(ptr-1)); ptr--);
str = SysAllocStringLen(str, ptr-str);
SysFreeString(conv_str);
if(!str)
return E_OUTOFMEMORY;
return return_bstr(res, str);
}
static HRESULT Global_Trim(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)

View File

@ -254,6 +254,18 @@ Sub TestRound(val, exval, vt)
Call ok(getVT(Round(val)) = vt, "getVT(Round(" & val & ")) = " & getVT(Round(val)))
End Sub
Sub TestRTrim(str, exstr)
Call ok(RTrim(str) = exstr, "RTrim(" & str & ") = " & RTrim(str))
End Sub
TestRTrim " test ", " test"
TestRTrim "test ", "test"
TestRTrim " test", " test"
TestRTrim "test", "test"
TestRTrim "", ""
TestRTrim 123, "123"
if isEnglishLang then TestRTrim true, "True"
TestRound 3, 3, "VT_I2"
TestRound 3.3, 3, "VT_R8"
TestRound 3.8, 4, "VT_R8"