Robert Wilhelm : msvcrt: Support system(NULL).
Alexandre Julliard
julliard at winehq.org
Fri May 28 09:43:13 CDT 2010
Module: wine
Branch: master
Commit: 620af69d888bc5d0fa2179f06423aa1fb290b11b
URL: http://source.winehq.org/git/wine.git/?a=commit;h=620af69d888bc5d0fa2179f06423aa1fb290b11b
Author: Robert Wilhelm <robert.wilhelm at gmx.net>
Date: Thu May 27 18:45:06 2010 +0200
msvcrt: Support system(NULL).
---
dlls/msvcrt/process.c | 19 ++++++++++++++++++-
dlls/msvcrt/tests/environ.c | 11 +++++++++++
2 files changed, 29 insertions(+), 1 deletions(-)
diff --git a/dlls/msvcrt/process.c b/dlls/msvcrt/process.c
index 564c100..b4c39c1 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/environ.c b/dlls/msvcrt/tests/environ.c
index 6175e14..336238c 100644
--- a/dlls/msvcrt/tests/environ.c
+++ b/dlls/msvcrt/tests/environ.c
@@ -42,6 +42,15 @@ static const char *a_very_long_env_string =
"/usr/lib/mingw32/3.4.2/;"
"/usr/lib/";
+static void test_system(void)
+{
+ int ret = system(NULL);
+ ok(ret == 1, "Expected system to return 1, got %d\n", ret);
+
+ ret = system("echo OK");
+ ok(ret == 0, "Expected system to return 0, got %d\n", ret);
+}
+
START_TEST(environ)
{
ok( _putenv("cat=") == 0, "_putenv failed on deletion of nonexistent environment variable\n" );
@@ -54,4 +63,6 @@ START_TEST(environ)
ok( _putenv(a_very_long_env_string) == 0, "_putenv failed for long environment string\n");
ok( getenv("nonexistent") == NULL, "getenv should fail with nonexistent var name\n" );
+
+ test_system();
}
More information about the wine-cvs
mailing list