[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 5/8] Fix compat.c compilation with mingw32
From: |
Ladislav Michl |
Subject: |
[PATCH 5/8] Fix compat.c compilation with mingw32 |
Date: |
Tue, 4 Dec 2018 22:25:42 +0100 |
User-agent: |
Mutt/1.10.1 (2018-07-13) |
Guard Windows version of setenv with HAVE_SETENV for setups
where setenv is already provided.
---
common/compat.c | 24 +++++++++++++-----------
1 file changed, 13 insertions(+), 11 deletions(-)
diff --git a/common/compat.c b/common/compat.c
index 35673caa..99b777f1 100644
--- a/common/compat.c
+++ b/common/compat.c
@@ -15,13 +15,10 @@
#include "compat.h"
+#ifndef HAVE_SETENV
+
#ifdef WIN32
# include <windows.h>
-# include <sys/timeb.h>
-# include <time.h>
-# define ftime _ftime
-# define timeb _timeb
-
int setenv(const char *name, const char *value, int overwrite)
{
return (int)SetEnvironmentVariable(name, value);
@@ -32,10 +29,7 @@ int unsetenv(const char *name)
SetEnvironmentVariable(name, NULL);
return 0;
}
-
-#endif
-
-#ifndef HAVE_SETENV
+#else
# include <stdlib.h>
/* Implemented according to http://www.greenend.org.uk/rjk/2008/putenv.html
and Linux manpage */
int setenv(const char *envname, const char *envvalue, int overwrite)
@@ -65,12 +59,21 @@ int unsetenv(const char *name)
}
#endif
+#endif
+
#ifdef HAVE_SYS_TIME_H
# include <sys/time.h>
#endif
#ifndef HAVE_GETTIMEOFDAY
+#ifdef WIN32
+# include <sys/timeb.h>
+# include <time.h>
+# define ftime _ftime
+# define timeb _timeb
+#endif
+
int gettimeofday(struct timeval *tv, void *tz)
{
struct timeb t;
@@ -88,7 +91,6 @@ int gettimeofday(struct timeval *tv, void *tz)
#endif
-
#ifndef HAVE_STRSEP
/*
@@ -149,7 +151,7 @@ char *strsep(char **stringp, const char *delim)
register const char *spanp;
register int c, sc;
char *tok;
-
+
if ((s = *stringp) == NULL)
return (NULL);
for (tok = s;;) {
--
2.20.0.rc2
- [PATCH v2 2/8] Use lower case for Win32 includes, (continued)
[PATCH v2 4/8] Test for number of mkdir() arguments, Ladislav Michl, 2018/12/04
[PATCH 8/8] Remove cfg_foreach, Ladislav Michl, 2018/12/04
[PATCH v2 6/8] Refactor devices build, Ladislav Michl, 2018/12/04
[PATCH v2 7/8] Use posix_spawn to run external scripts, Ladislav Michl, 2018/12/04
[PATCH 5/8] Fix compat.c compilation with mingw32,
Ladislav Michl <=