Jacek Caban : vbscript: Don't convert hex literals ending with '&' to short in parse_hex_literal.

Alexandre Julliard julliard at winehq.org
Mon Feb 3 15:06:08 CST 2020


Module: wine
Branch: master
Commit: 8def4dfa0ee9c2d70fd4c98daa50447b6a15ad3c
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=8def4dfa0ee9c2d70fd4c98daa50447b6a15ad3c

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Mon Feb  3 19:57:03 2020 +0100

vbscript: Don't convert hex literals ending with '&' to short in parse_hex_literal.

Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/vbscript/global.c       | 6 +++---
 dlls/vbscript/lex.c          | 8 +++++---
 dlls/vbscript/tests/lang.vbs | 7 ++++++-
 3 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/dlls/vbscript/global.c b/dlls/vbscript/global.c
index d42091990b..a4442960d9 100644
--- a/dlls/vbscript/global.c
+++ b/dlls/vbscript/global.c
@@ -2793,7 +2793,7 @@ static const builtin_prop_t global_props[] = {
     {L"vbFormFeed",                NULL, BP_GET, VT_BSTR, (UINT_PTR)&vbFormFeed},
     {L"vbFriday",                  NULL, BP_GET, VT_I2, 6},
     {L"vbGeneralDate",             NULL, BP_GET, VT_I2, 0},
-    {L"vbGreen",                   NULL, BP_GET, VT_I4, (INT16)0x00ff00},
+    {L"vbGreen",                   NULL, BP_GET, VT_I4, 0x00ff00},
     {L"vbIgnore",                  NULL, BP_GET, VT_I2, IDIGNORE},
     {L"vbInformation",             NULL, BP_GET, VT_I2, MB_ICONASTERISK},
     {L"vbInteger",                 NULL, BP_GET, VT_I2, VT_I2},
@@ -2840,7 +2840,7 @@ static const builtin_prop_t global_props[] = {
     {L"vbVerticalTab",             NULL, BP_GET, VT_BSTR, (UINT_PTR)&vbVerticalTab},
     {L"vbWednesday",               NULL, BP_GET, VT_I2, 4},
     {L"vbWhite",                   NULL, BP_GET, VT_I4, 0xffffff},
-    {L"vbYellow",                  NULL, BP_GET, VT_I4, (INT16)0x00ffff},
+    {L"vbYellow",                  NULL, BP_GET, VT_I4, 0x00ffff},
     {L"vbYes",                     NULL, BP_GET, VT_I2, IDYES},
     {L"vbYesNo",                   NULL, BP_GET, VT_I2, MB_YESNO},
     {L"vbYesNoCancel",             NULL, BP_GET, VT_I2, MB_YESNOCANCEL},
@@ -2945,7 +2945,7 @@ static HRESULT Err_Raise(BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VA
     if(SUCCEEDED(hres)) {
         script_ctx_t *ctx = This->ctx;
 
-        error = (code == (INT16)code) ? MAKE_VBSERROR((UINT16)code) : map_hres(code);
+        error = (code & ~0xffff) ? map_hres(code) : MAKE_VBSERROR(code);
 
         if(source) {
             SysFreeString(ctx->ei.bstrSource);
diff --git a/dlls/vbscript/lex.c b/dlls/vbscript/lex.c
index f6070134f4..5b93739d02 100644
--- a/dlls/vbscript/lex.c
+++ b/dlls/vbscript/lex.c
@@ -320,10 +320,12 @@ static int parse_hex_literal(parser_ctx_t *ctx, LONG *ret)
         return 0;
     }
 
-    if(*ctx->ptr == '&')
+    if(*ctx->ptr == '&') {
         ctx->ptr++;
-
-    *ret = l == (UINT16)l ? (INT16)l : l;
+        *ret = l;
+    }else {
+        *ret = l == (UINT16)l ? (INT16)l : l;
+    }
     return tInt;
 }
 
diff --git a/dlls/vbscript/tests/lang.vbs b/dlls/vbscript/tests/lang.vbs
index 04e3cbfe91..c50b8bbe59 100644
--- a/dlls/vbscript/tests/lang.vbs
+++ b/dlls/vbscript/tests/lang.vbs
@@ -55,6 +55,9 @@ Call ok(&hff = 255, "&hff <> 255")
 Call ok(&Hff = 255, "&Hff <> 255")
 Call ok(&hffff = -1, "&hffff <> -1")
 Call ok(&hfffe = -2, "&hfffe <> -2")
+Call ok(&hffff& = 65535, "&hffff& <> -1")
+Call ok(&hfffe& = 65534, "&hfffe& <> -2")
+Call ok(&hffffffff& = -1, "&hffffffff& <> -1")
 
 W = 5
 Call ok(W = 5, "W = " & W & " expected " & 5)
@@ -90,7 +93,9 @@ Call ok(getVT(&h10&) = "VT_I2", "getVT(&h10&) is not VT_I2")
 Call ok(getVT(&h10000&) = "VT_I4", "getVT(&h10000&) is not VT_I4")
 Call ok(getVT(&H10000&) = "VT_I4", "getVT(&H10000&) is not VT_I4")
 Call ok(getVT(&hffFFffFF&) = "VT_I2", "getVT(&hffFFffFF&) is not VT_I2")
-Call ok(getVT(&hffFFffFE&) = "VT_I2", "getVT(&hffFFffFE   &) is not VT_I2")
+Call ok(getVT(&hffFFffFE&) = "VT_I2", "getVT(&hffFFffFE &) is not VT_I2")
+Call ok(getVT(&hffF&) = "VT_I2", "getVT(&hffFF&) is not VT_I2")
+Call ok(getVT(&hffFF&) = "VT_I4", "getVT(&hffFF&) is not VT_I4")
 Call ok(getVT(1e2) = "VT_R8", "getVT(1e2) is not VT_R8")
 Call ok(getVT(1e0) = "VT_R8", "getVT(1e0) is not VT_R8")
 Call ok(getVT(0.1e2) = "VT_R8", "getVT(0.1e2) is not VT_R8")




More information about the wine-cvs mailing list