Wine-Devel
Threads by month
- ----- 2026 -----
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2003 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2002 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2001 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- 5 participants
- 84534 discussions
Nov. 30, 2020
Signed-off-by: Piotr Caban <piotr(a)codeweavers.com>
---
dlls/msvcr120/tests/msvcr120.c | 22 ++++++++--------------
1 file changed, 8 insertions(+), 14 deletions(-)
1
0
Nov. 30, 2020
Signed-off-by: Piotr Caban <piotr(a)codeweavers.com>
---
dlls/msvcr100/tests/msvcr100.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
1
0
Nov. 30, 2020
Signed-off-by: Piotr Caban <piotr(a)codeweavers.com>
---
dlls/msvcr90/tests/msvcr90.c | 27 ++++++++++-----------------
1 file changed, 10 insertions(+), 17 deletions(-)
1
0
Nov. 30, 2020
Signed-off-by: Piotr Caban <piotr(a)codeweavers.com>
---
dlls/msvcp140/tests/msvcp140.c | 358 +++++++++++++--------------------
1 file changed, 142 insertions(+), 216 deletions(-)
1
0
Nov. 30, 2020
Signed-off-by: Piotr Caban <piotr(a)codeweavers.com>
---
dlls/msvcp120/tests/msvcp120.c | 62 +++++++++++-----------------------
1 file changed, 20 insertions(+), 42 deletions(-)
1
0
Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org>
---
dlls/wbemdisp/locator.c | 16 ++++------
dlls/wbemdisp/main.c | 5 ++-
dlls/wbemdisp/tests/wbemdisp.c | 58 ++++++++++------------------------
3 files changed, 25 insertions(+), 54 deletions(-)
diff --git a/dlls/wbemdisp/locator.c b/dlls/wbemdisp/locator.c
index a9ef1618882..28c8e5b4120 100644
--- a/dlls/wbemdisp/locator.c
+++ b/dlls/wbemdisp/locator.c
@@ -436,14 +436,13 @@ static HRESULT WINAPI propertyset_Item( ISWbemPropertySet *iface, BSTR name,
static HRESULT WINAPI propertyset_get_Count( ISWbemPropertySet *iface, LONG *count )
{
- static const WCHAR propcountW[] = {'_','_','P','R','O','P','E','R','T','Y','_','C','O','U','N','T',0};
struct propertyset *propertyset = impl_from_ISWbemPropertySet( iface );
HRESULT hr;
VARIANT val;
TRACE( "%p, %p\n", propertyset, count );
- hr = IWbemClassObject_Get( propertyset->object, propcountW, 0, &val, NULL, NULL );
+ hr = IWbemClassObject_Get( propertyset->object, L"__PROPERTY_COUNT", 0, &val, NULL, NULL );
if (SUCCEEDED(hr))
{
*count = V_I4( &val );
@@ -1701,12 +1700,11 @@ static HRESULT WINAPI services_DeleteAsync(
static BSTR build_query_string( const WCHAR *class )
{
- static const WCHAR selectW[] = {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',0};
- UINT len = lstrlenW(class) + ARRAY_SIZE(selectW);
+ UINT len = lstrlenW(class) + ARRAY_SIZE(L"SELECT * FROM ");
BSTR ret;
if (!(ret = SysAllocStringLen( NULL, len ))) return NULL;
- lstrcpyW( ret, selectW );
+ lstrcpyW( ret, L"SELECT * FROM " );
lstrcatW( ret, class );
return ret;
}
@@ -1718,8 +1716,7 @@ static HRESULT WINAPI services_InstancesOf(
IDispatch *objWbemNamedValueSet,
ISWbemObjectSet **objWbemObjectSet )
{
- static const WCHAR wqlW[] = {'W','Q','L',0};
- BSTR query, wql = SysAllocString( wqlW );
+ BSTR query, wql = SysAllocString( L"WQL" );
HRESULT hr;
TRACE( "%p, %s, %x, %p, %p\n", iface, debugstr_w(strClass), iFlags, objWbemNamedValueSet,
@@ -2128,14 +2125,13 @@ static HRESULT WINAPI locator_Invoke(
static BSTR build_resource_string( BSTR server, BSTR namespace )
{
- static const WCHAR defaultW[] = {'r','o','o','t','\\','d','e','f','a','u','l','t',0};
ULONG len, len_server = 0, len_namespace = 0;
BSTR ret;
if (server && *server) len_server = lstrlenW( server );
else len_server = 1;
if (namespace && *namespace) len_namespace = lstrlenW( namespace );
- else len_namespace = ARRAY_SIZE(defaultW) - 1;
+ else len_namespace = ARRAY_SIZE(L"root\\default") - 1;
if (!(ret = SysAllocStringLen( NULL, 2 + len_server + 1 + len_namespace ))) return NULL;
@@ -2147,7 +2143,7 @@ static BSTR build_resource_string( BSTR server, BSTR namespace )
ret[len++] = '\\';
if (namespace && *namespace) lstrcpyW( ret + len, namespace );
- else lstrcpyW( ret + len, defaultW );
+ else lstrcpyW( ret + len, L"root\\default" );
return ret;
}
diff --git a/dlls/wbemdisp/main.c b/dlls/wbemdisp/main.c
index b3ee4de30cc..cfaf7d787eb 100644
--- a/dlls/wbemdisp/main.c
+++ b/dlls/wbemdisp/main.c
@@ -129,8 +129,7 @@ done:
static HRESULT WINAPI WinMGMTS_ParseDisplayName(IParseDisplayName *iface, IBindCtx *pbc, LPOLESTR pszDisplayName,
ULONG *pchEaten, IMoniker **ppmkOut)
{
- static const WCHAR prefixW[] = {'w','i','n','m','g','m','t','s',':',0};
- const DWORD prefix_len = ARRAY_SIZE(prefixW) - 1;
+ const DWORD prefix_len = ARRAY_SIZE(L"winmgmts:") - 1;
ISWbemLocator *locator = NULL;
ISWbemServices *services = NULL;
ISWbemObject *obj = NULL;
@@ -140,7 +139,7 @@ static HRESULT WINAPI WinMGMTS_ParseDisplayName(IParseDisplayName *iface, IBindC
TRACE( "%p, %p, %s, %p, %p\n", iface, pbc, debugstr_w(pszDisplayName), pchEaten, ppmkOut );
- if (wcsnicmp( pszDisplayName, prefixW, prefix_len )) return MK_E_SYNTAX;
+ if (wcsnicmp( pszDisplayName, L"winmgmts:", prefix_len )) return MK_E_SYNTAX;
p = pszDisplayName + prefix_len;
if (*p == '{')
diff --git a/dlls/wbemdisp/tests/wbemdisp.c b/dlls/wbemdisp/tests/wbemdisp.c
index 2bca6f9da67..fa51ce6d756 100644
--- a/dlls/wbemdisp/tests/wbemdisp.c
+++ b/dlls/wbemdisp/tests/wbemdisp.c
@@ -34,26 +34,10 @@ static const LCID english = MAKELCID(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US)
static void test_ParseDisplayName(void)
{
- static const WCHAR biosW[] = {'W','i','n','3','2','_','B','i','o','s',0};
- static const WCHAR manufacturerW[] = {'M','a','n','u','f','a','c','t','u','r','e','r',0};
- static const WCHAR versionW[] = {'v','e','r','s','i','o','n',0};
- static const WCHAR nosuchW[] = {'N','o','S','u','c','h',0};
- static const WCHAR name1[] =
- {'w','i','n','m','g','m','t','s',':',0};
- static const WCHAR name2[] =
- {'w','i','n','m','g','m','t','s',':','\\','\\','.','\\','r','o','o','t','\\','c','i','m','v','2',0};
- static const WCHAR name3[] =
- {'w','i','n','m','g','m','t','s',':','\\','\\','.','\\','r','o','o','t','\\','c','i','m','v','2',':',
- 'W','i','n','3','2','_','L','o','g','i','c','a','l','D','i','s','k','.',
- 'D','e','v','i','c','e','I','D','=','\'','C',':','\'',0};
- static const WCHAR name4[] =
- {'w','i','n','m','g','m','t','s',':','\\','\\','.','\\','r','o','o','t','\\','c','i','m','v','2',':',
- 'W','i','n','3','2','_','S','e','r','v','i','c','e',0};
- static const WCHAR stdregprovW[] =
- {'w','i','n','m','g','m','t','s',':','\\','\\','.','\\','r','o','o','t','\\','d','e','f','a','u','l','t',':',
- 'S','t','d','R','e','g','P','r','o','v',0};
- static const WCHAR getstringvalueW[] =
- {'G','e','t','S','t','r','i','n','g','V','a','l','u','e',0};
+ static const WCHAR name1[] = L"winmgmts:";
+ static const WCHAR name2[] = L"winmgmts:\\\\.\\root\\cimv2";
+ static const WCHAR name3[] = L"winmgmts:\\\\.\\root\\cimv2:Win32_LogicalDisk.DeviceID='C:'";
+ static const WCHAR name4[] = L"winmgmts:\\\\.\\root\\cimv2:Win32_Service";
static const struct
{
const WCHAR *name;
@@ -130,7 +114,7 @@ static void test_ParseDisplayName(void)
{
ISWbemObjectSet *objectset = NULL;
- str = SysAllocString( biosW );
+ str = SysAllocString( L"Win32_Bios" );
hr = ISWbemServices_InstancesOf( services, str, 0, NULL, &objectset );
SysFreeString( str );
ok( hr == S_OK, "got %x\n", hr );
@@ -174,28 +158,28 @@ static void test_ParseDisplayName(void)
ok( hr == S_OK, "got %x\n", hr );
ok( count == 1, "got %u\n", count );
- str = SysAllocString( manufacturerW );
+ str = SysAllocString( L"Manufacturer" );
dispid = 0xdeadbeef;
hr = IDispatch_GetIDsOfNames( dispatch, &IID_NULL, &str, 1, english, &dispid );
SysFreeString( str );
ok( hr == S_OK, "got %x\n", hr );
ok( dispid == 0x1800001 || dispid == 0x10b /* win2k */, "got %x\n", dispid );
- str = SysAllocString( versionW );
+ str = SysAllocString( L"version" );
dispid = 0xdeadbeef;
hr = IDispatch_GetIDsOfNames( dispatch, &IID_NULL, &str, 1, english, &dispid );
SysFreeString( str );
ok( hr == S_OK, "got %x\n", hr );
ok( dispid == 0x1800002 || dispid == 0x119 /* win2k */, "got %x\n", dispid );
- str = SysAllocString( nosuchW );
+ str = SysAllocString( L"NoSuch" );
dispid = 0xdeadbeef;
hr = IDispatch_GetIDsOfNames( dispatch, &IID_NULL, &str, 1, english, &dispid );
SysFreeString( str );
ok( hr == DISP_E_UNKNOWNNAME, "got %x\n", hr );
ok( dispid == DISPID_UNKNOWN, "got %x\n", dispid );
- str = SysAllocString( manufacturerW );
+ str = SysAllocString( L"Manufacturer" );
dispid = 0xdeadbeef;
hr = IDispatch_GetIDsOfNames( dispatch, &IID_NULL, &str, 1, english, &dispid );
SysFreeString( str );
@@ -261,7 +245,7 @@ static void test_ParseDisplayName(void)
hr = CreateBindCtx( 0, &ctx );
ok( hr == S_OK, "got %x\n", hr );
- str = SysAllocString( stdregprovW );
+ str = SysAllocString( L"winmgmts:\\\\.\\root\\default:StdRegProv" );
hr = IParseDisplayName_ParseDisplayName( displayname, NULL, str, &eaten, &moniker );
ok( hr == S_OK, "got %x\n", hr );
SysFreeString( str );
@@ -280,7 +264,7 @@ static void test_ParseDisplayName(void)
{
DISPID dispid = 0xdeadbeef;
- str = SysAllocString( getstringvalueW );
+ str = SysAllocString( L"GetStringValue" );
hr = ISWbemObject_GetIDsOfNames( sobj, &IID_NULL, &str, 1, english, &dispid );
ok( hr == S_OK, "got %x\n", hr );
ok( dispid == 0x1000001, "got %x\n", dispid );
@@ -295,14 +279,6 @@ static void test_ParseDisplayName(void)
IParseDisplayName_Release( displayname );
}
-static const WCHAR localhost[] = {'l','o','c','a','l','h','o','s','t',0};
-static const WCHAR root[] = {'r','o','o','t','\\','C','I','M','V','2',0};
-static const WCHAR query[] = {'S','e','l','e','c','t',' ','P','r','o','c','e','s','s','o','r','I','d',' ','f','r','o','m',
- ' ','W','i','n','3','2','_','P','r','o','c','e','s','s','o','r',0};
-static const WCHAR lang[] = {'W','Q','L',0};
-static const WCHAR props[] = {'P','r','o','p','e','r','t','i','e','s','_',0};
-static const WCHAR procid[] = {'P','r','o','c','e','s','s','o','r','I','d',0};
-
static void test_locator(void)
{
HRESULT hr;
@@ -324,15 +300,15 @@ static void test_locator(void)
hr = CoCreateInstance( &CLSID_SWbemLocator, NULL, CLSCTX_INPROC_SERVER, &IID_ISWbemLocator, (void **)&locator );
ok( hr == S_OK, "got %x\n", hr );
- host_bstr = SysAllocString(localhost);
- root_bstr = SysAllocString(root);
+ host_bstr = SysAllocString( L"localhost" );
+ root_bstr = SysAllocString( L"root\\CIMV2" );
hr = ISWbemLocator_ConnectServer( locator, host_bstr, root_bstr, NULL, NULL, NULL, NULL, 0, NULL, &services);
ok( hr == S_OK, "got %x\n", hr );
SysFreeString( root_bstr );
SysFreeString( host_bstr );
- query_bstr = SysAllocString(query);
- lang_bstr = SysAllocString(lang);
+ query_bstr = SysAllocString( L"Select ProcessorId from Win32_Processor" );
+ lang_bstr = SysAllocString( L"WQL" );
hr = ISWbemServices_ExecQuery( services, query_bstr, lang_bstr, wbemFlagForwardOnly, NULL, &object_set);
ok( hr == S_OK, "got %x\n", hr );
SysFreeString( lang_bstr );
@@ -374,7 +350,7 @@ static void test_locator(void)
ok( hr == S_OK, "got %x\n", hr );
ok( V_VT(&var) == VT_DISPATCH, "got %x\n", V_VT(&var));
- props_bstr = SysAllocString( props );
+ props_bstr = SysAllocString( L"Properties_" );
hr = IDispatch_GetIDsOfNames( V_DISPATCH(&var), &IID_NULL, &props_bstr, 1, english, &id );
ok( hr == S_OK, "got %x\n", hr );
ok( id == 21, "got %d\n", id );
@@ -390,7 +366,7 @@ static void test_locator(void)
ok( hr == WBEM_E_NOT_FOUND, "got %x\n", hr );
SysFreeString( props_bstr );
- procid_bstr = SysAllocString( procid );
+ procid_bstr = SysAllocString( L"ProcessorId" );
hr = ISWbemPropertySet_Item( prop_set, procid_bstr, 0, &prop );
ok( hr == S_OK, "got %x\n", hr );
SysFreeString( procid_bstr );
--
2.26.2
2
1
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=50206
Signed-off-by: Austin English <austinenglish(a)gmail.com>
---
configure | 2 ++
configure.ac | 1 +
dlls/dcomp/Makefile.in | 8 ++++++++
dlls/dcomp/dcomp.spec | 23 ++++++++++++++++++++++
dlls/dcomp/main.c | 44 ++++++++++++++++++++++++++++++++++++++++++
dlls/dcomp/version.rc | 26 +++++++++++++++++++++++++
6 files changed, 104 insertions(+)
create mode 100644 dlls/dcomp/Makefile.in
create mode 100644 dlls/dcomp/dcomp.spec
create mode 100644 dlls/dcomp/main.c
create mode 100644 dlls/dcomp/version.rc
diff --git a/configure b/configure
index e6596361ff1..9139ed9a247 100755
--- a/configure
+++ b/configure
@@ -1244,6 +1244,7 @@ enable_davclnt
enable_dbgeng
enable_dbghelp
enable_dciman32
+enable_dcomp
enable_ddraw
enable_ddrawex
enable_devenum
@@ -20413,6 +20414,7 @@ wine_fn_config_makefile dlls/dbgeng/tests enable_tests
wine_fn_config_makefile dlls/dbghelp enable_dbghelp
wine_fn_config_makefile dlls/dbghelp/tests enable_tests
wine_fn_config_makefile dlls/dciman32 enable_dciman32
+wine_fn_config_makefile dlls/dcomp enable_dcomp
wine_fn_config_makefile dlls/ddeml.dll16 enable_win16
wine_fn_config_makefile dlls/ddraw enable_ddraw
wine_fn_config_makefile dlls/ddraw/tests enable_tests
diff --git a/configure.ac b/configure.ac
index 705ab04295d..6b548b5ba56 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3192,6 +3192,7 @@ WINE_CONFIG_MAKEFILE(dlls/dbgeng/tests)
WINE_CONFIG_MAKEFILE(dlls/dbghelp)
WINE_CONFIG_MAKEFILE(dlls/dbghelp/tests)
WINE_CONFIG_MAKEFILE(dlls/dciman32)
+WINE_CONFIG_MAKEFILE(dlls/dcomp)
WINE_CONFIG_MAKEFILE(dlls/ddeml.dll16,enable_win16)
WINE_CONFIG_MAKEFILE(dlls/ddraw)
WINE_CONFIG_MAKEFILE(dlls/ddraw/tests)
diff --git a/dlls/dcomp/Makefile.in b/dlls/dcomp/Makefile.in
new file mode 100644
index 00000000000..6d75a87980f
--- /dev/null
+++ b/dlls/dcomp/Makefile.in
@@ -0,0 +1,8 @@
+MODULE = dcomp.dll
+
+EXTRADLLFLAGS = -mno-cygwin
+
+C_SRCS = \
+ main.c
+
+RC_SRCS = version.rc
diff --git a/dlls/dcomp/dcomp.spec b/dlls/dcomp/dcomp.spec
new file mode 100644
index 00000000000..10eb10c29ff
--- /dev/null
+++ b/dlls/dcomp/dcomp.spec
@@ -0,0 +1,23 @@
+@ stub DCOMP_1017
+@ stub CompileEffectDescription
+@ stub DCOMP_1019
+@ stub CreateEffectDescription
+@ stub DCompositionAttachMouseDragToHwnd
+@ stub DCompositionAttachMouseWheelToHwnd
+@ stub DCompositionCreateDevice2
+@ stub DCompositionCreateDevice3
+@ stub DCompositionCreateDevice
+@ stub DCompositionCreateSurfaceHandle
+@ stub DeserializeEffectDescription
+@ stub DCOMP_1028
+@ stub DllCanUnloadNow
+@ stub DllGetActivationFactory
+@ stub DCOMP_1031
+@ stub DllGetClassObject
+@ stub DCOMP_1033
+@ stub DwmEnableMMCSS
+@ stub DwmFlush
+@ stub DwmpEnableDDASupport
+@ stub SerializeEffectDescription
+@ stub DCOMP_1038
+@ stub DCOMP_1039
diff --git a/dlls/dcomp/main.c b/dlls/dcomp/main.c
new file mode 100644
index 00000000000..b0b911a9bf5
--- /dev/null
+++ b/dlls/dcomp/main.c
@@ -0,0 +1,44 @@
+/*
+ * DirectComposition Library
+ *
+ * Copyright 2020 Austin English
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+#include <stdarg.h>
+
+#include "windef.h"
+#include "winbase.h"
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(dcomp);
+
+BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
+{
+ TRACE("(0x%p, %d, %p)\n", hinstDLL, fdwReason, lpvReserved);
+
+ switch (fdwReason)
+ {
+ case DLL_WINE_PREATTACH:
+ return FALSE; /* prefer native version */
+ case DLL_PROCESS_ATTACH:
+ DisableThreadLibraryCalls(hinstDLL);
+ break;
+ default:
+ break;
+ }
+
+ return TRUE;
+}
diff --git a/dlls/dcomp/version.rc b/dlls/dcomp/version.rc
new file mode 100644
index 00000000000..a76f2675829
--- /dev/null
+++ b/dlls/dcomp/version.rc
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2020 Austin English
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#define WINE_FILEDESCRIPTION_STR "Wine dcomp"
+#define WINE_FILENAME_STR "dcomp.dll"
+#define WINE_FILEVERSION 10,0,14393,0
+#define WINE_FILEVERSION_STR "10.0.14393.0"
+#define WINE_PRODUCTVERSION 10,0,14393,0
+#define WINE_PRODUCTVERSION_STR "10.0.14393.0"
+
+#include "wine/wine_common_ver.rc"
--
2.28.0
1
0
[PATCH 1/4] qcap/tests: Add some tests for smart tee streaming using the strmbase infrastructure.
by Zebediah Figura Nov. 30, 2020
by Zebediah Figura Nov. 30, 2020
Nov. 30, 2020
Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com>
---
dlls/qcap/tests/smartteefilter.c | 268 ++++++++++++++++++++++++++++++-
1 file changed, 264 insertions(+), 4 deletions(-)
diff --git a/dlls/qcap/tests/smartteefilter.c b/dlls/qcap/tests/smartteefilter.c
index 1019fd3c1ba..bd51743de76 100644
--- a/dlls/qcap/tests/smartteefilter.c
+++ b/dlls/qcap/tests/smartteefilter.c
@@ -2278,6 +2278,9 @@ struct testfilter
struct strmbase_sink sink;
const AM_MEDIA_TYPE *sink_mt;
AM_MEDIA_TYPE source_mt;
+ HANDLE sample_event, eos_event, segment_event;
+ BOOL preview;
+ unsigned int got_begin_flush, got_end_flush;
};
static inline struct testfilter *impl_from_strmbase_filter(struct strmbase_filter *iface)
@@ -2298,6 +2301,9 @@ static struct strmbase_pin *testfilter_get_pin(struct strmbase_filter *iface, un
static void testfilter_destroy(struct strmbase_filter *iface)
{
struct testfilter *filter = impl_from_strmbase_filter(iface);
+ CloseHandle(filter->sample_event);
+ CloseHandle(filter->eos_event);
+ CloseHandle(filter->segment_event);
strmbase_source_cleanup(&filter->source);
strmbase_sink_cleanup(&filter->sink);
strmbase_filter_cleanup(&filter->filter);
@@ -2327,7 +2333,9 @@ static HRESULT testsource_get_media_type(struct strmbase_pin *iface, unsigned in
static void test_sink_allocator(IPin *pin)
{
- ALLOCATOR_PROPERTIES req_props = {1, 5000, 1, 0}, ret_props;
+ /* FIXME: We shouldn't need more than one sample, but Wine currently uses
+ * the same allocator for all three pins. */
+ ALLOCATOR_PROPERTIES req_props = {3, 256, 1, 0}, ret_props;
IMemAllocator *req_allocator, *ret_allocator;
IMemInputPin *input;
HRESULT hr;
@@ -2359,9 +2367,6 @@ static void test_sink_allocator(IPin *pin)
hr = IMemAllocator_SetProperties(req_allocator, &req_props, &ret_props);
ok(hr == S_OK, "Got hr %#x.\n", hr);
- hr = IMemAllocator_Commit(req_allocator);
- ok(hr == S_OK, "Got hr %#x.\n", hr);
-
IMemAllocator_Release(req_allocator);
IMemInputPin_Release(input);
}
@@ -2429,6 +2434,88 @@ static HRESULT testsink_get_media_type(struct strmbase_pin *iface, unsigned int
static HRESULT WINAPI testsink_Receive(struct strmbase_sink *iface, IMediaSample *sample)
{
+ struct testfilter *filter = impl_from_strmbase_filter(iface->pin.filter);
+ REFERENCE_TIME start, stop;
+ BYTE *data, expect[200];
+ LONG size, i;
+ HRESULT hr;
+
+ size = IMediaSample_GetSize(sample);
+ ok(size == 256, "Got size %u.\n", size);
+ size = IMediaSample_GetActualDataLength(sample);
+ ok(size == 200, "Got valid size %u.\n", size);
+
+ hr = IMediaSample_GetPointer(sample, &data);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ for (i = 0; i < size; ++i)
+ expect[i] = i;
+ ok(!memcmp(data, expect, size), "Data didn't match.\n");
+
+ hr = IMediaSample_GetTime(sample, &start, &stop);
+ if (filter->preview)
+ {
+ ok(hr == VFW_E_SAMPLE_TIME_NOT_SET, "Got hr %#x.\n", hr);
+ }
+ else
+ {
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ ok(start == 30000, "Got start time %s.\n", wine_dbgstr_longlong(start));
+ ok(stop == 40000, "Got stop time %s.\n", wine_dbgstr_longlong(stop));
+ }
+
+ hr = IMediaSample_GetMediaTime(sample, &start, &stop);
+ if (filter->preview)
+ {
+ todo_wine ok(hr == VFW_E_MEDIA_TIME_NOT_SET, "Got hr %#x.\n", hr);
+ }
+ else
+ {
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ ok(start == 10000, "Got start time %s.\n", wine_dbgstr_longlong(start));
+ ok(stop == 20000, "Got stop time %s.\n", wine_dbgstr_longlong(stop));
+ }
+
+ hr = IMediaSample_IsDiscontinuity(sample);
+ todo_wine_if (filter->preview) ok(hr == filter->preview ? S_FALSE : S_OK, "Got hr %#x.\n", hr);
+ hr = IMediaSample_IsPreroll(sample);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ hr = IMediaSample_IsSyncPoint(sample);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+ SetEvent(filter->sample_event);
+
+ return S_OK;
+}
+
+static HRESULT testsink_new_segment(struct strmbase_sink *iface,
+ REFERENCE_TIME start, REFERENCE_TIME stop, double rate)
+{
+ struct testfilter *filter = impl_from_strmbase_filter(iface->pin.filter);
+ ok(start == 10000, "Got start %s.\n", wine_dbgstr_longlong(start));
+ ok(stop == 20000, "Got stop %s.\n", wine_dbgstr_longlong(stop));
+ ok(rate == 1.0, "Got rate %.16e.\n", rate);
+ SetEvent(filter->segment_event);
+ return S_OK;
+}
+
+static HRESULT testsink_eos(struct strmbase_sink *iface)
+{
+ struct testfilter *filter = impl_from_strmbase_filter(iface->pin.filter);
+ SetEvent(filter->eos_event);
+ return S_OK;
+}
+
+static HRESULT testsink_begin_flush(struct strmbase_sink *iface)
+{
+ struct testfilter *filter = impl_from_strmbase_filter(iface->pin.filter);
+ ++filter->got_begin_flush;
+ return S_OK;
+}
+
+static HRESULT testsink_end_flush(struct strmbase_sink *iface)
+{
+ struct testfilter *filter = impl_from_strmbase_filter(iface->pin.filter);
+ ++filter->got_end_flush;
return S_OK;
}
@@ -2438,6 +2525,10 @@ static const struct strmbase_sink_ops testsink_ops =
.base.pin_query_accept = testsink_query_accept,
.base.pin_get_media_type = testsink_get_media_type,
.pfnReceive = testsink_Receive,
+ .sink_new_segment = testsink_new_segment,
+ .sink_eos = testsink_eos,
+ .sink_begin_flush = testsink_begin_flush,
+ .sink_end_flush = testsink_end_flush,
};
static void testfilter_init(struct testfilter *filter)
@@ -2447,6 +2538,9 @@ static void testfilter_init(struct testfilter *filter)
strmbase_filter_init(&filter->filter, NULL, &clsid, &testfilter_ops);
strmbase_source_init(&filter->source, &filter->filter, L"source", &testsource_ops);
strmbase_sink_init(&filter->sink, &filter->filter, L"sink", &testsink_ops, NULL);
+ filter->sample_event = CreateEventW(NULL, FALSE, FALSE, NULL);
+ filter->segment_event = CreateEventW(NULL, FALSE, FALSE, NULL);
+ filter->eos_event = CreateEventW(NULL, FALSE, FALSE, NULL);
}
static void test_source_media_types(AM_MEDIA_TYPE req_mt, const AM_MEDIA_TYPE *source_mt, IPin *source)
@@ -2791,6 +2885,171 @@ static void test_connect_pin(void)
ok(!ref, "Got outstanding refcount %d.\n", ref);
}
+static void test_streaming(void)
+{
+ static const AM_MEDIA_TYPE req_mt =
+ {
+ .majortype = {0x111},
+ .subtype = {0x222},
+ .formattype = {0x333},
+ };
+ IBaseFilter *filter = create_smart_tee();
+ struct testfilter testsource, testsink1, testsink2;
+ IPin *sink, *capture, *preview;
+ REFERENCE_TIME start, stop;
+ IMemAllocator *allocator;
+ IMediaControl *control;
+ IFilterGraph2 *graph;
+ IMediaSample *sample;
+ IMemInputPin *input;
+ LONG size, i;
+ HRESULT hr;
+ BYTE *data;
+ ULONG ref;
+
+ testfilter_init(&testsource);
+ testfilter_init(&testsink1);
+ testfilter_init(&testsink2);
+ testsink2.preview = TRUE;
+ CoCreateInstance(&CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER,
+ &IID_IFilterGraph2, (void **)&graph);
+ IFilterGraph2_AddFilter(graph, &testsource.filter.IBaseFilter_iface, L"source");
+ IFilterGraph2_AddFilter(graph, &testsink1.filter.IBaseFilter_iface, L"sink1");
+ IFilterGraph2_AddFilter(graph, &testsink2.filter.IBaseFilter_iface, L"sink2");
+ IFilterGraph2_AddFilter(graph, filter, L"sample grabber");
+ IFilterGraph2_QueryInterface(graph, &IID_IMediaControl, (void **)&control);
+ IBaseFilter_FindPin(filter, L"Input", &sink);
+ IPin_QueryInterface(sink, &IID_IMemInputPin, (void **)&input);
+ IBaseFilter_FindPin(filter, L"Capture", &capture);
+ IBaseFilter_FindPin(filter, L"Preview", &preview);
+
+ hr = IFilterGraph2_ConnectDirect(graph, &testsource.source.pin.IPin_iface, sink, &req_mt);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ hr = IFilterGraph2_ConnectDirect(graph, capture, &testsink1.sink.pin.IPin_iface, &req_mt);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ hr = IFilterGraph2_ConnectDirect(graph, preview, &testsink2.sink.pin.IPin_iface, &req_mt);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+ hr = IMemInputPin_ReceiveCanBlock(input);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+ hr = IMemInputPin_GetAllocator(input, &allocator);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+ hr = IMemAllocator_GetBuffer(allocator, &sample, NULL, NULL, 0);
+ ok(hr == VFW_E_NOT_COMMITTED, "Got hr %#x.\n", hr);
+
+ hr = IMediaControl_Pause(control);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+ hr = IMemAllocator_GetBuffer(allocator, &sample, NULL, NULL, 0);
+ todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr);
+ if (hr != S_OK)
+ {
+ IMemAllocator_Commit(allocator);
+ hr = IMemAllocator_GetBuffer(allocator, &sample, NULL, NULL, 0);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ }
+
+ hr = IMediaSample_GetPointer(sample, &data);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ size = IMediaSample_GetSize(sample);
+ ok(size == 256, "Got size %d.\n", size);
+ for (i = 0; i < 200; ++i)
+ data[i] = i;
+ hr = IMediaSample_SetActualDataLength(sample, 200);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+ start = 10000;
+ stop = 20000;
+ hr = IMediaSample_SetMediaTime(sample, &start, &stop);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ start = 30000;
+ stop = 40000;
+ hr = IMediaSample_SetTime(sample, &start, &stop);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ hr = IMediaSample_SetDiscontinuity(sample, TRUE);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ hr = IMediaSample_SetPreroll(sample, TRUE);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ hr = IMediaSample_SetSyncPoint(sample, TRUE);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+ hr = IMemInputPin_Receive(input, sample);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ ok(!WaitForSingleObject(testsink1.sample_event, 1000), "Wait timed out.\n");
+ ok(!WaitForSingleObject(testsink2.sample_event, 1000), "Wait timed out.\n");
+
+ hr = IPin_NewSegment(sink, 10000, 20000, 1.0);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ ok(!WaitForSingleObject(testsink1.segment_event, 1000), "Wait timed out.\n");
+ ok(!WaitForSingleObject(testsink2.segment_event, 1000), "Wait timed out.\n");
+
+ hr = IPin_EndOfStream(sink);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ ok(!WaitForSingleObject(testsink1.eos_event, 1000), "Wait timed out.\n");
+ ok(!WaitForSingleObject(testsink2.eos_event, 1000), "Wait timed out.\n");
+
+ hr = IPin_EndOfStream(sink);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ ok(!WaitForSingleObject(testsink1.eos_event, 1000), "Wait timed out.\n");
+ ok(!WaitForSingleObject(testsink2.eos_event, 1000), "Wait timed out.\n");
+
+ ok(!testsink1.got_begin_flush, "Got %u calls to IPin::BeginFlush().\n", testsink1.got_begin_flush);
+ ok(!testsink2.got_begin_flush, "Got %u calls to IPin::BeginFlush().\n", testsink2.got_begin_flush);
+ hr = IPin_BeginFlush(sink);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ ok(testsink1.got_begin_flush == 1, "Got %u calls to IPin::BeginFlush().\n", testsink1.got_begin_flush);
+ ok(testsink2.got_begin_flush == 1, "Got %u calls to IPin::BeginFlush().\n", testsink2.got_begin_flush);
+
+ hr = IMemInputPin_Receive(input, sample);
+ todo_wine ok(hr == S_FALSE, "Got hr %#x.\n", hr);
+
+ hr = IPin_EndOfStream(sink);
+ todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr);
+ /* No EOS events are sent downstream, however. */
+
+ ok(!testsink1.got_end_flush, "Got %u calls to IPin::EndFlush().\n", testsink1.got_end_flush);
+ ok(!testsink2.got_end_flush, "Got %u calls to IPin::EndFlush().\n", testsink2.got_end_flush);
+ hr = IPin_EndFlush(sink);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ ok(testsink1.got_end_flush == 1, "Got %u calls to IPin::EndFlush().\n", testsink1.got_end_flush);
+ ok(testsink2.got_end_flush == 1, "Got %u calls to IPin::EndFlush().\n", testsink2.got_end_flush);
+
+ hr = IMemInputPin_Receive(input, sample);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ ok(!WaitForSingleObject(testsink1.sample_event, 1000), "Wait timed out.\n");
+ ok(!WaitForSingleObject(testsink2.sample_event, 1000), "Wait timed out.\n");
+
+ hr = IMediaControl_Stop(control);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+ hr = IMemInputPin_Receive(input, sample);
+ todo_wine ok(hr == VFW_E_WRONG_STATE, "Got hr %#x.\n", hr);
+
+ hr = IPin_EndOfStream(sink);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ /* No EOS events are sent downstream, however. */
+
+ IMediaSample_Release(sample);
+ IMemAllocator_Release(allocator);
+ IMemInputPin_Release(input);
+ IPin_Release(sink);
+ IPin_Release(capture);
+ IPin_Release(preview);
+ IMediaControl_Release(control);
+ ref = IFilterGraph2_Release(graph);
+ ok(!ref, "Got outstanding refcount %d.\n", ref);
+ ref = IBaseFilter_Release(filter);
+ ok(!ref, "Got outstanding refcount %d.\n", ref);
+ ref = IBaseFilter_Release(&testsource.filter.IBaseFilter_iface);
+ ok(!ref, "Got outstanding refcount %d.\n", ref);
+ ref = IBaseFilter_Release(&testsink1.filter.IBaseFilter_iface);
+ ok(!ref, "Got outstanding refcount %d.\n", ref);
+ ref = IBaseFilter_Release(&testsink2.filter.IBaseFilter_iface);
+ ok(!ref, "Got outstanding refcount %d.\n", ref);
+}
+
START_TEST(smartteefilter)
{
CoInitialize(NULL);
@@ -2805,6 +3064,7 @@ START_TEST(smartteefilter)
test_enum_media_types();
test_unconnected_filter_state();
test_connect_pin();
+ test_streaming();
test_smart_tee_filter();
--
2.29.2
1
3
Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org>
---
programs/cmd/directory.c | 21 +++----
programs/cmd/wcmdmain.c | 116 +++++++++++++--------------------------
2 files changed, 46 insertions(+), 91 deletions(-)
diff --git a/programs/cmd/directory.c b/programs/cmd/directory.c
index df3ed4387ee..24b18bfa81b 100644
--- a/programs/cmd/directory.c
+++ b/programs/cmd/directory.c
@@ -252,11 +252,6 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le
int concurrentDirs = 0;
BOOL done_header = FALSE;
- static const WCHAR fmt2[] = {'%','1','!','-','1','3','s','!','\0'};
- static const WCHAR fmt3[] = {'%','1','!','-','2','3','s','!','\0'};
- static const WCHAR fmt4[] = {'%','1','\0'};
- static const WCHAR fmt5[] = {'%','1','%','2','\0'};
-
dir_count = 0;
file_count = 0;
entry_count = 0;
@@ -405,13 +400,13 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le
if (!bare) {
WCMD_output (L"%1!10s! %2!8s! <DIR> ", datestring, timestring);
- if (shortname) WCMD_output (fmt2, fd[i].cAlternateFileName);
- if (usernames) WCMD_output (fmt3, username);
- WCMD_output(fmt4,fd[i].cFileName);
+ if (shortname) WCMD_output(L"%1!-13s!", fd[i].cAlternateFileName);
+ if (usernames) WCMD_output(L"%1!-23s!", username);
+ WCMD_output(L"%1",fd[i].cFileName);
} else {
if (!((lstrcmpW(fd[i].cFileName, L".") == 0) ||
(lstrcmpW(fd[i].cFileName, L"..") == 0))) {
- WCMD_output(fmt5, recurse?inputparms->dirName:L"", fd[i].cFileName);
+ WCMD_output(L"%1%2", recurse ? inputparms->dirName : L"", fd[i].cFileName);
} else {
addNewLine = FALSE;
}
@@ -425,11 +420,11 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le
if (!bare) {
WCMD_output (L"%1!10s! %2!8s! %3!10s! ", datestring, timestring,
WCMD_filesize64(file_size.QuadPart));
- if (shortname) WCMD_output (fmt2, fd[i].cAlternateFileName);
- if (usernames) WCMD_output (fmt3, username);
- WCMD_output(fmt4,fd[i].cFileName);
+ if (shortname) WCMD_output(L"%1!-13s!", fd[i].cAlternateFileName);
+ if (usernames) WCMD_output(L"%1!-23s!", username);
+ WCMD_output(L"%1",fd[i].cFileName);
} else {
- WCMD_output(fmt5, recurse ? inputparms->dirName : L"", fd[i].cFileName);
+ WCMD_output(L"%1%2", recurse ? inputparms->dirName : L"", fd[i].cFileName);
}
}
}
diff --git a/programs/cmd/wcmdmain.c b/programs/cmd/wcmdmain.c
index 3484f05ae73..cacb7ea7751 100644
--- a/programs/cmd/wcmdmain.c
+++ b/programs/cmd/wcmdmain.c
@@ -46,11 +46,6 @@ int defaultColor = 7;
BOOL echo_mode = TRUE;
WCHAR anykey[100], version_string[100];
-static const WCHAR envPathExt[] = {'P','A','T','H','E','X','T','\0'};
-static const WCHAR dfltPathExt[] = {'.','b','a','t',';',
- '.','c','o','m',';',
- '.','c','m','d',';',
- '.','e','x','e','\0'};
static BOOL opt_c, opt_k, opt_s, unicodeOutput = FALSE;
@@ -334,12 +329,10 @@ static void WCMD_show_prompt (BOOL newLine) {
WCHAR out_string[MAX_PATH], curdir[MAX_PATH], prompt_string[MAX_PATH];
WCHAR *p, *q;
DWORD len;
- static const WCHAR envPrompt[] = {'P','R','O','M','P','T','\0'};
- len = GetEnvironmentVariableW(envPrompt, prompt_string, ARRAY_SIZE(prompt_string));
+ len = GetEnvironmentVariableW(L"PROMPT", prompt_string, ARRAY_SIZE(prompt_string));
if ((len == 0) || (len >= ARRAY_SIZE(prompt_string))) {
- static const WCHAR dfltPrompt[] = {'$','P','$','G','\0'};
- lstrcpyW (prompt_string, dfltPrompt);
+ lstrcpyW(prompt_string, L"$P$G");
}
p = prompt_string;
q = out_string;
@@ -554,13 +547,7 @@ static WCHAR *WCMD_expand_envvar(WCHAR *start, WCHAR startchar)
WCHAR thisVarContents[MAXSTRING];
WCHAR savedchar = 0x00;
int len;
-
- static const WCHAR ErrorLvl[] = {'E','R','R','O','R','L','E','V','E','L','\0'};
- static const WCHAR Date[] = {'D','A','T','E','\0'};
- static const WCHAR Time[] = {'T','I','M','E','\0'};
- static const WCHAR Cd[] = {'C','D','\0'};
- static const WCHAR Random[] = {'R','A','N','D','O','M','\0'};
- WCHAR Delims[] = {'%',':','\0'}; /* First char gets replaced appropriately */
+ WCHAR Delims[] = L"%:"; /* First char gets replaced appropriately */
WINE_TRACE("Expanding: %s (%c)\n", wine_dbgstr_w(start), startchar);
@@ -614,24 +601,22 @@ static WCHAR *WCMD_expand_envvar(WCHAR *start, WCHAR startchar)
/* Expand to contents, if unchanged, return */
/* Handle DATE, TIME, ERRORLEVEL and CD replacements allowing */
/* override if existing env var called that name */
- if (WCMD_is_magic_envvar(thisVar, ErrorLvl)) {
- static const WCHAR fmt[] = {'%','d','\0'};
- wsprintfW(thisVarContents, fmt, errorlevel);
+ if (WCMD_is_magic_envvar(thisVar, L"ERRORLEVEL")) {
+ wsprintfW(thisVarContents, L"%d", errorlevel);
len = lstrlenW(thisVarContents);
- } else if (WCMD_is_magic_envvar(thisVar, Date)) {
+ } else if (WCMD_is_magic_envvar(thisVar, L"DATE")) {
GetDateFormatW(LOCALE_USER_DEFAULT, DATE_SHORTDATE, NULL,
NULL, thisVarContents, MAXSTRING);
len = lstrlenW(thisVarContents);
- } else if (WCMD_is_magic_envvar(thisVar, Time)) {
+ } else if (WCMD_is_magic_envvar(thisVar, L"TIME")) {
GetTimeFormatW(LOCALE_USER_DEFAULT, TIME_NOSECONDS, NULL,
NULL, thisVarContents, MAXSTRING);
len = lstrlenW(thisVarContents);
- } else if (WCMD_is_magic_envvar(thisVar, Cd)) {
+ } else if (WCMD_is_magic_envvar(thisVar, L"CD")) {
GetCurrentDirectoryW(MAXSTRING, thisVarContents);
len = lstrlenW(thisVarContents);
- } else if (WCMD_is_magic_envvar(thisVar, Random)) {
- static const WCHAR fmt[] = {'%','d','\0'};
- wsprintfW(thisVarContents, fmt, rand() % 32768);
+ } else if (WCMD_is_magic_envvar(thisVar, L"RANDOM")) {
+ wsprintfW(thisVarContents, L"%d", rand() % 32768);
len = lstrlenW(thisVarContents);
} else {
@@ -1042,8 +1027,6 @@ void WCMD_run_program (WCHAR *command, BOOL called)
BOOL explicit_path = FALSE;
BOOL status;
DWORD len;
- static const WCHAR envPath[] = {'P','A','T','H','\0'};
- static const WCHAR delims[] = {'/','\\',':','\0'};
/* Quick way to get the filename is to extract the first argument. */
WINE_TRACE("Running '%s' (%d)\n", wine_dbgstr_w(command), called);
@@ -1056,13 +1039,11 @@ void WCMD_run_program (WCHAR *command, BOOL called)
}
/* Calculate the search path and stem to search for */
- if (wcspbrk (firstParam, delims) == NULL) { /* No explicit path given, search path */
- static const WCHAR curDir[] = {'.',';','\0'};
- lstrcpyW(pathtosearch, curDir);
- len = GetEnvironmentVariableW(envPath, &pathtosearch[2], ARRAY_SIZE(pathtosearch)-2);
+ if (wcspbrk(firstParam, L"/\\:") == NULL) { /* No explicit path given, search path */
+ lstrcpyW(pathtosearch, L".;");
+ len = GetEnvironmentVariableW(L"PATH", &pathtosearch[2], ARRAY_SIZE(pathtosearch)-2);
if ((len == 0) || (len >= ARRAY_SIZE(pathtosearch) - 2)) {
- static const WCHAR curDir[] = {'.','\0'};
- lstrcpyW (pathtosearch, curDir);
+ lstrcpyW(pathtosearch, L".");
}
if (wcschr(firstParam, '.') != NULL) extensionsupplied = TRUE;
if (lstrlenW(firstParam) >= MAX_PATH)
@@ -1088,9 +1069,9 @@ void WCMD_run_program (WCHAR *command, BOOL called)
}
/* Now extract PATHEXT */
- len = GetEnvironmentVariableW(envPathExt, pathext, ARRAY_SIZE(pathext));
+ len = GetEnvironmentVariableW(L"PATHEXT", pathext, ARRAY_SIZE(pathext));
if ((len == 0) || (len >= ARRAY_SIZE(pathext))) {
- lstrcpyW (pathext, dfltPathExt);
+ lstrcpyW(pathext, L".bat;.com;.cmd;.exe");
}
/* Loop through the search path, dir by dir */
@@ -1163,9 +1144,8 @@ void WCMD_run_program (WCHAR *command, BOOL called)
if (!found) {
HANDLE h;
WIN32_FIND_DATAW finddata;
- static const WCHAR allFiles[] = {'.','*','\0'};
- lstrcatW(thisDir,allFiles);
+ lstrcatW(thisDir, L".*");
h = FindFirstFileW(thisDir, &finddata);
FindClose(h);
if (h != INVALID_HANDLE_VALUE) {
@@ -1201,13 +1181,11 @@ void WCMD_run_program (WCHAR *command, BOOL called)
DWORD console;
HINSTANCE hinst;
WCHAR *ext = wcsrchr( thisDir, '.' );
- static const WCHAR batExt[] = {'.','b','a','t','\0'};
- static const WCHAR cmdExt[] = {'.','c','m','d','\0'};
WINE_TRACE("Found as %s\n", wine_dbgstr_w(thisDir));
/* Special case BAT and CMD */
- if (ext && (!wcsicmp(ext, batExt) || !wcsicmp(ext, cmdExt))) {
+ if (ext && (!wcsicmp(ext, L".bat") || !wcsicmp(ext, L".cmd"))) {
BOOL oldinteractive = interactive;
interactive = FALSE;
WCMD_batch (thisDir, command, called, NULL, INVALID_HANDLE_VALUE);
@@ -1349,7 +1327,6 @@ void WCMD_execute (const WCHAR *command, const WCHAR *redirects,
(*cmdList)->nextcommand->prevDelim == CMD_PIPE) {
WCHAR temp_path[MAX_PATH];
- static const WCHAR cmdW[] = {'C','M','D','\0'};
/* Remember piping is in action */
WINE_TRACE("Output needs to be piped\n");
@@ -1357,15 +1334,14 @@ void WCMD_execute (const WCHAR *command, const WCHAR *redirects,
/* Generate a unique temporary filename */
GetTempPathW(ARRAY_SIZE(temp_path), temp_path);
- GetTempFileNameW(temp_path, cmdW, 0, (*cmdList)->nextcommand->pipeFile);
+ GetTempFileNameW(temp_path, L"CMD", 0, (*cmdList)->nextcommand->pipeFile);
WINE_TRACE("Using temporary file of %s\n",
wine_dbgstr_w((*cmdList)->nextcommand->pipeFile));
}
/* If piped output, send stdout to the pipe by appending >filename to redirects */
if (piped) {
- static const WCHAR redirOut[] = {'%','s',' ','>',' ','%','s','\0'};
- wsprintfW (new_redir, redirOut, redirects, (*cmdList)->nextcommand->pipeFile);
+ wsprintfW (new_redir, L"%s > %s", redirects, (*cmdList)->nextcommand->pipeFile);
WINE_TRACE("Redirects now %s\n", wine_dbgstr_w(new_redir));
} else {
lstrcpyW(new_redir, redirects);
@@ -1395,8 +1371,7 @@ void WCMD_execute (const WCHAR *command, const WCHAR *redirects,
lstrcpyW(envvar, L"=");
lstrcatW(envvar, cmd);
if (GetEnvironmentVariableW(envvar, dir, MAX_PATH) == 0) {
- static const WCHAR fmt[] = {'%','s','\\','\0'};
- wsprintfW(cmd, fmt, cmd);
+ wsprintfW(cmd, L"%s\\", cmd);
WINE_TRACE("No special directory settings, using dir of %s\n", wine_dbgstr_w(cmd));
}
WINE_TRACE("Got directory %s as %s\n", wine_dbgstr_w(envvar), wine_dbgstr_w(cmd));
@@ -1675,11 +1650,10 @@ void WCMD_execute (const WCHAR *command, const WCHAR *redirects,
*/
WCHAR *WCMD_LoadMessage(UINT id) {
static WCHAR msg[2048];
- static const WCHAR failedMsg[] = {'F','a','i','l','e','d','!','\0'};
if (!LoadStringW(GetModuleHandleW(NULL), id, msg, ARRAY_SIZE(msg))) {
WINE_FIXME("LoadString failed with %d\n", GetLastError());
- lstrcpyW(msg, failedMsg);
+ lstrcpyW(msg, L"Failed!");
}
return msg;
}
@@ -2440,11 +2414,6 @@ int __cdecl wmain (int argc, WCHAR *argvW[])
BOOL promptNewLine = TRUE;
BOOL opt_q;
int opt_t = 0;
- static const WCHAR offW[] = {'O','F','F','\0'};
- static const WCHAR promptW[] = {'P','R','O','M','P','T','\0'};
- static const WCHAR defaultpromptW[] = {'$','P','$','G','\0'};
- static const WCHAR comspecW[] = {'C','O','M','S','P','E','C',0};
- static const WCHAR cmdW[] = {'\\','c','m','d','.','e','x','e',0};
WCHAR comspec[MAX_PATH];
CMD_LIST *toExecute = NULL; /* Commands left to be executed */
RTL_OSVERSIONINFOEXW osv;
@@ -2452,11 +2421,11 @@ int __cdecl wmain (int argc, WCHAR *argvW[])
STARTUPINFOW startupInfo;
const WCHAR *arg;
- if (!GetEnvironmentVariableW(comspecW, comspec, ARRAY_SIZE(comspec)))
+ if (!GetEnvironmentVariableW(L"COMSPEC", comspec, ARRAY_SIZE(comspec)))
{
- GetSystemDirectoryW(comspec, ARRAY_SIZE(comspec) - ARRAY_SIZE(cmdW));
- lstrcatW(comspec, cmdW);
- SetEnvironmentVariableW(comspecW, comspec);
+ GetSystemDirectoryW(comspec, ARRAY_SIZE(comspec) - ARRAY_SIZE(L"\\cmd.exe"));
+ lstrcatW(comspec, L"\\cmd.exe");
+ SetEnvironmentVariableW(L"COMSPEC", comspec);
}
srand(time(NULL));
@@ -2528,13 +2497,13 @@ int __cdecl wmain (int argc, WCHAR *argvW[])
while (*arg && wcschr(L" \t,=;", *arg)) arg++;
if (opt_q) {
- WCMD_echo(offW);
+ WCMD_echo(L"OFF");
}
/* Until we start to read from the keyboard, stay as non-interactive */
interactive = FALSE;
- SetEnvironmentVariableW(promptW, defaultpromptW);
+ SetEnvironmentVariableW(L"PROMPT", L"$P$G");
if (opt_c || opt_k) {
int len;
@@ -2592,9 +2561,9 @@ int __cdecl wmain (int argc, WCHAR *argvW[])
BOOL found = FALSE;
/* Now extract PATHEXT */
- len = GetEnvironmentVariableW(envPathExt, pathext, ARRAY_SIZE(pathext));
+ len = GetEnvironmentVariableW(L"PATHEXT", pathext, ARRAY_SIZE(pathext));
if ((len == 0) || (len >= ARRAY_SIZE(pathext))) {
- lstrcpyW (pathext, dfltPathExt);
+ lstrcpyW(pathext, L".bat;.com;.cmd;.exe");
}
/* If the supplied parameter has any directory information, look there */
@@ -2681,8 +2650,7 @@ int __cdecl wmain (int argc, WCHAR *argvW[])
/* Save cwd into appropriate env var (Must be before the /c processing */
GetCurrentDirectoryW(ARRAY_SIZE(string), string);
if (IsCharAlphaW(string[0]) && string[1] == ':') {
- static const WCHAR fmt[] = {'=','%','c',':','\0'};
- wsprintfW(envvar, fmt, string[0]);
+ wsprintfW(envvar, L"=%c:", string[0]);
SetEnvironmentVariableW(envvar, string);
WINE_TRACE("Set %s to %s\n", wine_dbgstr_w(envvar), wine_dbgstr_w(string));
}
@@ -2726,26 +2694,20 @@ int __cdecl wmain (int argc, WCHAR *argvW[])
HKEY key;
DWORD type;
DWORD value=0, size=4;
- static const WCHAR regKeyW[] = {'S','o','f','t','w','a','r','e','\\',
- 'M','i','c','r','o','s','o','f','t','\\',
- 'C','o','m','m','a','n','d',' ','P','r','o','c','e','s','s','o','r','\0'};
- static const WCHAR dfltColorW[] = {'D','e','f','a','u','l','t','C','o','l','o','r','\0'};
+ static const WCHAR regKeyW[] = L"Software\\Microsoft\\Command Processor";
if (RegOpenKeyExW(HKEY_CURRENT_USER, regKeyW,
0, KEY_READ, &key) == ERROR_SUCCESS) {
WCHAR strvalue[4];
/* See if DWORD or REG_SZ */
- if (RegQueryValueExW(key, dfltColorW, NULL, &type,
- NULL, NULL) == ERROR_SUCCESS) {
+ if (RegQueryValueExW(key, L"DefaultColor", NULL, &type, NULL, NULL) == ERROR_SUCCESS) {
if (type == REG_DWORD) {
size = sizeof(DWORD);
- RegQueryValueExW(key, dfltColorW, NULL, NULL,
- (LPBYTE)&value, &size);
+ RegQueryValueExW(key, L"DefaultColor", NULL, NULL, (BYTE *)&value, &size);
} else if (type == REG_SZ) {
size = ARRAY_SIZE(strvalue);
- RegQueryValueExW(key, dfltColorW, NULL, NULL,
- (LPBYTE)strvalue, &size);
+ RegQueryValueExW(key, L"DefaultColor", NULL, NULL, (BYTE *)strvalue, &size);
value = wcstoul(strvalue, NULL, 10);
}
}
@@ -2757,16 +2719,14 @@ int __cdecl wmain (int argc, WCHAR *argvW[])
WCHAR strvalue[4];
/* See if DWORD or REG_SZ */
- if (RegQueryValueExW(key, dfltColorW, NULL, &type,
+ if (RegQueryValueExW(key, L"DefaultColor", NULL, &type,
NULL, NULL) == ERROR_SUCCESS) {
if (type == REG_DWORD) {
size = sizeof(DWORD);
- RegQueryValueExW(key, dfltColorW, NULL, NULL,
- (LPBYTE)&value, &size);
+ RegQueryValueExW(key, L"DefaultColor", NULL, NULL, (BYTE *)&value, &size);
} else if (type == REG_SZ) {
size = ARRAY_SIZE(strvalue);
- RegQueryValueExW(key, dfltColorW, NULL, NULL,
- (LPBYTE)strvalue, &size);
+ RegQueryValueExW(key, L"DefaultColor", NULL, NULL, (BYTE *)strvalue, &size);
value = wcstoul(strvalue, NULL, 10);
}
}
--
2.26.2
1
0
Nov. 29, 2020
Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org>
---
programs/cmd/builtins.c | 386 ++++++++++++++++------------------------
1 file changed, 149 insertions(+), 237 deletions(-)
diff --git a/programs/cmd/builtins.c b/programs/cmd/builtins.c
index e4b1fed613f..e99dd24ac72 100644
--- a/programs/cmd/builtins.c
+++ b/programs/cmd/builtins.c
@@ -39,67 +39,59 @@ extern BOOL echo_mode;
extern BOOL interactive;
struct env_stack *pushd_directories;
-const WCHAR wildcardsW[] = {'*','?','\0'};
-const WCHAR slashstarW[] = {'\\','*','\0'};
-const WCHAR deviceW[] = {'\\','\\','.','\\','\0'};
const WCHAR inbuilt[][10] = {
- {'C','A','L','L','\0'},
- {'C','D','\0'},
- {'C','H','D','I','R','\0'},
- {'C','L','S','\0'},
- {'C','O','P','Y','\0'},
- {'C','T','T','Y','\0'},
- {'D','A','T','E','\0'},
- {'D','E','L','\0'},
- {'D','I','R','\0'},
- {'E','C','H','O','\0'},
- {'E','R','A','S','E','\0'},
- {'F','O','R','\0'},
- {'G','O','T','O','\0'},
- {'H','E','L','P','\0'},
- {'I','F','\0'},
- {'L','A','B','E','L','\0'},
- {'M','D','\0'},
- {'M','K','D','I','R','\0'},
- {'M','O','V','E','\0'},
- {'P','A','T','H','\0'},
- {'P','A','U','S','E','\0'},
- {'P','R','O','M','P','T','\0'},
- {'R','E','M','\0'},
- {'R','E','N','\0'},
- {'R','E','N','A','M','E','\0'},
- {'R','D','\0'},
- {'R','M','D','I','R','\0'},
- {'S','E','T','\0'},
- {'S','H','I','F','T','\0'},
- {'S','T','A','R','T','\0'},
- {'T','I','M','E','\0'},
- {'T','I','T','L','E','\0'},
- {'T','Y','P','E','\0'},
- {'V','E','R','I','F','Y','\0'},
- {'V','E','R','\0'},
- {'V','O','L','\0'},
- {'E','N','D','L','O','C','A','L','\0'},
- {'S','E','T','L','O','C','A','L','\0'},
- {'P','U','S','H','D','\0'},
- {'P','O','P','D','\0'},
- {'A','S','S','O','C','\0'},
- {'C','O','L','O','R','\0'},
- {'F','T','Y','P','E','\0'},
- {'M','O','R','E','\0'},
- {'C','H','O','I','C','E','\0'},
- {'M','K','L','I','N','K','\0'},
- {'E','X','I','T','\0'}
+ L"CALL",
+ L"CD",
+ L"CHDIR",
+ L"CLS",
+ L"COPY",
+ L"CTTY",
+ L"DATE",
+ L"DEL",
+ L"DIR",
+ L"ECHO",
+ L"ERASE",
+ L"FOR",
+ L"GOTO",
+ L"HELP",
+ L"IF",
+ L"LABEL",
+ L"MD",
+ L"MKDIR",
+ L"MOVE",
+ L"PATH",
+ L"PAUSE",
+ L"PROMPT",
+ L"REM",
+ L"REN",
+ L"RENAME",
+ L"RD",
+ L"RMDIR",
+ L"SET",
+ L"SHIFT",
+ L"START",
+ L"TIME",
+ L"TITLE",
+ L"TYPE",
+ L"VERIFY",
+ L"VER",
+ L"VOL",
+ L"ENDLOCAL",
+ L"SETLOCAL",
+ L"PUSHD",
+ L"POPD",
+ L"ASSOC",
+ L"COLOR",
+ L"FTYPE",
+ L"MORE",
+ L"CHOICE",
+ L"MKLINK",
+ L"EXIT"
};
static const WCHAR externals[][10] = {
- {'A','T','T','R','I','B','\0'},
- {'X','C','O','P','Y','\0'}
+ L"ATTRIB",
+ L"XCOPY"
};
-static const WCHAR onW[] = {'O','N','\0'};
-static const WCHAR offW[] = {'O','F','F','\0'};
-static const WCHAR parmY[] = {'/','Y','\0'};
-static const WCHAR parmNoY[] = {'/','-','Y','\0'};
-static const WCHAR eqeqW[] = {'=','=','\0'};
static HINSTANCE hinst;
struct env_stack *saved_environment;
@@ -261,11 +253,6 @@ void WCMD_change_tty (void) {
*/
void WCMD_choice (const WCHAR * args) {
-
- static const WCHAR bellW[] = {7,0};
- static const WCHAR commaW[] = {',',0};
- static const WCHAR bracket_open[] = {'[',0};
- static const WCHAR bracket_close[] = {']','?',0};
WCHAR answer[16];
WCHAR buffer[16];
WCHAR *ptr = NULL;
@@ -381,15 +368,15 @@ void WCMD_choice (const WCHAR * args) {
if (!opt_n) {
/* print a list of all allowed answers inside brackets */
- WCMD_output_asis(bracket_open);
+ WCMD_output_asis(L"[");
ptr = opt_c;
answer[1] = 0;
while ((answer[0] = *ptr++)) {
WCMD_output_asis(answer);
if (*ptr)
- WCMD_output_asis(commaW);
+ WCMD_output_asis(L",");
}
- WCMD_output_asis(bracket_close);
+ WCMD_output_asis(L"]?");
}
while (TRUE) {
@@ -417,7 +404,7 @@ void WCMD_choice (const WCHAR * args) {
{
/* key not allowed: play the bell */
WINE_TRACE("key not allowed: %s\n", wine_dbgstr_w(answer));
- WCMD_output_asis(bellW);
+ WCMD_output_asis(L"\a");
}
}
}
@@ -598,7 +585,6 @@ void WCMD_copy(WCHAR * args) {
WCHAR copycmd[4];
DWORD len;
BOOL dstisdevice = FALSE;
- static const WCHAR copyCmdW[] = {'C','O','P','Y','C','M','D','\0'};
typedef struct _COPY_FILES
{
@@ -787,11 +773,11 @@ void WCMD_copy(WCHAR * args) {
/* If COPYCMD is set, then we force the overwrite with /Y and ask for
* confirmation with /-Y. If COPYCMD is neither of those, then we use the
* default behavior. */
- len = GetEnvironmentVariableW(copyCmdW, copycmd, ARRAY_SIZE(copycmd));
+ len = GetEnvironmentVariableW(L"COPYCMD", copycmd, ARRAY_SIZE(copycmd));
if (len && len < ARRAY_SIZE(copycmd)) {
- if (!lstrcmpiW (copycmd, parmY))
+ if (!lstrcmpiW(copycmd, L"/Y"))
prompt = FALSE;
- else if (!lstrcmpiW (copycmd, parmNoY))
+ else if (!lstrcmpiW(copycmd, L"/-Y"))
prompt = TRUE;
}
}
@@ -851,7 +837,7 @@ void WCMD_copy(WCHAR * args) {
} else if (!destisdirectory) {
/* We have been asked to copy to a filename. Default to ascii IF the
source contains wildcards (true even if only one match) */
- if (wcspbrk(sourcelist->name, wildcardsW) != NULL) {
+ if (wcspbrk(sourcelist->name, L"*?") != NULL) {
anyconcats = TRUE; /* We really are concatenating to a single file */
if (destination->binarycopy == -1) {
destination->binarycopy = 0;
@@ -870,7 +856,7 @@ void WCMD_copy(WCHAR * args) {
wine_dbgstr_w(destname), appendfirstsource);
/* Remember if the destination is a device */
- if (wcsncmp(destination->name, deviceW, lstrlenW(deviceW)) == 0) {
+ if (wcsncmp(destination->name, L"\\\\.\\", lstrlenW(L"\\\\.\\")) == 0) {
WINE_TRACE("Destination is a device\n");
dstisdevice = TRUE;
}
@@ -914,13 +900,13 @@ void WCMD_copy(WCHAR * args) {
GetFullPathNameW(thiscopy->name, ARRAY_SIZE(srcpath), srcpath, &filenamepart);
WINE_TRACE("Directory, so full name is now '%s'\n", wine_dbgstr_w(srcpath));
- } else if ((wcspbrk(srcpath, wildcardsW) == NULL) &&
+ } else if ((wcspbrk(srcpath, L"*?") == NULL) &&
(attributes != INVALID_FILE_ATTRIBUTES) &&
(attributes & FILE_ATTRIBUTE_DIRECTORY)) {
/* We need to know where the filename part starts, so append \* and
recalculate the full resulting path */
- lstrcatW(thiscopy->name, slashstarW);
+ lstrcatW(thiscopy->name, L"\\*");
GetFullPathNameW(thiscopy->name, ARRAY_SIZE(srcpath), srcpath, &filenamepart);
WINE_TRACE("Directory, so full name is now '%s'\n", wine_dbgstr_w(srcpath));
}
@@ -929,7 +915,7 @@ void WCMD_copy(WCHAR * args) {
wine_dbgstr_w(srcpath), anyconcats);
/* If the source is a device, just use it, otherwise search */
- if (wcsncmp(srcpath, deviceW, lstrlenW(deviceW)) == 0) {
+ if (wcsncmp(srcpath, L"\\\\.\\", lstrlenW(L"\\\\.\\")) == 0) {
WINE_TRACE("Source is a device\n");
srcisdevice = TRUE;
srcname = &srcpath[4]; /* After the \\.\ prefix */
@@ -1148,7 +1134,6 @@ void WCMD_create_dir (WCHAR *args) {
* and a bitmask of unwanted attributes (*wantClear).
*/
static void WCMD_delete_parse_attributes(DWORD *wantSet, DWORD *wantClear) {
- static const WCHAR parmA[] = {'/','A','\0'};
WCHAR *p;
/* both are strictly 'out' parameters */
@@ -1156,7 +1141,7 @@ static void WCMD_delete_parse_attributes(DWORD *wantSet, DWORD *wantClear) {
*wantClear=0;
/* For each /A argument */
- for (p=wcsstr(quals, parmA); p != NULL; p=wcsstr(p, parmA)) {
+ for (p=wcsstr(quals, L"/A"); p != NULL; p=wcsstr(p, L"/A")) {
/* Skip /A itself */
p += 2;
@@ -1198,10 +1183,7 @@ static void WCMD_delete_parse_attributes(DWORD *wantSet, DWORD *wantClear) {
* (If /P supplied, del will prompt for individual files later.)
*/
static BOOL WCMD_delete_confirm_wildcard(const WCHAR *filename, BOOL *pPrompted) {
- static const WCHAR parmP[] = {'/','P','\0'};
- static const WCHAR parmQ[] = {'/','Q','\0'};
-
- if ((wcsstr(quals, parmQ) == NULL) && (wcsstr(quals, parmP) == NULL)) {
+ if ((wcsstr(quals, L"/Q") == NULL) && (wcsstr(quals, L"/P") == NULL)) {
WCHAR drive[10];
WCHAR dir[MAX_PATH];
WCHAR fname[MAX_PATH];
@@ -1216,13 +1198,12 @@ static BOOL WCMD_delete_confirm_wildcard(const WCHAR *filename, BOOL *pPrompted)
if ((lstrcmpW(fname, L"*") == 0) && (*ext == 0x00 || (lstrcmpW(ext, L".*") == 0))) {
WCHAR question[MAXSTRING];
- static const WCHAR fmt[] = {'%','s',' ','\0'};
/* Caller uses this to suppress "file not found" warning later */
*pPrompted = TRUE;
/* Ask for confirmation */
- wsprintfW(question, fmt, fpath);
+ wsprintfW(question, L"%s ", fpath);
return WCMD_ask_confirm(question, TRUE, NULL);
}
}
@@ -1236,10 +1217,6 @@ static BOOL WCMD_delete_confirm_wildcard(const WCHAR *filename, BOOL *pPrompted)
* Returns TRUE if a file was deleted.
*/
static BOOL WCMD_delete_one (const WCHAR *thisArg) {
-
- static const WCHAR parmP[] = {'/','P','\0'};
- static const WCHAR parmS[] = {'/','S','\0'};
- static const WCHAR parmF[] = {'/','F','\0'};
DWORD wanted_attrs;
DWORD unwanted_attrs;
BOOL found = FALSE;
@@ -1276,10 +1253,9 @@ static BOOL WCMD_delete_one (const WCHAR *thisArg) {
&& (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
{
WCHAR modifiedParm[MAX_PATH];
- static const WCHAR slashStar[] = {'\\','*','\0'};
lstrcpyW(modifiedParm, argCopy);
- lstrcatW(modifiedParm, slashStar);
+ lstrcatW(modifiedParm, L"\\*");
FindClose(hff);
found = TRUE;
WCMD_delete_one(modifiedParm);
@@ -1303,7 +1279,7 @@ static BOOL WCMD_delete_one (const WCHAR *thisArg) {
&& ((fd.dwFileAttributes & unwanted_attrs) == 0);
/* /P means prompt for each file */
- if (ok && wcsstr (quals, parmP) != NULL) {
+ if (ok && wcsstr(quals, L"/P") != NULL) {
WCHAR* question;
/* Ask for confirmation */
@@ -1318,7 +1294,7 @@ static BOOL WCMD_delete_one (const WCHAR *thisArg) {
/* If file is read only, and /A:r or /F supplied, delete it */
if (fd.dwFileAttributes & FILE_ATTRIBUTE_READONLY &&
((wanted_attrs & FILE_ATTRIBUTE_READONLY) ||
- wcsstr (quals, parmF) != NULL)) {
+ wcsstr(quals, L"/F") != NULL)) {
SetFileAttributesW(fpath, fd.dwFileAttributes & ~FILE_ATTRIBUTE_READONLY);
}
@@ -1332,7 +1308,7 @@ static BOOL WCMD_delete_one (const WCHAR *thisArg) {
}
/* Now recurse into all subdirectories handling the parameter in the same way */
- if (wcsstr (quals, parmS) != NULL) {
+ if (wcsstr(quals, L"/S") != NULL) {
WCHAR thisDir[MAX_PATH];
int cPos;
@@ -1505,15 +1481,15 @@ void WCMD_echo (const WCHAR *args)
count = lstrlenW(trimmed);
if (count == 0 && origcommand[0]!='.' && origcommand[0]!=':'
&& origcommand[0]!=';' && origcommand[0]!='/') {
- if (echo_mode) WCMD_output (WCMD_LoadMessage(WCMD_ECHOPROMPT), onW);
- else WCMD_output (WCMD_LoadMessage(WCMD_ECHOPROMPT), offW);
+ if (echo_mode) WCMD_output(WCMD_LoadMessage(WCMD_ECHOPROMPT), L"ON");
+ else WCMD_output (WCMD_LoadMessage(WCMD_ECHOPROMPT), L"OFF");
heap_free(trimmed);
return;
}
- if (lstrcmpiW(trimmed, onW) == 0)
+ if (lstrcmpiW(trimmed, L"ON") == 0)
echo_mode = TRUE;
- else if (lstrcmpiW(trimmed, offW) == 0)
+ else if (lstrcmpiW(trimmed, L"OFF") == 0)
echo_mode = FALSE;
else {
WCMD_output_asis (args);
@@ -1665,12 +1641,10 @@ static BOOL WCMD_parse_forf_options(WCHAR *options, WCHAR *eol, int *skip,
static const WCHAR tokensW[] = {'t','o','k','e','n','s','='};
static const WCHAR delimsW[] = {'d','e','l','i','m','s','='};
static const WCHAR usebackqW[] = {'u','s','e','b','a','c','k','q'};
- static const WCHAR forf_defaultdelims[] = {' ', '\t', '\0'};
- static const WCHAR forf_defaulttokens[] = {'1', '\0'};
/* Initialize to defaults */
- lstrcpyW(delims, forf_defaultdelims);
- lstrcpyW(tokens, forf_defaulttokens);
+ lstrcpyW(delims, L" \t");
+ lstrcpyW(tokens, L"1");
*eol = 0;
*skip = 0;
*usebackq = FALSE;
@@ -1768,7 +1742,7 @@ static void WCMD_add_dirstowalk(DIRECTORY_STACK *dirsToWalk) {
/* Build a generic search and add all directories on the list of directories
still to walk */
lstrcpyW(fullitem, dirsToWalk->dirName);
- lstrcatW(fullitem, slashstarW);
+ lstrcatW(fullitem, L"\\*");
hff = FindFirstFileW(fullitem, &fd);
if (hff != INVALID_HANDLE_VALUE) {
do {
@@ -2072,10 +2046,6 @@ static HANDLE WCMD_forf_getinputhandle(BOOL usebackq, WCHAR *itemstr, BOOL iscmd
WCHAR temp_cmd[MAXSTRING];
WCHAR *trimmed = NULL;
HANDLE hinput = INVALID_HANDLE_VALUE;
- static const WCHAR redirOutW[] = {'>','%','s','\0'};
- static const WCHAR cmdW[] = {'C','M','D','\0'};
- static const WCHAR cmdslashcW[] = {'C','M','D','.','E','X','E',' ',
- '/','C',' ','%','s','\0'};
/* Remove leading and trailing character (but there may be trailing whitespace too) */
if ((iscmd && (itemstr[0] == '`' && usebackq)) ||
@@ -2093,11 +2063,11 @@ static HANDLE WCMD_forf_getinputhandle(BOOL usebackq, WCHAR *itemstr, BOOL iscmd
if (iscmd) {
/* Get temp filename */
GetTempPathW(ARRAY_SIZE(temp_str), temp_str);
- GetTempFileNameW(temp_str, cmdW, 0, temp_file);
+ GetTempFileNameW(temp_str, L"CMD", 0, temp_file);
/* Redirect output to the temporary file */
- wsprintfW(temp_str, redirOutW, temp_file);
- wsprintfW(temp_cmd, cmdslashcW, itemstr);
+ wsprintfW(temp_str, L">%s", temp_file);
+ wsprintfW(temp_cmd, L"CMD.EXE /C %s", itemstr);
WINE_TRACE("Issuing '%s' with redirs '%s'\n",
wine_dbgstr_w(temp_cmd), wine_dbgstr_w(temp_str));
WCMD_execute (temp_cmd, temp_str, NULL, FALSE);
@@ -2299,7 +2269,6 @@ void WCMD_for (WCHAR *p, CMD_LIST **cmdList) {
* If the parameter within the set has a wildcard then search for matching files
* otherwise do a literal substitution.
*/
- static const WCHAR wildcards[] = {'*','?','\0'};
/* Take a copy of the item returned from WCMD_parameter as it is held in a
static buffer which can be overwritten during parsing of the for body */
@@ -2327,7 +2296,7 @@ void WCMD_for (WCHAR *p, CMD_LIST **cmdList) {
lstrcpyW(fullitem, item);
}
- if (wcspbrk (fullitem, wildcards)) {
+ if (wcspbrk(fullitem, L"*?")) {
hff = FindFirstFileW(fullitem, &fd);
if (hff != INVALID_HANDLE_VALUE) {
do {
@@ -2469,7 +2438,6 @@ void WCMD_for (WCHAR *p, CMD_LIST **cmdList) {
/* If /L is provided, now run the for loop */
if (useNumbers) {
WCHAR thisNum[20];
- static const WCHAR fmt[] = {'%','d','\0'};
WINE_TRACE("FOR /L provided range from %d to %d step %d\n",
numbers[0], numbers[2], numbers[1]);
@@ -2477,7 +2445,7 @@ void WCMD_for (WCHAR *p, CMD_LIST **cmdList) {
(numbers[1]<0)? i>=numbers[2] : i<=numbers[2];
i=i + numbers[1]) {
- swprintf(thisNum, ARRAY_SIZE(thisNum), fmt, i);
+ swprintf(thisNum, ARRAY_SIZE(thisNum), L"%d", i);
WINE_TRACE("Processing FOR number %s\n", wine_dbgstr_w(thisNum));
thisCmdStart = cmdStart;
@@ -2556,9 +2524,8 @@ void WCMD_give_help (const WCHAR *args)
if (CompareStringW(LOCALE_USER_DEFAULT, NORM_IGNORECASE | SORT_STRINGSORT,
args, -1, externals[i], -1) == CSTR_EQUAL) {
WCHAR cmd[128];
- static const WCHAR helpW[] = {' ', '/','?','\0'};
lstrcpyW(cmd, args);
- lstrcatW(cmd, helpW);
+ lstrcatW(cmd, L" /?");
WCMD_run_program(cmd, FALSE);
return;
}
@@ -2581,14 +2548,13 @@ void WCMD_goto (CMD_LIST **cmdList) {
WCHAR string[MAX_PATH];
WCHAR *labelend = NULL;
- const WCHAR labelEndsW[] = {'>','<','|','&',' ',':','\t','\0'};
+ const WCHAR labelEndsW[] = L"><|& :\t";
/* Do not process any more parts of a processed multipart or multilines command */
if (cmdList) *cmdList = NULL;
if (context != NULL) {
WCHAR *paramStart = param1, *str;
- static const WCHAR eofW[] = {':','e','o','f','\0'};
if (param1[0] == 0x00) {
WCMD_output_stderr(WCMD_LoadMessage(WCMD_NOARG));
@@ -2596,7 +2562,7 @@ void WCMD_goto (CMD_LIST **cmdList) {
}
/* Handle special :EOF label */
- if (lstrcmpiW (eofW, param1) == 0) {
+ if (lstrcmpiW(L":eof", param1) == 0) {
context -> skip_rest = TRUE;
return;
}
@@ -2678,7 +2644,6 @@ void WCMD_pushd (const WCHAR *args)
{
struct env_stack *curdir;
WCHAR *thisdir;
- static const WCHAR parmD[] = {'/','D','\0'};
if (wcschr(args, '/') != NULL) {
SetLastError(ERROR_INVALID_PARAMETER);
@@ -2696,7 +2661,7 @@ void WCMD_pushd (const WCHAR *args)
}
/* Change directory using CD code with /D parameter */
- lstrcpyW(quals, parmD);
+ lstrcpyW(quals, L"/D");
GetCurrentDirectoryW (1024, thisdir);
errorlevel = 0;
WCMD_setshow_default(args);
@@ -2758,15 +2723,9 @@ static int evaluate_if_comparison(const WCHAR *leftOperand, const WCHAR *operato
WCHAR *endptr_leftOp, *endptr_rightOp;
long int leftOperand_int, rightOperand_int;
BOOL int_operands;
- static const WCHAR lssW[] = {'l','s','s','\0'};
- static const WCHAR leqW[] = {'l','e','q','\0'};
- static const WCHAR equW[] = {'e','q','u','\0'};
- static const WCHAR neqW[] = {'n','e','q','\0'};
- static const WCHAR geqW[] = {'g','e','q','\0'};
- static const WCHAR gtrW[] = {'g','t','r','\0'};
/* == is a special case, as it always compares strings */
- if (!lstrcmpiW(operator, eqeqW))
+ if (!lstrcmpiW(operator, L"=="))
return caseInsensitive ? lstrcmpiW(leftOperand, rightOperand) == 0
: lstrcmpW (leftOperand, rightOperand) == 0;
@@ -2776,7 +2735,7 @@ static int evaluate_if_comparison(const WCHAR *leftOperand, const WCHAR *operato
int_operands = (!*endptr_leftOp) && (!*endptr_rightOp);
/* Perform actual (integer or string) comparison */
- if (!lstrcmpiW(operator, lssW)) {
+ if (!lstrcmpiW(operator, L"lss")) {
if (int_operands)
return leftOperand_int < rightOperand_int;
else
@@ -2784,7 +2743,7 @@ static int evaluate_if_comparison(const WCHAR *leftOperand, const WCHAR *operato
: lstrcmpW (leftOperand, rightOperand) < 0;
}
- if (!lstrcmpiW(operator, leqW)) {
+ if (!lstrcmpiW(operator, L"leq")) {
if (int_operands)
return leftOperand_int <= rightOperand_int;
else
@@ -2792,7 +2751,7 @@ static int evaluate_if_comparison(const WCHAR *leftOperand, const WCHAR *operato
: lstrcmpW (leftOperand, rightOperand) <= 0;
}
- if (!lstrcmpiW(operator, equW)) {
+ if (!lstrcmpiW(operator, L"equ")) {
if (int_operands)
return leftOperand_int == rightOperand_int;
else
@@ -2800,7 +2759,7 @@ static int evaluate_if_comparison(const WCHAR *leftOperand, const WCHAR *operato
: lstrcmpW (leftOperand, rightOperand) == 0;
}
- if (!lstrcmpiW(operator, neqW)) {
+ if (!lstrcmpiW(operator, L"neq")) {
if (int_operands)
return leftOperand_int != rightOperand_int;
else
@@ -2808,7 +2767,7 @@ static int evaluate_if_comparison(const WCHAR *leftOperand, const WCHAR *operato
: lstrcmpW (leftOperand, rightOperand) != 0;
}
- if (!lstrcmpiW(operator, geqW)) {
+ if (!lstrcmpiW(operator, L"geq")) {
if (int_operands)
return leftOperand_int >= rightOperand_int;
else
@@ -2816,7 +2775,7 @@ static int evaluate_if_comparison(const WCHAR *leftOperand, const WCHAR *operato
: lstrcmpW (leftOperand, rightOperand) >= 0;
}
- if (!lstrcmpiW(operator, gtrW)) {
+ if (!lstrcmpiW(operator, L"gtr")) {
if (int_operands)
return leftOperand_int > rightOperand_int;
else
@@ -2830,18 +2789,13 @@ static int evaluate_if_comparison(const WCHAR *leftOperand, const WCHAR *operato
int evaluate_if_condition(WCHAR *p, WCHAR **command, int *test, int *negate)
{
WCHAR condition[MAX_PATH];
- static const WCHAR notW[] = {'n','o','t','\0'};
- static const WCHAR errlvlW[] = {'e','r','r','o','r','l','e','v','e','l','\0'};
- static const WCHAR existW[] = {'e','x','i','s','t','\0'};
- static const WCHAR defdW[] = {'d','e','f','i','n','e','d','\0'};
- static const WCHAR parmI[] = {'/','I','\0'};
- int caseInsensitive = (wcsstr(quals, parmI) != NULL);
-
- *negate = !lstrcmpiW(param1,notW);
+ int caseInsensitive = (wcsstr(quals, L"/I") != NULL);
+
+ *negate = !lstrcmpiW(param1,L"not");
lstrcpyW(condition, (*negate ? param2 : param1));
WINE_TRACE("Condition: %s\n", wine_dbgstr_w(condition));
- if (!lstrcmpiW (condition, errlvlW)) {
+ if (!lstrcmpiW(condition, L"errorlevel")) {
WCHAR *param = WCMD_parameter(p, 1+(*negate), NULL, FALSE, FALSE);
WCHAR *endptr;
long int param_int = wcstol(param, &endptr, 10);
@@ -2849,7 +2803,7 @@ int evaluate_if_condition(WCHAR *p, WCHAR **command, int *test, int *negate)
*test = ((long int)errorlevel >= param_int);
WCMD_parameter(p, 2+(*negate), command, FALSE, FALSE);
}
- else if (!lstrcmpiW (condition, existW)) {
+ else if (!lstrcmpiW(condition, L"exist")) {
WIN32_FIND_DATAW fd;
HANDLE hff;
WCHAR *param = WCMD_parameter(p, 1+(*negate), NULL, FALSE, FALSE);
@@ -2864,7 +2818,7 @@ int evaluate_if_condition(WCHAR *p, WCHAR **command, int *test, int *negate)
WCMD_parameter(p, 2+(*negate), command, FALSE, FALSE);
}
- else if (!lstrcmpiW (condition, defdW)) {
+ else if (!lstrcmpiW(condition, L"defined")) {
*test = (GetEnvironmentVariableW(WCMD_parameter(p, 1+(*negate), NULL, FALSE, FALSE),
NULL, 0) > 0);
WCMD_parameter(p, 2+(*negate), command, FALSE, FALSE);
@@ -2882,8 +2836,8 @@ int evaluate_if_condition(WCHAR *p, WCHAR **command, int *test, int *negate)
while (*p == ' ' || *p == '\t')
p++;
- if (!wcsncmp(p, eqeqW, lstrlenW(eqeqW)))
- lstrcpyW(operator, eqeqW);
+ if (!wcsncmp(p, L"==", lstrlenW(L"==")))
+ lstrcpyW(operator, L"==");
else {
lstrcpyW(operator, WCMD_parameter(p, 0, ¶mStart, FALSE, FALSE));
if (!*operator) goto syntax_err;
@@ -3026,23 +2980,22 @@ void WCMD_move (void)
/* Default whether automatic overwriting is on. If we are interactive then
we prompt by default, otherwise we overwrite by default
/-Y has the highest priority, then /Y and finally the COPYCMD env. variable */
- if (wcsstr (quals, parmNoY))
+ if (wcsstr(quals, L"/-Y"))
force = FALSE;
- else if (wcsstr (quals, parmY))
+ else if (wcsstr(quals, L"/Y"))
force = TRUE;
else {
- static const WCHAR copyCmdW[] = {'C','O','P','Y','C','M','D','\0'};
/* By default, we will force the overwrite in batch mode and ask for
* confirmation in interactive mode. */
force = !interactive;
/* If COPYCMD is set, then we force the overwrite with /Y and ask for
* confirmation with /-Y. If COPYCMD is neither of those, then we use the
* default behavior. */
- len = GetEnvironmentVariableW(copyCmdW, copycmd, ARRAY_SIZE(copycmd));
+ len = GetEnvironmentVariableW(L"COPYCMD", copycmd, ARRAY_SIZE(copycmd));
if (len && len < ARRAY_SIZE(copycmd)) {
- if (!lstrcmpiW (copycmd, parmY))
+ if (!lstrcmpiW(copycmd, L"/Y"))
force = TRUE;
- else if (!lstrcmpiW (copycmd, parmNoY))
+ else if (!lstrcmpiW(copycmd, L"/-Y"))
force = FALSE;
}
}
@@ -3111,8 +3064,6 @@ void WCMD_remove_dir (WCHAR *args) {
int argno = 0;
int argsProcessed = 0;
WCHAR *argN = args;
- static const WCHAR parmS[] = {'/','S','\0'};
- static const WCHAR parmQ[] = {'/','Q','\0'};
/* Loop through all args */
while (argN) {
@@ -3124,7 +3075,7 @@ void WCMD_remove_dir (WCHAR *args) {
/* If subdirectory search not supplied, just try to remove
and report error if it fails (eg if it contains a file) */
- if (wcsstr (quals, parmS) == NULL) {
+ if (wcsstr(quals, L"/S") == NULL) {
if (!RemoveDirectoryW(thisArg)) WCMD_print_error ();
/* Otherwise use ShFileOp to recursively remove a directory */
@@ -3133,13 +3084,12 @@ void WCMD_remove_dir (WCHAR *args) {
SHFILEOPSTRUCTW lpDir;
/* Ask first */
- if (wcsstr (quals, parmQ) == NULL) {
+ if (wcsstr(quals, L"/Q") == NULL) {
BOOL ok;
WCHAR question[MAXSTRING];
- static const WCHAR fmt[] = {'%','s',' ','\0'};
/* Ask for confirmation */
- wsprintfW(question, fmt, thisArg);
+ wsprintfW(question, L"%s ", thisArg);
ok = WCMD_ask_confirm(question, TRUE, NULL);
/* Abort if answer is 'N' */
@@ -3310,12 +3260,6 @@ void WCMD_setlocal (const WCHAR *s) {
struct env_stack *env_copy;
WCHAR cwd[MAX_PATH];
BOOL newdelay;
- static const WCHAR ondelayW[] = {'E','N','A','B','L','E','D','E','L','A',
- 'Y','E','D','E','X','P','A','N','S','I',
- 'O','N','\0'};
- static const WCHAR offdelayW[] = {'D','I','S','A','B','L','E','D','E','L',
- 'A','Y','E','D','E','X','P','A','N','S',
- 'I','O','N','\0'};
/* setlocal does nothing outside of batch programs */
if (!context) return;
@@ -3324,9 +3268,9 @@ void WCMD_setlocal (const WCHAR *s) {
/* ENABLEDELAYEDEXPANSION / DISABLEDELAYEDEXPANSION could be parm1 or parm2
(if both ENABLEEXTENSIONS and ENABLEDELAYEDEXPANSION supplied for example) */
- if (!wcsicmp(param1, ondelayW) || !wcsicmp(param2, ondelayW)) {
+ if (!wcsicmp(param1, L"ENABLEDELAYEDEXPANSION") || !wcsicmp(param2, L"ENABLEDELAYEDEXPANSION")) {
newdelay = TRUE;
- } else if (!wcsicmp(param1, offdelayW) || !wcsicmp(param2, offdelayW)) {
+ } else if (!wcsicmp(param1, L"DISABLEDELAYEDEXPANSION") || !wcsicmp(param2, L"DISABLEDELAYEDEXPANSION")) {
newdelay = FALSE;
} else {
newdelay = delayedsubst;
@@ -3422,9 +3366,8 @@ void WCMD_endlocal (void) {
if (IsCharAlphaW(temp->u.cwd)) {
WCHAR envvar[4];
WCHAR cwd[MAX_PATH];
- static const WCHAR fmt[] = {'=','%','c',':','\0'};
- wsprintfW(envvar, fmt, temp->u.cwd);
+ wsprintfW(envvar, L"=%c:", temp->u.cwd);
if (GetEnvironmentVariableW(envvar, cwd, MAX_PATH)) {
WINE_TRACE("Resetting cwd to %s\n", wine_dbgstr_w(cwd));
SetCurrentDirectoryW(cwd);
@@ -3449,7 +3392,6 @@ void WCMD_setshow_default (const WCHAR *args) {
WCHAR *pos;
WIN32_FIND_DATAW fd;
HANDLE hff;
- static const WCHAR parmD[] = {'/','D','\0'};
WINE_TRACE("Request change to directory '%s'\n", wine_dbgstr_w(args));
@@ -3457,7 +3399,7 @@ void WCMD_setshow_default (const WCHAR *args) {
if (lstrlenW(args) >= 2 &&
CompareStringW(LOCALE_USER_DEFAULT,
NORM_IGNORECASE | SORT_STRINGSORT,
- args, 2, parmD, -1) == CSTR_EQUAL) {
+ args, 2, L"/D", -1) == CSTR_EQUAL) {
args += 2;
while (*args && (*args==' ' || *args=='\t'))
args++;
@@ -3492,14 +3434,13 @@ void WCMD_setshow_default (const WCHAR *args) {
WCHAR dir[MAX_PATH];
WCHAR fname[MAX_PATH];
WCHAR ext[MAX_PATH];
- static const WCHAR fmt[] = {'%','s','%','s','%','s','\0'};
/* Convert path into actual directory spec */
GetFullPathNameW(string, ARRAY_SIZE(fpath), fpath, NULL);
_wsplitpath(fpath, drive, dir, fname, ext);
/* Rebuild path */
- wsprintfW(string, fmt, drive, dir, fd.cFileName);
+ wsprintfW(string, L"%s%s%s", drive, dir, fd.cFileName);
break;
}
} while (FindNextFileW(hff, &fd) != 0);
@@ -3521,7 +3462,7 @@ void WCMD_setshow_default (const WCHAR *args) {
/* Restore old directory if drive letter would change, and
CD x:\directory /D (or pushd c:\directory) not supplied */
- if ((wcsstr(quals, parmD) == NULL) &&
+ if ((wcsstr(quals, L"/D") == NULL) &&
(param1[1] == ':') && (toupper(param1[0]) != toupper(cwd[0]))) {
SetCurrentDirectoryW(cwd);
}
@@ -3555,12 +3496,11 @@ void WCMD_setshow_date (void) {
WCHAR curdate[64], buffer[64];
DWORD count;
- static const WCHAR parmT[] = {'/','T','\0'};
if (!*param1) {
if (GetDateFormatW(LOCALE_USER_DEFAULT, 0, NULL, NULL, curdate, ARRAY_SIZE(curdate))) {
WCMD_output (WCMD_LoadMessage(WCMD_CURRENTDATE), curdate);
- if (wcsstr (quals, parmT) == NULL) {
+ if (wcsstr(quals, L"/T") == NULL) {
WCMD_output (WCMD_LoadMessage(WCMD_NEWDATE));
WCMD_ReadFile(GetStdHandle(STD_INPUT_HANDLE), buffer, ARRAY_SIZE(buffer), &count);
if (count > 2) {
@@ -3905,11 +3845,10 @@ static int WCMD_reduce(OPSTACK **opstack, VARSTACK **varstack) {
case '=':
{
- WCHAR intFormat[] = {'%','d','\0'};
WCHAR result[MAXSTRING];
/* Build the result, then push it onto the stack */
- swprintf(result, ARRAY_SIZE(result), intFormat, var1);
+ swprintf(result, ARRAY_SIZE(result), L"%d", var1);
WINE_TRACE("Assigning %s a value %s\n", wine_dbgstr_w((*varstack)->variable),
wine_dbgstr_w(result));
SetEnvironmentVariableW((*varstack)->variable, result);
@@ -3932,8 +3871,7 @@ static int WCMD_reduce(OPSTACK **opstack, VARSTACK **varstack) {
*/
static int WCMD_handleExpression(WCHAR **expr, int *ret, int depth)
{
- static const WCHAR mathDelims[] = {' ','\t','(',')','!','~','-','*','/','%',
- '+','<','>','&','^','|','=',',','\0' };
+ static const WCHAR mathDelims[] = L" \t()!~-*/%+<>&^|=,";
int rc = 0;
WCHAR *pos;
BOOL lastwasnumber = FALSE; /* FALSE makes a minus at the start of the expression easier to handle */
@@ -4165,8 +4103,6 @@ void WCMD_setshow_env (WCHAR *s) {
LPVOID env;
WCHAR *p;
BOOL status;
- static const WCHAR parmP[] = {'/','P','\0'};
- static const WCHAR parmA[] = {'/','A','\0'};
WCHAR string[MAXSTRING];
if (param1[0] == 0x00 && quals[0] == 0x00) {
@@ -4178,7 +4114,7 @@ void WCMD_setshow_env (WCHAR *s) {
/* See if /P supplied, and if so echo the prompt, and read in a reply */
if (CompareStringW(LOCALE_USER_DEFAULT,
NORM_IGNORECASE | SORT_STRINGSORT,
- s, 2, parmP, -1) == CSTR_EQUAL) {
+ s, 2, L"/P", -1) == CSTR_EQUAL) {
DWORD count;
s += 2;
@@ -4214,7 +4150,7 @@ void WCMD_setshow_env (WCHAR *s) {
/* See if /A supplied, and if so calculate the results of all the expressions */
} else if (CompareStringW(LOCALE_USER_DEFAULT,
NORM_IGNORECASE | SORT_STRINGSORT,
- s, 2, parmA, -1) == CSTR_EQUAL) {
+ s, 2, L"/A", -1) == CSTR_EQUAL) {
/* /A supplied, so evaluate expressions and set variables appropriately */
/* Syntax is set /a var=1,var2=var+4 etc, and it echos back the result */
/* of the final computation */
@@ -4246,8 +4182,7 @@ void WCMD_setshow_env (WCHAR *s) {
/* If we have no context (interactive or cmd.exe /c) print the final result */
if (!context) {
- static const WCHAR fmt[] = {'%','d','\0'};
- swprintf(string, ARRAY_SIZE(string), fmt, result);
+ swprintf(string, ARRAY_SIZE(string), L"%d", result);
WCMD_output_asis(string);
}
@@ -4295,13 +4230,11 @@ void WCMD_setshow_path (const WCHAR *args) {
WCHAR string[1024];
DWORD status;
- static const WCHAR pathW[] = {'P','A','T','H','\0'};
- static const WCHAR pathEqW[] = {'P','A','T','H','=','\0'};
if (!*param1 && !*param2) {
- status = GetEnvironmentVariableW(pathW, string, ARRAY_SIZE(string));
+ status = GetEnvironmentVariableW(L"PATH", string, ARRAY_SIZE(string));
if (status != 0) {
- WCMD_output_asis ( pathEqW);
+ WCMD_output_asis(L"PATH=");
WCMD_output_asis ( string);
WCMD_output_asis(L"\r\n");
}
@@ -4311,7 +4244,7 @@ void WCMD_setshow_path (const WCHAR *args) {
}
else {
if (*args == '=') args++; /* Skip leading '=' */
- status = SetEnvironmentVariableW(pathW, args);
+ status = SetEnvironmentVariableW(L"PATH", args);
if (!status) WCMD_print_error();
}
}
@@ -4325,18 +4258,17 @@ void WCMD_setshow_path (const WCHAR *args) {
void WCMD_setshow_prompt (void) {
WCHAR *s;
- static const WCHAR promptW[] = {'P','R','O','M','P','T','\0'};
if (!*param1) {
- SetEnvironmentVariableW(promptW, NULL);
+ SetEnvironmentVariableW(L"PROMPT", NULL);
}
else {
s = param1;
while ((*s == '=') || (*s == ' ') || (*s == '\t')) s++;
if (!*s) {
- SetEnvironmentVariableW(promptW, NULL);
+ SetEnvironmentVariableW(L"PROMPT", NULL);
}
- else SetEnvironmentVariableW(promptW, s);
+ else SetEnvironmentVariableW(L"PROMPT", s);
}
}
@@ -4352,13 +4284,12 @@ void WCMD_setshow_time (void) {
WCHAR curtime[64], buffer[64];
DWORD count;
SYSTEMTIME st;
- static const WCHAR parmT[] = {'/','T','\0'};
if (!*param1) {
GetLocalTime(&st);
if (GetTimeFormatW(LOCALE_USER_DEFAULT, 0, &st, NULL, curtime, ARRAY_SIZE(curtime))) {
WCMD_output (WCMD_LoadMessage(WCMD_CURRENTTIME), curtime);
- if (wcsstr (quals, parmT) == NULL) {
+ if (wcsstr(quals, L"/T") == NULL) {
WCMD_output (WCMD_LoadMessage(WCMD_NEWTIME));
WCMD_ReadFile(GetStdHandle(STD_INPUT_HANDLE), buffer, ARRAY_SIZE(buffer), &count);
if (count > 2) {
@@ -4411,11 +4342,6 @@ void WCMD_shift (const WCHAR *args) {
*/
void WCMD_start(WCHAR *args)
{
- static const WCHAR exeW[] = {'\\','c','o','m','m','a','n','d',
- '\\','s','t','a','r','t','.','e','x','e',0};
- static const WCHAR startDelims[] = { ' ', '\t', '/', '\0' };
- static const WCHAR prefixQuote[] = {'"','\\','"','\0'};
- static const WCHAR postfixQuote[] = {'\\','"','"','\0'};
int argno;
int have_title;
WCHAR file[MAX_PATH];
@@ -4424,7 +4350,7 @@ void WCMD_start(WCHAR *args)
PROCESS_INFORMATION pi;
GetWindowsDirectoryW( file, MAX_PATH );
- lstrcatW( file, exeW );
+ lstrcatW(file, L"\\command\\start.exe");
cmdline = heap_xalloc( (lstrlenW(file) + lstrlenW(args) + 8) * sizeof(WCHAR) );
lstrcpyW( cmdline, file );
lstrcatW(cmdline, L" ");
@@ -4468,7 +4394,7 @@ void WCMD_start(WCHAR *args)
WCHAR *thisArg, *argN;
argN = NULL;
- thisArg = WCMD_parameter_with_delims(args, argno, &argN, FALSE, FALSE, startDelims);
+ thisArg = WCMD_parameter_with_delims(args, argno, &argN, FALSE, FALSE, L" \t/");
/* No more parameters */
if (!argN)
@@ -4484,12 +4410,12 @@ void WCMD_start(WCHAR *args)
cmdline_params[argN - args] = '\0';
/* Add quoted title */
- lstrcatW(cmdline_params, prefixQuote);
+ lstrcatW(cmdline_params, L"\"\\\"");
lstrcatW(cmdline_params, thisArg);
- lstrcatW(cmdline_params, postfixQuote);
+ lstrcatW(cmdline_params, L"\\\"\"");
/* Concatenate remaining command-line */
- thisArg = WCMD_parameter_with_delims(args, argno, &argN, TRUE, FALSE, startDelims);
+ thisArg = WCMD_parameter_with_delims(args, argno, &argN, TRUE, FALSE, L" \t/");
lstrcatW(cmdline_params, argN + lstrlenW(thisArg));
break;
@@ -4579,8 +4505,7 @@ void WCMD_type (WCHAR *args) {
errorlevel = 1;
} else {
if (writeHeaders) {
- static const WCHAR fmt[] = {'\n','%','1','\n','\n','\n','\0'};
- WCMD_output_stderr(fmt, thisArg);
+ WCMD_output_stderr(L"\n%1\n\n\n", thisArg);
}
while (WCMD_ReadFile(h, buffer, ARRAY_SIZE(buffer) - 1, &count)) {
if (count == 0) break; /* ReadFile reports success on EOF! */
@@ -4606,15 +4531,10 @@ void WCMD_more (WCHAR *args) {
WCHAR moreStrPage[100];
WCHAR buffer[512];
DWORD count;
- static const WCHAR moreStart[] = {'-','-',' ','\0'};
- static const WCHAR moreFmt[] = {'%','s',' ','-','-','\n','\0'};
- static const WCHAR moreFmt2[] = {'%','s',' ','(','%','2','.','2','d','%','%',
- ')',' ','-','-','\n','\0'};
- static const WCHAR conInW[] = {'C','O','N','I','N','$','\0'};
/* Prefix the NLS more with '-- ', then load the text */
errorlevel = 0;
- lstrcpyW(moreStr, moreStart);
+ lstrcpyW(moreStr, L"-- ");
LoadStringW(hinst, WCMD_MORESTR, &moreStr[3], ARRAY_SIZE(moreStr)-3);
if (param1[0] == 0x00) {
@@ -4624,7 +4544,7 @@ void WCMD_more (WCHAR *args) {
more are satisfied by the next line from the input (file). To
avoid this, ensure stdin is to the console */
HANDLE hstdin = GetStdHandle(STD_INPUT_HANDLE);
- HANDLE hConIn = CreateFileW(conInW, GENERIC_READ | GENERIC_WRITE,
+ HANDLE hConIn = CreateFileW(L"CONIN$", GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ, NULL, OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL, 0);
WINE_TRACE("No parms - working probably in pipe mode\n");
@@ -4632,7 +4552,7 @@ void WCMD_more (WCHAR *args) {
/* Warning: No easy way of ending the stream (ctrl+z on windows) so
once you get in this bit unless due to a pipe, it's going to end badly... */
- wsprintfW(moreStrPage, moreFmt, moreStr);
+ wsprintfW(moreStrPage, L"%s --\n", moreStr);
WCMD_enter_paged_mode(moreStrPage);
while (WCMD_ReadFile(hstdin, buffer, ARRAY_SIZE(buffer)-1, &count)) {
@@ -4663,7 +4583,7 @@ void WCMD_more (WCHAR *args) {
if (needsPause) {
/* Wait */
- wsprintfW(moreStrPage, moreFmt2, moreStr, 100);
+ wsprintfW(moreStrPage, L"%s (%2.2d%%) --\n", moreStr, 100);
WCMD_leave_paged_mode();
WCMD_output_asis(moreStrPage);
WCMD_ReadFile(GetStdHandle(STD_INPUT_HANDLE), buffer, ARRAY_SIZE(buffer), &count);
@@ -4694,7 +4614,7 @@ void WCMD_more (WCHAR *args) {
curPos += count;
/* Update % count (would be used in WCMD_output_asis as prompt) */
- wsprintfW(moreStrPage, moreFmt2, moreStr, (int) min(99, (curPos * 100)/fileLen));
+ wsprintfW(moreStrPage, L"%s (%2.2d%%) --\n", moreStr, (int) min(99, (curPos * 100)/fileLen));
WCMD_output_asis (buffer);
}
@@ -4720,15 +4640,15 @@ void WCMD_verify (const WCHAR *args) {
count = lstrlenW(args);
if (count == 0) {
- if (verify_mode) WCMD_output (WCMD_LoadMessage(WCMD_VERIFYPROMPT), onW);
- else WCMD_output (WCMD_LoadMessage(WCMD_VERIFYPROMPT), offW);
+ if (verify_mode) WCMD_output(WCMD_LoadMessage(WCMD_VERIFYPROMPT), L"ON");
+ else WCMD_output (WCMD_LoadMessage(WCMD_VERIFYPROMPT), L"OFF");
return;
}
- if (lstrcmpiW(args, onW) == 0) {
+ if (lstrcmpiW(args, L"ON") == 0) {
verify_mode = TRUE;
return;
}
- else if (lstrcmpiW(args, offW) == 0) {
+ else if (lstrcmpiW(args, L"OFF") == 0) {
verify_mode = FALSE;
return;
}
@@ -4770,12 +4690,11 @@ int WCMD_volume(BOOL set_label, const WCHAR *path)
status = GetVolumeInformationW(NULL, label, ARRAY_SIZE(label), &serial, NULL, NULL, NULL, 0);
}
else {
- static const WCHAR fmt[] = {'%','s','\\','\0'};
if ((path[1] != ':') || (lstrlenW(path) != 2)) {
WCMD_output_stderr(WCMD_LoadMessage(WCMD_SYNTAXERR));
return 0;
}
- wsprintfW (curdir, fmt, path);
+ wsprintfW (curdir, L"%s\\", path);
status = GetVolumeInformationW(curdir, label, ARRAY_SIZE(label), &serial, NULL, NULL, NULL, 0);
}
if (!status) {
@@ -4817,11 +4736,9 @@ int WCMD_volume(BOOL set_label, const WCHAR *path)
*/
void WCMD_exit (CMD_LIST **cmdList) {
-
- static const WCHAR parmB[] = {'/','B','\0'};
int rc = wcstol(param1, NULL, 10); /* Note: wcstol of empty parameter is 0 */
- if (context && lstrcmpiW(quals, parmB) == 0) {
+ if (context && lstrcmpiW(quals, L"/B") == 0) {
errorlevel = rc;
context -> skip_rest = TRUE;
*cmdList = NULL;
@@ -4846,8 +4763,6 @@ void WCMD_assoc (const WCHAR *args, BOOL assoc) {
WCHAR keyValue[MAXSTRING];
DWORD valueLen = MAXSTRING;
HKEY readKey;
- static const WCHAR shOpCmdW[] = {'\\','S','h','e','l','l','\\',
- 'O','p','e','n','\\','C','o','m','m','a','n','d','\0'};
/* See if parameter includes '=' */
errorlevel = 0;
@@ -4882,7 +4797,7 @@ void WCMD_assoc (const WCHAR *args, BOOL assoc) {
{
WCHAR subkey[MAXSTRING];
lstrcpyW(subkey, keyName);
- if (!assoc) lstrcatW(subkey, shOpCmdW);
+ if (!assoc) lstrcatW(subkey, L"\\Shell\\Open\\Command");
if (RegOpenKeyExW(key, subkey, 0, accessOptions, &readKey) == ERROR_SUCCESS) {
@@ -4915,7 +4830,7 @@ void WCMD_assoc (const WCHAR *args, BOOL assoc) {
/* Set up key name */
lstrcpyW(subkey, keyValue);
- if (!assoc) lstrcatW(subkey, shOpCmdW);
+ if (!assoc) lstrcatW(subkey, L"\\Shell\\Open\\Command");
if (RegOpenKeyExW(key, subkey, 0, accessOptions, &readKey) == ERROR_SUCCESS) {
@@ -4951,7 +4866,7 @@ void WCMD_assoc (const WCHAR *args, BOOL assoc) {
/* Set up key name */
lstrcpyW(subkey, args);
- if (!assoc) lstrcatW(subkey, shOpCmdW);
+ if (!assoc) lstrcatW(subkey, L"\\Shell\\Open\\Command");
/* If nothing after '=' then clear value - only valid for ASSOC */
if (*newValue == 0x00) {
@@ -5066,9 +4981,6 @@ void WCMD_mklink(WCHAR *args)
BOOL ret = FALSE;
WCHAR file1[MAX_PATH];
WCHAR file2[MAX_PATH];
- static const WCHAR optD[] = {'/', 'D', '\0'};
- static const WCHAR optH[] = {'/', 'H', '\0'};
- static const WCHAR optJ[] = {'/', 'J', '\0'};
if (param1[0] == 0x00 || param2[0] == 0x00) {
WCMD_output_stderr(WCMD_LoadMessage(WCMD_NOARG));
@@ -5084,11 +4996,11 @@ void WCMD_mklink(WCHAR *args)
WINE_TRACE("mklink: Processing arg '%s'\n", wine_dbgstr_w(thisArg));
- if(lstrcmpiW(thisArg, optD) == 0)
+ if (lstrcmpiW(thisArg, L"/D") == 0)
isdir = TRUE;
- else if(lstrcmpiW(thisArg, optH) == 0)
+ else if (lstrcmpiW(thisArg, L"/H") == 0)
hard = TRUE;
- else if(lstrcmpiW(thisArg, optJ) == 0)
+ else if (lstrcmpiW(thisArg, L"/J") == 0)
junction = TRUE;
else {
if(!file1[0])
--
2.26.2
1
0