From f69649ae33bea97b88a2794bf4140cd68efe6a92 Mon Sep 17 00:00:00 2001 From: Vincent Torri Date: Sun, 19 Oct 2014 20:24:50 +0200 Subject: [PATCH] evil: simplify implementation of localtime_r @fix --- src/lib/evil/evil_time.c | 26 ++------------------------ src/lib/evil/evil_time.h | 14 ++++++++++---- 2 files changed, 12 insertions(+), 28 deletions(-) diff --git a/src/lib/evil/evil_time.c b/src/lib/evil/evil_time.c index 9bb1ebd..9e6fd5c 100644 --- a/src/lib/evil/evil_time.c +++ b/src/lib/evil/evil_time.c @@ -5,41 +5,19 @@ #include #include #include -#define _POSIX /* FIXME: to be removed when mingw-w64 will be fixed */ #include #include "Evil.h" #include "evil_private.h" -#ifndef localtime_r - struct tm * -localtime_r(const time_t *timep, struct tm *result) +evil_localtime_r(const time_t *timep, struct tm *result) { -# ifndef _MSC_VER - struct tm *tmp; -# endif /* ! _MSC_VER */ - - if (!timep || !result) - return NULL; - -# ifdef _MSC_VER - if (localtime_s(result, timep) != 0) - return NULL; -# else - tmp = localtime(timep); - if (!tmp) - return NULL; - - memcpy(result, tmp, sizeof(struct tm)); - -# endif /* ! _MSC_VER */ + _localtime64_s(result, timep); return result; } -#endif /* localtime_r */ - /* * strptime * based on http://cvsweb.netbsd.org/bsdweb.cgi/src/lib/libc/time/strptime.c?rev=HEAD diff --git a/src/lib/evil/evil_time.h b/src/lib/evil/evil_time.h index e137cbd..c65115a 100644 --- a/src/lib/evil/evil_time.h +++ b/src/lib/evil/evil_time.h @@ -14,8 +14,6 @@ */ -#ifndef localtime_r - /** * @brief Convert the calendar time to broken-time representation in a * user supplied data. @@ -34,9 +32,17 @@ * * Supported OS: Windows XP. */ -EAPI struct tm *localtime_r(const time_t *timep, struct tm *result); +EAPI struct tm *evil_localtime_r(const time_t *timep, struct tm *result); -#endif /* localtime_r */ +/** + * @def localtime_r(t, r) + * + * Wrapper around evil_localtime_r(). + */ +#ifdef localtime_r +# undef localtime_r +#endif +#define localtime_r(t, r) evil_localtime_r(t, r) /** * @brief Convert a string representation of time to a time tm structure . -- 2.7.4