Jacek Caban : vbscript: Added Space() implementation.
Alexandre Julliard
julliard at winehq.org
Tue Sep 25 15:13:39 CDT 2012
Module: wine
Branch: master
Commit: 7308be6c0ad06a6d2b8384fcc8a9396556dcc0ef
URL: http://source.winehq.org/git/wine.git/?a=commit;h=7308be6c0ad06a6d2b8384fcc8a9396556dcc0ef
Author: Jacek Caban <jacek at codeweavers.com>
Date: Tue Sep 25 14:25:22 2012 +0200
vbscript: Added Space() implementation.
---
dlls/vbscript/global.c | 30 ++++++++++++++++++++++++++++--
dlls/vbscript/tests/api.vbs | 4 ++++
2 files changed, 32 insertions(+), 2 deletions(-)
diff --git a/dlls/vbscript/global.c b/dlls/vbscript/global.c
index 0513664..f7d8efe 100644
--- a/dlls/vbscript/global.c
+++ b/dlls/vbscript/global.c
@@ -672,8 +672,34 @@ static HRESULT Global_Trim(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARI
static HRESULT Global_Space(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
{
- FIXME("\n");
- return E_NOTIMPL;
+ BSTR str;
+ int n, i;
+ HRESULT hres;
+
+ TRACE("%s\n", debugstr_variant(arg));
+
+ hres = to_int(arg, &n);
+ if(FAILED(hres))
+ return hres;
+
+ if(n < 0) {
+ FIXME("n = %d\n", n);
+ return E_NOTIMPL;
+ }
+
+ if(!res)
+ return S_OK;
+
+ str = SysAllocStringLen(NULL, n);
+ if(!str)
+ return E_OUTOFMEMORY;
+
+ for(i=0; i<n; i++)
+ str[i] = ' ';
+
+ V_VT(res) = VT_BSTR;
+ V_BSTR(res) = str;
+ return S_OK;
}
static HRESULT Global_String(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 c17c5b4..2ad9404 100644
--- a/dlls/vbscript/tests/api.vbs
+++ b/dlls/vbscript/tests/api.vbs
@@ -179,4 +179,8 @@ Call ok(Len(1) = 1, "Len(1) = " & Len(1))
Call ok(isNull(Len(null)), "Len(null) = " & Len(null))
Call ok(Len(empty) = 0, "Len(empty) = " & Len(empty))
+Call ok(Space(1) = " ", "Space(1) = " & Space(1) & """")
+Call ok(Space(0) = "", "Space(0) = " & Space(0) & """")
+Call ok(Space(5) = " ", "Space(5) = " & Space(5) & """")
+
Call reportSuccess()
More information about the wine-cvs
mailing list