Jacek Caban : vbscript: Added Chr implementation.

Alexandre Julliard julliard at winehq.org
Mon Oct 15 14:29:06 CDT 2012


Module: wine
Branch: master
Commit: 02f6ea925ec898aaca72b80e473fb7ea100a3e5c
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=02f6ea925ec898aaca72b80e473fb7ea100a3e5c

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Mon Oct 15 11:15:51 2012 +0200

vbscript: Added Chr implementation.

---

 dlls/vbscript/global.c      |   25 +++++++++++++++++++++++--
 dlls/vbscript/tests/api.vbs |    4 ++++
 2 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/dlls/vbscript/global.c b/dlls/vbscript/global.c
index 7d60a49..4a4dd8e 100644
--- a/dlls/vbscript/global.c
+++ b/dlls/vbscript/global.c
@@ -1070,8 +1070,29 @@ static HRESULT Global_Asc(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIA
 
 static HRESULT Global_Chr(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 {
-    FIXME("\n");
-    return E_NOTIMPL;
+    int c;
+    HRESULT hres;
+
+    TRACE("%s\n", debugstr_variant(arg));
+
+    hres = to_int(arg, &c);
+    if(FAILED(hres))
+        return hres;
+
+    if(c <= 0 || c >= 0x100) {
+        FIXME("invalid arg\n");
+        return E_FAIL;
+    }
+
+    if(res) {
+        WCHAR ch = c;
+
+        V_VT(res) = VT_BSTR;
+        V_BSTR(res) = SysAllocStringLen(&ch, 1);
+        if(!V_BSTR(res))
+            return E_OUTOFMEMORY;
+    }
+    return S_OK;
 }
 
 static HRESULT Global_AscW(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 7ccbaa1..e986362 100644
--- a/dlls/vbscript/tests/api.vbs
+++ b/dlls/vbscript/tests/api.vbs
@@ -50,6 +50,10 @@ TestCStr 3, "3"
 if isEnglishLang then TestCStr 3.5, "3.5"
 if isEnglishLang then TestCStr true, "True"
 
+Call ok(getVT(Chr(120)) = "VT_BSTR", "getVT(Chr(120)) = " & getVT(Chr(120)))
+Call ok(getVT(Chr(255)) = "VT_BSTR", "getVT(Chr(255)) = " & getVT(Chr(255)))
+Call ok(Chr(120) = "x", "Chr(120) = " & Chr(120))
+
 Call ok(isObject(new EmptyClass), "isObject(new EmptyClass) is not true?")
 Set x = new EmptyClass
 Call ok(isObject(x), "isObject(x) is not true?")




More information about the wine-cvs mailing list