diff options
author | Jan Niklas Hasse <jhasse@bixense.com> | 2020-05-18 09:57:34 (GMT) |
---|---|---|
committer | Jan Niklas Hasse <jhasse@bixense.com> | 2020-05-18 09:57:34 (GMT) |
commit | cf021f32e62370b7f9c8249a6c600cbe48e849c7 (patch) | |
tree | 62e21084f4596964db290b7f742d6df82e6821ae /src | |
parent | c6148b0c3377a7d12b679f99f35e09cc7f36e940 (diff) | |
download | Ninja-cf021f32e62370b7f9c8249a6c600cbe48e849c7.zip Ninja-cf021f32e62370b7f9c8249a6c600cbe48e849c7.tar.gz Ninja-cf021f32e62370b7f9c8249a6c600cbe48e849c7.tar.bz2 |
MinGW now has _mktemp_s, use overload with size parameter
MSVC also used the custom implementation, since the function isn't a
macro and therefore
#ifndef _mktemp_s
didn't work as intended.
Diffstat (limited to 'src')
-rw-r--r-- | src/test.cc | 13 |
1 files changed, 2 insertions, 11 deletions
diff --git a/src/test.cc b/src/test.cc index 8ba2297..021005e 100644 --- a/src/test.cc +++ b/src/test.cc @@ -24,6 +24,7 @@ #include <stdlib.h> #ifdef _WIN32 #include <windows.h> +#include <io.h> #else #include <unistd.h> #endif @@ -45,19 +46,9 @@ extern "C" { namespace { #ifdef _WIN32 -#ifndef _mktemp_s -/// mingw has no mktemp. Implement one with the same type as the one -/// found in the Windows API. -int _mktemp_s(char* templ) { - char* ofs = strchr(templ, 'X'); - sprintf(ofs, "%d", rand() % 1000000); - return 0; -} -#endif - /// Windows has no mkdtemp. Implement it in terms of _mktemp_s. char* mkdtemp(char* name_template) { - int err = _mktemp_s(name_template); + int err = _mktemp_s(name_template, strlen(name_template) + 1); if (err < 0) { perror("_mktemp_s"); return NULL; |