summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Niklas Hasse <jhasse@bixense.com>2020-05-18 11:57:34 +0200
committerJan Niklas Hasse <jhasse@bixense.com>2020-05-18 11:57:34 +0200
commitcf021f32e62370b7f9c8249a6c600cbe48e849c7 (patch)
tree62e21084f4596964db290b7f742d6df82e6821ae
parentc6148b0c3377a7d12b679f99f35e09cc7f36e940 (diff)
downloadninja-cf021f32e62370b7f9c8249a6c600cbe48e849c7.tar.gz
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.
-rw-r--r--src/test.cc13
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;