aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--debianutils/mktemp.c4
-rw-r--r--include/mingw.h2
-rw-r--r--win32/mingw.c14
3 files changed, 16 insertions, 4 deletions
diff --git a/debianutils/mktemp.c b/debianutils/mktemp.c
index 7f60ca234..983d7a246 100644
--- a/debianutils/mktemp.c
+++ b/debianutils/mktemp.c
@@ -94,11 +94,7 @@ int mktemp_main(int argc UNUSED_PARAM, char **argv)
94 94
95 if (opts & OPT_u) { 95 if (opts & OPT_u) {
96 chp = mktemp(chp); 96 chp = mktemp(chp);
97#if !ENABLE_PLATFORM_MINGW32
98 if (chp[0] == '\0') 97 if (chp[0] == '\0')
99#else
100 if (chp == NULL || chp[0] == '\0')
101#endif
102 goto error; 98 goto error;
103 } else if (opts & OPT_d) { 99 } else if (opts & OPT_d) {
104 if (mkdtemp(chp) == NULL) 100 if (mkdtemp(chp) == NULL)
diff --git a/include/mingw.h b/include/mingw.h
index b3fc603c0..d6eb5d22c 100644
--- a/include/mingw.h
+++ b/include/mingw.h
@@ -164,12 +164,14 @@ int mingw_system(const char *cmd);
164 164
165int clearenv(void); 165int clearenv(void);
166char *mingw_getenv(const char *name); 166char *mingw_getenv(const char *name);
167char *mingw_mktemp(char *template);
167int mkstemp(char *template); 168int mkstemp(char *template);
168char *realpath(const char *path, char *resolved_path); 169char *realpath(const char *path, char *resolved_path);
169int setenv(const char *name, const char *value, int replace); 170int setenv(const char *name, const char *value, int replace);
170void unsetenv(const char *env); 171void unsetenv(const char *env);
171 172
172#define getenv mingw_getenv 173#define getenv mingw_getenv
174#define mktemp mingw_mktemp
173 175
174/* 176/*
175 * sys/ioctl.h 177 * sys/ioctl.h
diff --git a/win32/mingw.c b/win32/mingw.c
index b9f720e1a..70a8cb611 100644
--- a/win32/mingw.c
+++ b/win32/mingw.c
@@ -435,6 +435,20 @@ unsigned int sleep (unsigned int seconds)
435 return 0; 435 return 0;
436} 436}
437 437
438/*
439 * Windows' mktemp returns NULL on error whereas POSIX always returns the
440 * template and signals an error by making it an empty string.
441 */
442#undef mktemp
443char *mingw_mktemp(char *template)
444{
445 if ( mktemp(template) == NULL ) {
446 template[0] = '\0';
447 }
448
449 return template;
450}
451
438int mkstemp(char *template) 452int mkstemp(char *template)
439{ 453{
440 char *filename = mktemp(template); 454 char *filename = mktemp(template);