Michael Stefaniuc : vbscript: Use wide-char string literals.

Alexandre Julliard julliard at winehq.org
Mon Nov 16 15:28:56 CST 2020


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

Author: Michael Stefaniuc <mstefani at winehq.org>
Date:   Sun Nov 15 23:11:20 2020 +0100

vbscript: Use wide-char string literals.

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

---

 dlls/vbscript/compile.c  |  7 ++-----
 dlls/vbscript/global.c   | 52 +++++++++++++++++-------------------------------
 dlls/vbscript/interp.c   |  4 +---
 dlls/vbscript/lex.c      |  3 +--
 dlls/vbscript/vbregexp.c |  3 +--
 5 files changed, 23 insertions(+), 46 deletions(-)

diff --git a/dlls/vbscript/compile.c b/dlls/vbscript/compile.c
index 5c298ebe99a..0d1960d8ca1 100644
--- a/dlls/vbscript/compile.c
+++ b/dlls/vbscript/compile.c
@@ -1674,9 +1674,6 @@ static HRESULT compile_class(compile_ctx_t *ctx, class_decl_t *class_decl)
     unsigned i;
     HRESULT hres;
 
-    static const WCHAR class_initializeW[] = {'c','l','a','s','s','_','i','n','i','t','i','a','l','i','z','e',0};
-    static const WCHAR class_terminateW[] = {'c','l','a','s','s','_','t','e','r','m','i','n','a','t','e',0};
-
     if(lookup_dim_decls(ctx, class_decl->name) || lookup_funcs_name(ctx, class_decl->name)
             || lookup_const_decls(ctx, class_decl->name, FALSE) || lookup_class_name(ctx, class_decl->name)) {
         FIXME("%s: redefinition\n", debugstr_w(class_decl->name));
@@ -1722,14 +1719,14 @@ static HRESULT compile_class(compile_ctx_t *ctx, class_decl_t *class_decl)
             }
         }
 
-        if(!wcsicmp(class_initializeW, func_decl->name)) {
+        if(!wcsicmp(L"class_initialize", func_decl->name)) {
             if(func_decl->type != FUNC_SUB) {
                 FIXME("class initializer is not sub\n");
                 return E_FAIL;
             }
 
             class_desc->class_initialize_id = i;
-        }else  if(!wcsicmp(class_terminateW, func_decl->name)) {
+        }else  if(!wcsicmp(L"class_terminate", func_decl->name)) {
             if(func_decl->type != FUNC_SUB) {
                 FIXME("class terminator is not sub\n");
                 return E_FAIL;
diff --git a/dlls/vbscript/global.c b/dlls/vbscript/global.c
index 18504a43b9a..feab156c7b4 100644
--- a/dlls/vbscript/global.c
+++ b/dlls/vbscript/global.c
@@ -37,9 +37,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(vbscript);
 const GUID GUID_CUSTOM_CONFIRMOBJECTSAFETY =
     {0x10200490,0xfa38,0x11d0,{0xac,0x0e,0x00,0xa0,0xc9,0xf,0xff,0xc0}};
 
-static const WCHAR emptyW[] = {0};
-static const WCHAR vbscriptW[] = {'V','B','S','c','r','i','p','t',0};
-
 #define BP_GET      1
 #define BP_GETPUT   2
 
@@ -600,21 +597,21 @@ static HRESULT show_msgbox(script_ctx_t *ctx, BSTR prompt, unsigned type, BSTR o
         if(orig_title && *orig_title) {
             WCHAR *ptr;
 
-            title = title_buf = heap_alloc(sizeof(vbscriptW) + (lstrlenW(orig_title)+2)*sizeof(WCHAR));
+            title = title_buf = heap_alloc(sizeof(L"VBScript") + (lstrlenW(orig_title)+2)*sizeof(WCHAR));
             if(!title)
                 return E_OUTOFMEMORY;
 
-            memcpy(title_buf, vbscriptW, sizeof(vbscriptW));
-            ptr = title_buf + ARRAY_SIZE(vbscriptW)-1;
+            memcpy(title_buf, L"VBScript", sizeof(L"VBScript"));
+            ptr = title_buf + ARRAY_SIZE(L"VBScript")-1;
 
             *ptr++ = ':';
             *ptr++ = ' ';
             lstrcpyW(ptr, orig_title);
         }else {
-            title = vbscriptW;
+            title = L"VBScript";
         }
     }else {
-        title = orig_title ? orig_title : emptyW;
+        title = orig_title ? orig_title : L"";
     }
 
     hres = IActiveScriptSiteWindow_GetWindow(acts_window, &hwnd);
@@ -2203,19 +2200,6 @@ static HRESULT Global_DatePart(BuiltinDisp *This, VARIANT *arg, unsigned args_cn
 
 static HRESULT Global_TypeName(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 {
-    static const WCHAR ByteW[]     = {'B', 'y', 't', 'e', 0};
-    static const WCHAR IntegerW[]  = {'I', 'n', 't', 'e', 'g', 'e', 'r', 0};
-    static const WCHAR LongW[]     = {'L', 'o', 'n', 'g', 0};
-    static const WCHAR SingleW[]   = {'S', 'i', 'n', 'g', 'l', 'e', 0};
-    static const WCHAR DoubleW[]   = {'D', 'o', 'u', 'b', 'l', 'e', 0};
-    static const WCHAR CurrencyW[] = {'C', 'u', 'r', 'r', 'e', 'n', 'c', 'y', 0};
-    static const WCHAR DecimalW[]  = {'D', 'e', 'c', 'i', 'm', 'a', 'l', 0};
-    static const WCHAR DateW[]     = {'D', 'a', 't', 'e', 0};
-    static const WCHAR StringW[]   = {'S', 't', 'r', 'i', 'n', 'g', 0};
-    static const WCHAR BooleanW[]  = {'B', 'o', 'o', 'l', 'e', 'a', 'n', 0};
-    static const WCHAR EmptyW[]    = {'E', 'm', 'p', 't', 'y', 0};
-    static const WCHAR NullW[]     = {'N', 'u', 'l', 'l', 0};
-
     TRACE("(%s)\n", debugstr_variant(arg));
 
     assert(args_cnt == 1);
@@ -2225,29 +2209,29 @@ static HRESULT Global_TypeName(BuiltinDisp *This, VARIANT *arg, unsigned args_cn
 
     switch(V_VT(arg)) {
         case VT_UI1:
-            return return_string(res, ByteW);
+            return return_string(res, L"Byte");
         case VT_I2:
-            return return_string(res, IntegerW);
+            return return_string(res, L"Integer");
         case VT_I4:
-            return return_string(res, LongW);
+            return return_string(res, L"Long");
         case VT_R4:
-            return return_string(res, SingleW);
+            return return_string(res, L"Single");
         case VT_R8:
-            return return_string(res, DoubleW);
+            return return_string(res, L"Double");
         case VT_CY:
-            return return_string(res, CurrencyW);
+            return return_string(res, L"Currency");
         case VT_DECIMAL:
-            return return_string(res, DecimalW);
+            return return_string(res, L"Decimal");
         case VT_DATE:
-            return return_string(res, DateW);
+            return return_string(res, L"Date");
         case VT_BSTR:
-            return return_string(res, StringW);
+            return return_string(res, L"String");
         case VT_BOOL:
-            return return_string(res, BooleanW);
+            return return_string(res, L"Boolean");
         case VT_EMPTY:
-            return return_string(res, EmptyW);
+            return return_string(res, L"Empty");
         case VT_NULL:
-            return return_string(res, NullW);
+            return return_string(res, L"Null");
         default:
             FIXME("arg %s not supported\n", debugstr_variant(arg));
             return E_NOTIMPL;
@@ -2665,7 +2649,7 @@ static HRESULT Global_ScriptEngine(BuiltinDisp *This, VARIANT *arg, unsigned arg
 
     assert(args_cnt == 0);
 
-    return return_string(res, vbscriptW);
+    return return_string(res, L"VBScript");
 }
 
 static HRESULT Global_ScriptEngineMajorVersion(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
diff --git a/dlls/vbscript/interp.c b/dlls/vbscript/interp.c
index 40d1e961ccb..560d3b16e69 100644
--- a/dlls/vbscript/interp.c
+++ b/dlls/vbscript/interp.c
@@ -1127,11 +1127,9 @@ static HRESULT interp_new(exec_ctx_t *ctx)
     VARIANT v;
     HRESULT hres;
 
-    static const WCHAR regexpW[] = {'r','e','g','e','x','p',0};
-
     TRACE("%s\n", debugstr_w(arg));
 
-    if(!wcsicmp(arg, regexpW)) {
+    if(!wcsicmp(arg, L"regexp")) {
         V_VT(&v) = VT_DISPATCH;
         hres = create_regexp(&V_DISPATCH(&v));
         if(FAILED(hres))
diff --git a/dlls/vbscript/lex.c b/dlls/vbscript/lex.c
index 251374d90e6..e98ed98e194 100644
--- a/dlls/vbscript/lex.c
+++ b/dlls/vbscript/lex.c
@@ -337,8 +337,7 @@ static void skip_spaces(parser_ctx_t *ctx)
 
 static int comment_line(parser_ctx_t *ctx)
 {
-    static const WCHAR newlineW[] = {'\n','\r',0};
-    ctx->ptr = wcspbrk(ctx->ptr, newlineW);
+    ctx->ptr = wcspbrk(ctx->ptr, L"\n\r");
     if(ctx->ptr)
         ctx->ptr++;
     else
diff --git a/dlls/vbscript/vbregexp.c b/dlls/vbscript/vbregexp.c
index 49046bc7810..ddaadb0ce3f 100644
--- a/dlls/vbscript/vbregexp.c
+++ b/dlls/vbscript/vbregexp.c
@@ -52,10 +52,9 @@ static HRESULT init_regexp_typeinfo(regexp_tid_t tid)
     HRESULT hres;
 
     if(!typelib) {
-        static const WCHAR vbscript_dll3W[] = {'v','b','s','c','r','i','p','t','.','d','l','l','\\','3',0};
         ITypeLib *tl;
 
-        hres = LoadTypeLib(vbscript_dll3W, &tl);
+        hres = LoadTypeLib(L"vbscript.dll\\3", &tl);
         if(FAILED(hres)) {
             ERR("LoadRegTypeLib failed: %08x\n", hres);
             return hres;




More information about the wine-cvs mailing list