diff options
author | Vincent Torri <vincent.torri@gmail.com> | 2014-10-19 20:24:50 +0200 |
---|---|---|
committer | Cedric BAIL <cedric@osg.samsung.com> | 2014-10-20 18:40:12 +0200 |
commit | f69649ae33bea97b88a2794bf4140cd68efe6a92 (patch) | |
tree | 445a3413a5beddb9371f1b0283ecdd05c843108c | |
parent | 7f9a82db0362812c20bf95ccc493471738fa52e1 (diff) | |
download | efl-f69649ae33bea97b88a2794bf4140cd68efe6a92.tar.gz |
evil: simplify implementation of localtime_r
@fix
-rw-r--r-- | src/lib/evil/evil_time.c | 26 | ||||
-rw-r--r-- | 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 9bb1ebdf85..9e6fd5c3f2 100644 --- a/src/lib/evil/evil_time.c +++ b/src/lib/evil/evil_time.c @@ -5,41 +5,19 @@ #include <strings.h> #include <inttypes.h> #include <ctype.h> -#define _POSIX /* FIXME: to be removed when mingw-w64 will be fixed */ #include <time.h> #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 e137cbdf0b..c65115abb2 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 . |