msvcrt: Support system(NULL).
This commit is contained in:
parent
d815e582cf
commit
620af69d88
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue