msvcrt: Fix _mktemp implementation.
This commit is contained in:
parent
9e5097187e
commit
ce9d4b807e
|
@ -1691,9 +1691,12 @@ char * CDECL MSVCRT__mktemp(char *pattern)
|
|||
int id;
|
||||
char letter = 'a';
|
||||
|
||||
if(!pattern)
|
||||
return NULL;
|
||||
|
||||
while(*pattern)
|
||||
numX = (*pattern++ == 'X')? numX + 1 : 0;
|
||||
if (numX < 5)
|
||||
if (numX < 6)
|
||||
return NULL;
|
||||
pattern--;
|
||||
id = GetCurrentProcessId();
|
||||
|
@ -1708,8 +1711,7 @@ char * CDECL MSVCRT__mktemp(char *pattern)
|
|||
do
|
||||
{
|
||||
*pattern = letter++;
|
||||
if (GetFileAttributesA(retVal) == INVALID_FILE_ATTRIBUTES &&
|
||||
GetLastError() == ERROR_FILE_NOT_FOUND)
|
||||
if (GetFileAttributesA(retVal) == INVALID_FILE_ATTRIBUTES)
|
||||
return retVal;
|
||||
} while(letter <= 'z');
|
||||
return NULL;
|
||||
|
@ -1725,9 +1727,12 @@ MSVCRT_wchar_t * CDECL MSVCRT__wmktemp(MSVCRT_wchar_t *pattern)
|
|||
int id;
|
||||
MSVCRT_wchar_t letter = 'a';
|
||||
|
||||
if(!pattern)
|
||||
return NULL;
|
||||
|
||||
while(*pattern)
|
||||
numX = (*pattern++ == 'X')? numX + 1 : 0;
|
||||
if (numX < 5)
|
||||
if (numX < 6)
|
||||
return NULL;
|
||||
pattern--;
|
||||
id = GetCurrentProcessId();
|
||||
|
@ -1741,8 +1746,7 @@ MSVCRT_wchar_t * CDECL MSVCRT__wmktemp(MSVCRT_wchar_t *pattern)
|
|||
pattern++;
|
||||
do
|
||||
{
|
||||
if (GetFileAttributesW(retVal) == INVALID_FILE_ATTRIBUTES &&
|
||||
GetLastError() == ERROR_FILE_NOT_FOUND)
|
||||
if (GetFileAttributesW(retVal) == INVALID_FILE_ATTRIBUTES)
|
||||
return retVal;
|
||||
*pattern = letter++;
|
||||
} while(letter != '|');
|
||||
|
|
|
@ -2130,6 +2130,26 @@ static void test_stdin(void)
|
|||
ok(h != NULL, "h == NULL\n");
|
||||
}
|
||||
|
||||
static void test_mktemp(void)
|
||||
{
|
||||
char buf[16];
|
||||
|
||||
strcpy(buf, "a");
|
||||
ok(!_mktemp(buf), "_mktemp(\"a\") != NULL\n");
|
||||
|
||||
strcpy(buf, "testXXXXX");
|
||||
ok(!_mktemp(buf), "_mktemp(\"testXXXXX\") != NULL\n");
|
||||
|
||||
strcpy(buf, "testXXXXXX");
|
||||
ok(_mktemp(buf) != NULL, "_mktemp(\"testXXXXXX\") == NULL\n");
|
||||
|
||||
strcpy(buf, "testXXXXXXa");
|
||||
ok(!_mktemp(buf), "_mktemp(\"testXXXXXXa\") != NULL\n");
|
||||
|
||||
strcpy(buf, "**XXXXXX");
|
||||
ok(_mktemp(buf) != NULL, "_mktemp(\"**XXXXXX\") == NULL\n");
|
||||
}
|
||||
|
||||
START_TEST(file)
|
||||
{
|
||||
int arg_c;
|
||||
|
@ -2193,6 +2213,7 @@ START_TEST(file)
|
|||
test_setmaxstdio();
|
||||
test_pipes(arg_v[0]);
|
||||
test_stdin();
|
||||
test_mktemp();
|
||||
|
||||
/* Wait for the (_P_NOWAIT) spawned processes to finish to make sure the report
|
||||
* file contains lines in the correct order
|
||||
|
|
Loading…
Reference in New Issue