summaryrefslogtreecommitdiff
path: root/src/lib/evil
diff options
context:
space:
mode:
authorVincent Torri <vincent.torri@gmail.com>2014-10-19 20:24:50 +0200
committerCedric BAIL <cedric@osg.samsung.com>2014-10-20 18:40:12 +0200
commitf69649ae33bea97b88a2794bf4140cd68efe6a92 (patch)
tree445a3413a5beddb9371f1b0283ecdd05c843108c /src/lib/evil
parent7f9a82db0362812c20bf95ccc493471738fa52e1 (diff)
evil: simplify implementation of localtime_r
@fix
Diffstat (limited to 'src/lib/evil')
-rw-r--r--src/lib/evil/evil_time.c26
-rw-r--r--src/lib/evil/evil_time.h14
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 @@
5#include <strings.h> 5#include <strings.h>
6#include <inttypes.h> 6#include <inttypes.h>
7#include <ctype.h> 7#include <ctype.h>
8#define _POSIX /* FIXME: to be removed when mingw-w64 will be fixed */
9#include <time.h> 8#include <time.h>
10 9
11#include "Evil.h" 10#include "Evil.h"
12#include "evil_private.h" 11#include "evil_private.h"
13 12
14#ifndef localtime_r
15
16struct tm * 13struct tm *
17localtime_r(const time_t *timep, struct tm *result) 14evil_localtime_r(const time_t *timep, struct tm *result)
18{ 15{
19# ifndef _MSC_VER 16 _localtime64_s(result, timep);
20 struct tm *tmp;
21# endif /* ! _MSC_VER */
22
23 if (!timep || !result)
24 return NULL;
25
26# ifdef _MSC_VER
27 if (localtime_s(result, timep) != 0)
28 return NULL;
29# else
30 tmp = localtime(timep);
31 if (!tmp)
32 return NULL;
33
34 memcpy(result, tmp, sizeof(struct tm));
35
36# endif /* ! _MSC_VER */
37 17
38 return result; 18 return result;
39} 19}
40 20
41#endif /* localtime_r */
42
43/* 21/*
44 * strptime 22 * strptime
45 * based on http://cvsweb.netbsd.org/bsdweb.cgi/src/lib/libc/time/strptime.c?rev=HEAD 23 * 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 @@
14 */ 14 */
15 15
16 16
17#ifndef localtime_r
18
19/** 17/**
20 * @brief Convert the calendar time to broken-time representation in a 18 * @brief Convert the calendar time to broken-time representation in a
21 * user supplied data. 19 * user supplied data.
@@ -34,9 +32,17 @@
34 * 32 *
35 * Supported OS: Windows XP. 33 * Supported OS: Windows XP.
36 */ 34 */
37EAPI struct tm *localtime_r(const time_t *timep, struct tm *result); 35EAPI struct tm *evil_localtime_r(const time_t *timep, struct tm *result);
38 36
39#endif /* localtime_r */ 37/**
38 * @def localtime_r(t, r)
39 *
40 * Wrapper around evil_localtime_r().
41 */
42#ifdef localtime_r
43# undef localtime_r
44#endif
45#define localtime_r(t, r) evil_localtime_r(t, r)
40 46
41/** 47/**
42 * @brief Convert a string representation of time to a time tm structure . 48 * @brief Convert a string representation of time to a time tm structure .