Commit 0708b77b authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

vbscript: Added UCase implementation.

parent 98c605d6
...@@ -122,6 +122,30 @@ static HRESULT to_int(VARIANT *v, int *ret) ...@@ -122,6 +122,30 @@ static HRESULT to_int(VARIANT *v, int *ret)
return S_OK; return S_OK;
} }
static HRESULT to_string(VARIANT *v, BSTR *ret)
{
static const WCHAR trueW[] = {'T','r','u','e',0};
static const WCHAR falseW[] = {'F','a','l','s','e',0};
switch(V_VT(v)) {
case VT_BOOL:
*ret = SysAllocString(V_BOOL(v) ? trueW : falseW);
return *ret ? S_OK : E_OUTOFMEMORY;
default: {
VARIANT dst;
HRESULT hres;
V_VT(&dst) = VT_EMPTY;
hres = VariantChangeTypeEx(&dst, v, MAKELCID(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),SORT_DEFAULT), 0, VT_BSTR);
if(FAILED(hres))
return hres;
*ret = V_BSTR(&dst);
return S_OK;
}
}
}
static IUnknown *create_object(script_ctx_t *ctx, const WCHAR *progid) static IUnknown *create_object(script_ctx_t *ctx, const WCHAR *progid)
{ {
IInternetHostSecurityManager *secmgr = NULL; IInternetHostSecurityManager *secmgr = NULL;
...@@ -564,8 +588,33 @@ static HRESULT Global_LCase(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VAR ...@@ -564,8 +588,33 @@ static HRESULT Global_LCase(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VAR
static HRESULT Global_UCase(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res) static HRESULT Global_UCase(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
{ {
FIXME("\n"); BSTR str;
return E_NOTIMPL; HRESULT hres;
TRACE("%s\n", debugstr_variant(arg));
if(V_VT(arg) == VT_NULL) {
if(res)
V_VT(res) = VT_NULL;
return S_OK;
}
hres = to_string(arg, &str);
if(FAILED(hres))
return hres;
if(res) {
WCHAR *ptr;
for(ptr = str; *ptr; ptr++)
*ptr = toupperW(*ptr);
V_VT(res) = VT_BSTR;
V_BSTR(res) = str;
}else {
SysFreeString(str);
}
return S_OK;
} }
static HRESULT Global_LTrim(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res) static HRESULT Global_LTrim(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
......
...@@ -145,4 +145,18 @@ TestMid2 "test", 2, "est" ...@@ -145,4 +145,18 @@ TestMid2 "test", 2, "est"
TestMid2 "test", 4, "t" TestMid2 "test", 4, "t"
TestMid2 "test", 5, "" TestMid2 "test", 5, ""
Sub TestUCase(str, ex)
x = UCase(str)
Call ok(x = ex, "UCase(" & str & ") = " & x & " expected " & ex)
End Sub
TestUCase "test", "TEST"
TestUCase "123aBC?", "123ABC?"
TestUCase "", ""
TestUCase 1, "1"
TestUCase true, "TRUE"
TestUCase 0.123, "0.123"
TestUCase Empty, ""
Call ok(getVT(UCase(Null)) = "VT_NULL", "getVT(UCase(Null)) = " & getVT(UCase(Null)))
Call reportSuccess() Call reportSuccess()
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