Jacek Caban : vbscript: Added support for comparing to null.

Alexandre Julliard julliard at winehq.org
Mon Sep 10 15:22:11 CDT 2012


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

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Mon Sep 10 10:35:17 2012 +0200

vbscript: Added support for comparing to null.

---

 dlls/vbscript/interp.c       |   30 ++++++++++++++++++++----------
 dlls/vbscript/tests/lang.vbs |   13 +++++++++++++
 2 files changed, 33 insertions(+), 10 deletions(-)

diff --git a/dlls/vbscript/interp.c b/dlls/vbscript/interp.c
index 28c1b14..3a078b5 100644
--- a/dlls/vbscript/interp.c
+++ b/dlls/vbscript/interp.c
@@ -279,6 +279,13 @@ static HRESULT stack_push(exec_ctx_t *ctx, VARIANT *v)
     return S_OK;
 }
 
+static inline HRESULT stack_push_null(exec_ctx_t *ctx)
+{
+    VARIANT v;
+    V_VT(&v) = VT_NULL;
+    return stack_push(ctx, &v);
+}
+
 static void stack_popn(exec_ctx_t *ctx, unsigned n)
 {
     while(n--)
@@ -1143,12 +1150,8 @@ static HRESULT interp_empty(exec_ctx_t *ctx)
 
 static HRESULT interp_null(exec_ctx_t *ctx)
 {
-    VARIANT v;
-
     TRACE("\n");
-
-    V_VT(&v) = VT_NULL;
-    return stack_push(ctx, &v);
+    return stack_push_null(ctx);
 }
 
 static HRESULT interp_nothing(exec_ctx_t *ctx)
@@ -1306,11 +1309,6 @@ static HRESULT var_cmp(exec_ctx_t *ctx, VARIANT *l, VARIANT *r)
 {
     TRACE("%s %s\n", debugstr_variant(l), debugstr_variant(r));
 
-    if(V_VT(l) == VT_NULL || V_VT(r) == VT_NULL) {
-        FIXME("comparing nulls is not implemented\n");
-        return E_NOTIMPL;
-    }
-
     /* FIXME: Fix comparing string to number */
 
     return VarCmp(l, r, ctx->script->lcid, 0);
@@ -1345,6 +1343,8 @@ static HRESULT interp_equal(exec_ctx_t *ctx)
     hres = cmp_oper(ctx);
     if(FAILED(hres))
         return hres;
+    if(hres == VARCMP_NULL)
+        return stack_push_null(ctx);
 
     V_VT(&v) = VT_BOOL;
     V_BOOL(&v) = hres == VARCMP_EQ ? VARIANT_TRUE : VARIANT_FALSE;
@@ -1361,6 +1361,8 @@ static HRESULT interp_nequal(exec_ctx_t *ctx)
     hres = cmp_oper(ctx);
     if(FAILED(hres))
         return hres;
+    if(hres == VARCMP_NULL)
+        return stack_push_null(ctx);
 
     V_VT(&v) = VT_BOOL;
     V_BOOL(&v) = hres != VARCMP_EQ ? VARIANT_TRUE : VARIANT_FALSE;
@@ -1377,6 +1379,8 @@ static HRESULT interp_gt(exec_ctx_t *ctx)
     hres = cmp_oper(ctx);
     if(FAILED(hres))
         return hres;
+    if(hres == VARCMP_NULL)
+        return stack_push_null(ctx);
 
     V_VT(&v) = VT_BOOL;
     V_BOOL(&v) = hres == VARCMP_GT ? VARIANT_TRUE : VARIANT_FALSE;
@@ -1393,6 +1397,8 @@ static HRESULT interp_gteq(exec_ctx_t *ctx)
     hres = cmp_oper(ctx);
     if(FAILED(hres))
         return hres;
+    if(hres == VARCMP_NULL)
+        return stack_push_null(ctx);
 
     V_VT(&v) = VT_BOOL;
     V_BOOL(&v) = hres == VARCMP_GT || hres == VARCMP_EQ ? VARIANT_TRUE : VARIANT_FALSE;
@@ -1409,6 +1415,8 @@ static HRESULT interp_lt(exec_ctx_t *ctx)
     hres = cmp_oper(ctx);
     if(FAILED(hres))
         return hres;
+    if(hres == VARCMP_NULL)
+        return stack_push_null(ctx);
 
     V_VT(&v) = VT_BOOL;
     V_BOOL(&v) = hres == VARCMP_LT ? VARIANT_TRUE : VARIANT_FALSE;
@@ -1425,6 +1433,8 @@ static HRESULT interp_lteq(exec_ctx_t *ctx)
     hres = cmp_oper(ctx);
     if(FAILED(hres))
         return hres;
+    if(hres == VARCMP_NULL)
+        return stack_push_null(ctx);
 
     V_VT(&v) = VT_BOOL;
     V_BOOL(&v) = hres == VARCMP_LT || hres == VARCMP_EQ ? VARIANT_TRUE : VARIANT_FALSE;
diff --git a/dlls/vbscript/tests/lang.vbs b/dlls/vbscript/tests/lang.vbs
index 2ba3e5a..3e105b6 100644
--- a/dlls/vbscript/tests/lang.vbs
+++ b/dlls/vbscript/tests/lang.vbs
@@ -144,6 +144,19 @@ Call ok(1 = 1 < 0, "! 1 = 1 < 0")
 Call ok(1 <= 2, "! 1 <= 2")
 Call ok(2 <= 2, "! 2 <= 2")
 
+Call ok(isNull(0 = null), "'(0 = null)' is not null")
+Call ok(isNull(null = 1), "'(null = 1)' is not null")
+Call ok(isNull(0 > null), "'(0 > null)' is not null")
+Call ok(isNull(null > 1), "'(null > 1)' is not null")
+Call ok(isNull(0 < null), "'(0 < null)' is not null")
+Call ok(isNull(null < 1), "'(null < 1)' is not null")
+Call ok(isNull(0 <> null), "'(0 <> null)' is not null")
+Call ok(isNull(null <> 1), "'(null <> 1)' is not null")
+Call ok(isNull(0 >= null), "'(0 >= null)' is not null")
+Call ok(isNull(null >= 1), "'(null >= 1)' is not null")
+Call ok(isNull(0 <= null), "'(0 <= null)' is not null")
+Call ok(isNull(null <= 1), "'(null <= 1)' is not null")
+
 x = 3
 Call ok(2+2 = 4, "2+2 = " & (2+2))
 Call ok(false + 6 + true = 5, "false + 6 + true <> 5")




More information about the wine-cvs mailing list