Commit 620af69d authored by Robert Wilhelm's avatar Robert Wilhelm Committed by Alexandre Julliard

msvcrt: Support system(NULL).

parent d815e582
......@@ -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);
......
......@@ -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();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment