Jacek Caban : vbscript: Added UCase implementation.
Alexandre Julliard
julliard at winehq.org
Wed Jul 11 17:39:20 CDT 2012
Module: wine
Branch: master
Commit: 0708b77b9b50a28e818562c727fa32e7d93e024a
URL: http://source.winehq.org/git/wine.git/?a=commit;h=0708b77b9b50a28e818562c727fa32e7d93e024a
Author: Jacek Caban <jacek at codeweavers.com>
Date: Wed Jul 11 10:23:22 2012 +0200
vbscript: Added UCase implementation.
---
dlls/vbscript/global.c | 53 +++++++++++++++++++++++++++++++++++++++++-
dlls/vbscript/tests/api.vbs | 14 +++++++++++
2 files changed, 65 insertions(+), 2 deletions(-)
diff --git a/dlls/vbscript/global.c b/dlls/vbscript/global.c
index eaf4383..a812d91 100644
--- a/dlls/vbscript/global.c
+++ b/dlls/vbscript/global.c
@@ -122,6 +122,30 @@ static HRESULT to_int(VARIANT *v, int *ret)
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)
{
IInternetHostSecurityManager *secmgr = NULL;
@@ -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)
{
- FIXME("\n");
- return E_NOTIMPL;
+ BSTR str;
+ 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)
diff --git a/dlls/vbscript/tests/api.vbs b/dlls/vbscript/tests/api.vbs
index 67c365d..fe6f9b0 100644
--- a/dlls/vbscript/tests/api.vbs
+++ b/dlls/vbscript/tests/api.vbs
@@ -145,4 +145,18 @@ TestMid2 "test", 2, "est"
TestMid2 "test", 4, "t"
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()
More information about the wine-cvs
mailing list