support system(0).
Robert Wilhelm
robert.wilhelm at gmx.net
Thu May 27 11:45:06 CDT 2010
---
dlls/msvcrt/process.c | 19 ++++++++++++-
dlls/msvcrt/tests/Makefile.in | 1 +
dlls/msvcrt/tests/process.c | 60 +++++++++++++++++++++++++++++++++++++++++
3 files changed, 79 insertions(+), 1 deletions(-)
create mode 100644 dlls/msvcrt/tests/process.c
diff --git a/dlls/msvcrt/process.c b/dlls/msvcrt/process.c
index 564c100..2e8ebc8 100644
--- a/dlls/msvcrt/process.c
+++ b/dlls/msvcrt/process.c
@@ -1168,7 +1168,21 @@ int CDECL _wsystem(const MSVCRT_wchar_t* cmd)
unsigned int len;
static const MSVCRT_wchar_t flag[] = {' ','/','c',' ',0};
- if (!(comspec = msvcrt_get_comspec())) return -1;
+ comspec = msvcrt_get_comspec();
+
+ if (cmd == NULL)
+ {
+ if (comspec == NULL)
+ {
+ *MSVCRT__errno() = MSVCRT_ENOENT;
+ return 0;
+ }
+ return 1;
+ }
+
+ if ( comspec == NULL)
+ return -1;
+
len = strlenW(comspec) + strlenW(flag) + strlenW(cmd) + 1;
if (!(fullcmd = HeapAlloc(GetProcessHeap(), 0, len * sizeof(MSVCRT_wchar_t))))
@@ -1195,6 +1209,9 @@ int CDECL MSVCRT_system(const char* cmd)
int res = -1;
MSVCRT_wchar_t *cmdW;
+ if (cmd == NULL)
+ return _wsystem(NULL);
+
if ((cmdW = msvcrt_wstrdupa(cmd)))
{
res = _wsystem(cmdW);
diff --git a/dlls/msvcrt/tests/Makefile.in b/dlls/msvcrt/tests/Makefile.in
index 60348f5..ea095d7 100644
--- a/dlls/msvcrt/tests/Makefile.in
+++ b/dlls/msvcrt/tests/Makefile.in
@@ -19,6 +19,7 @@ C_SRCS = \
locale.c \
misc.c \
printf.c \
+ process.c \
scanf.c \
signal.c \
string.c \
diff --git a/dlls/msvcrt/tests/process.c b/dlls/msvcrt/tests/process.c
new file mode 100644
index 0000000..9e66b98
--- /dev/null
+++ b/dlls/msvcrt/tests/process.c
@@ -0,0 +1,60 @@
+/*
+ * Unit tests for msvcrt process functions
+ *
+ * Copyright 2010 Robert Wilhelm
+ *
+ * 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 "wine/test.h"
+#include <errno.h>
+#include "msvcrt.h"
+
+static int (__cdecl *psystem)(const char *);
+
+static void init(void)
+{
+ HMODULE hmod = GetModuleHandleA("msvcrt.dll");
+
+ psystem = (void *)GetProcAddress(hmod, "system");
+}
+
+static void test_system(void)
+{
+ int ret;
+
+ if (!psystem)
+ {
+ win_skip("system is not available\n");
+ return;
+ }
+
+ ret = psystem(NULL);
+ ok(ret == 1, "Expected system to return 1, got %d\n", ret);
+
+ ret = psystem("echo OK");
+ ok(ret == 0, "Expected system to return 0, got %d\n", ret);
+}
+
+
+
+
+START_TEST(process)
+{
+ init();
+
+ test_system();
+
+}
--
1.6.6.1
--=-NplJqUG5HbODL1KaLE/v--
More information about the wine-patches
mailing list