[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 6/8] Fix compat.c compilation with mingw32
From: |
Ladislav Michl |
Subject: |
[PATCH 6/8] Fix compat.c compilation with mingw32 |
Date: |
Mon, 3 Dec 2018 10:42:47 +0100 |
User-agent: |
Mutt/1.10.1 (2018-07-13) |
Compilation fails with both HAVE_SETENV and WIN32 set.
---
common/compat.c | 24 +++++++++++++-----------
1 file changed, 13 insertions(+), 11 deletions(-)
diff --git a/common/compat.c b/common/compat.c
index a1e1a9b5..48a4637a 100644
--- a/common/compat.c
+++ b/common/compat.c
@@ -16,13 +16,10 @@
#include "config.h"
#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);
@@ -33,10 +30,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)
@@ -66,12 +60,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;
@@ -89,7 +92,6 @@ int gettimeofday(struct timeval *tv, void *tz)
#endif
-
#ifndef HAVE_STRSEP
/*
@@ -150,7 +152,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.rc1
[PATCH 6/8] Fix compat.c compilation with mingw32,
Ladislav Michl <=
[PATCH 8/8] Refactor devices build, Ladislav Michl, 2018/12/03