summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2017-04-18 13:48:18 +0200
committerChristophe Grenier <grenier@cgsecurity.org>2017-04-18 13:48:18 +0200
commit097541329828425a374210da147ce818b1d40e36 (patch)
treebdd422671c8e43bb1917531ecfc4c44de8850afa /src
parenta1419a0806b4270bfad92ea496624b2edee5062c (diff)
MinGW: use localtime() instead of localtime_r()
Fix for a1419a0806b4270bfad92ea496624b2edee5062c
Diffstat (limited to 'src')
-rw-r--r--src/common.c6
-rw-r--r--src/common.h2
-rw-r--r--src/dir.c6
3 files changed, 11 insertions, 3 deletions
diff --git a/src/common.c b/src/common.c
index a4458b3..2e12b07 100644
--- a/src/common.c
+++ b/src/common.c
@@ -167,7 +167,7 @@ char * strcasestr (const char *haystack, const char *needle)
}
#endif
-#ifndef HAVE_LOCALTIME_R
+#if ! defined(HAVE_LOCALTIME_R) && ! defined(__MINGW32__)
struct tm *localtime_r(const time_t *timep, struct tm *result)
{
return localtime(timep);
@@ -247,8 +247,12 @@ int date_dos2unix(const unsigned short f_time, const unsigned short f_date)
void set_secwest(void)
{
const time_t t = time(NULL);
+#if defined(__MINGW32__)
+ const struct tm *tmptr = localtime(&t);
+#else
struct tm tmp;
const struct tm *tmptr = localtime_r(&t,&tmp);
+#endif
#ifdef HAVE_STRUCT_TM_TM_GMTOFF
if(tmptr)
secwest = -1 * tmptr->tm_gmtoff;
diff --git a/src/common.h b/src/common.h
index 28bad5d..5094573 100644
--- a/src/common.h
+++ b/src/common.h
@@ -496,7 +496,7 @@ int strncasecmp(const char * s1, const char * s2, size_t len);
#ifndef HAVE_STRCASESTR
char * strcasestr (const char *haystack, const char *needle);
#endif
-#ifndef HAVE_LOCALTIME_R
+#if ! defined(HAVE_LOCALTIME_R) && ! defined(__MINGW32__)
struct tm *localtime_r(const time_t *timep, struct tm *result);
#endif
/*
diff --git a/src/dir.c b/src/dir.c
index 85b7689..7122d28 100644
--- a/src/dir.c
+++ b/src/dir.c
@@ -156,9 +156,13 @@ void mode_string (const unsigned int mode, char *str)
int set_datestr(char *datestr, size_t n, const time_t timev)
{
int test_date=0;
- struct tm tmp;
const struct tm *tm_p;
+#if defined(__MINGW32__)
+ if(timev!=0 && (tm_p= localtime(&timev))!=NULL)
+#else
+ struct tm tmp;
if(timev!=0 && (tm_p= localtime_r(&timev, &tmp))!=NULL)
+#endif
{
snprintf(datestr, n,"%2d-%s-%4d %02d:%02d",
tm_p->tm_mday, monstr[tm_p->tm_mon],