]> granicus.if.org Git - check/commitdiff
libcompat: remove alternatives for localtime_r
authorbrarcher <brarcher@64e312b2-a51f-0410-8e61-82d0ca0eb02a>
Mon, 6 Jan 2014 04:41:41 +0000 (04:41 +0000)
committerbrarcher <brarcher@64e312b2-a51f-0410-8e61-82d0ca0eb02a>
Mon, 6 Jan 2014 04:41:41 +0000 (04:41 +0000)
returning to the previous localtime_r implementation that uses
localtime. The _localtime64_s implementation had issues, in that
it wanted to write to the "now" variable. (Should have been
passed "result" instead). Further, on MSVC (for which this replacement
is being considered) localtime redirects to _localtime64_s anyway.

For how Check is using localtime_r, just using localtime is
sufficient.

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@1038 64e312b2-a51f-0410-8e61-82d0ca0eb02a

CMakeLists.txt
lib/localtime_r.c

index 939bec8459d8a6681c46b23f261d127a64ddd5c5..41315c106f11946719d00f0d6a8839f27a7d608b 100644 (file)
@@ -104,7 +104,6 @@ check_function_exists(fork HAVE_FORK)
 check_function_exists(getpid HAVE_GETPID)
 check_function_exists(gettimeofday HAVE_GETTIMEOFDAY)
 check_function_exists(localtime_r HAVE_DECL_LOCALTIME_R)
-check_function_exists(localtime_s HAVE_LOCALTIME_S)
 check_function_exists(malloc HAVE_MALLOC)
 check_function_exists(realloc HAVE_REALLOC)
 check_function_exists(setenv HAVE_DECL_SETENV)
@@ -112,7 +111,6 @@ check_function_exists(sigaction HAVE_SIGACTION)
 check_function_exists(strdup HAVE_DECL_STRDUP)
 check_function_exists(strsignal HAVE_DECL_STRSIGNAL)
 check_function_exists(_getpid HAVE__GETPID)
-check_function_exists(_localtime64_s HAVE__LOCALTIME64_S)
 check_function_exists(_strdup HAVE__STRDUP)
 
 # printf related checks
index d9e9000d23b89d60ed3eec1f83c365d523b21043..081b01fdea90be097398931c2a23eb7adc520774 100644 (file)
@@ -4,20 +4,16 @@
 
 struct tm * localtime_r (const time_t *clock, struct tm *result)
 {
-    struct tm *now = NULL;
-
-#if HAVE_LOCALTIME_S
-    localtime_s (now, clock)
-#elif HAVE__LOCALTIME64_S
-    _localtime64_s (now, clock);
-#else
-    now = localtime (clock);
-#endif /* !HAVE_LOCALTIME_S */
-
-    if (now != NULL)
+    struct tm *now = localtime (clock);
+    if (now == NULL)
     {
-      *result = *now;
+        return NULL;
     }
+    else
+    {
+        *result = *now;
+    }
+
     return result;
 }