lib/replace: define HAVE_WORKING_STRPTIME instead of REPLACE_STRPTIME
authorStefan Metzmacher <metze@samba.org>
Mon, 11 Jun 2012 07:11:17 +0000 (09:11 +0200)
committerStefan Metzmacher <metze@samba.org>
Thu, 14 Jun 2012 07:34:14 +0000 (09:34 +0200)
That makes the logic in 'wscript' simpler.

metze

lib/replace/replace.h
lib/replace/strptime.m4
lib/replace/wscript

index 776da8aa4a13d97cf64d044ef942802c50de1ed4..bb271d45fabd49e0eeba81017e6ff0430ab6a1d1 100644 (file)
@@ -451,7 +451,7 @@ void rep_vsyslog (int facility_priority, const char *format, va_list arglist) PR
 typedef int (*comparison_fn_t)(const void *, const void *);
 #endif
 
-#ifdef REPLACE_STRPTIME
+#ifndef HAVE_WORKING_STRPTIME
 #define strptime rep_strptime
 struct tm;
 char *rep_strptime(const char *buf, const char *format, struct tm *tm);
index b1a56b4aab17cc8f094edb65ecab5b16b81c48de..8ac22f63426a4662d7b90bce2e128b2504612039 100644 (file)
@@ -1,3 +1,5 @@
+AC_CHECK_FUNCS(strptime)
+AC_CHECK_DECLS(strptime, [], [], [#include <time.h>])
 AC_CACHE_CHECK([whether strptime is available and works],libreplace_cv_STRPTIME_OK,[
        AC_TRY_RUN([
                #define LIBREPLACE_CONFIGURE_TEST_STRPTIME
@@ -8,6 +10,7 @@ AC_CACHE_CHECK([whether strptime is available and works],libreplace_cv_STRPTIME_
                [libreplace_cv_STRPTIME_OK="assuming not"])
 ])
 if test x"$libreplace_cv_STRPTIME_OK" != x"yes"; then
-        AC_DEFINE(REPLACE_STRPTIME,1,[Whether strptime should be replaced])
         LIBREPLACEOBJ="${LIBREPLACEOBJ} $libreplacedir/strptime.o"
+else
+        AC_DEFINE(HAVE_WORKING_STRPTIME,1,[Whether strptime is working correct])
 fi
index 743b5fe63299ff4bc38f37de3b8b8728fb98a6e7..7e4055ba9ad7611600b8933bdac364bf182d9004 100644 (file)
@@ -311,13 +311,14 @@ removeea setea
     conf.CHECK_HEADERS('poll.h')
     conf.CHECK_FUNCS('poll')
 
-    if not conf.CHECK_CODE('''#define LIBREPLACE_CONFIGURE_TEST_STRPTIME
-                           #include "test/strptime.c"''',
-                           define='HAVE_STRPTIME',
-                           execute=True,
-                           addmain=False,
-                           msg='Checking for working strptime'):
-        conf.DEFINE('REPLACE_STRPTIME', 1)
+    conf.CHECK_FUNCS('strptime')
+    conf.CHECK_DECLS('strptime', headers='time.h')
+    conf.CHECK_CODE('''#define LIBREPLACE_CONFIGURE_TEST_STRPTIME
+                       #include "test/strptime.c"''',
+                       define='HAVE_WORKING_STRPTIME',
+                       execute=True,
+                       addmain=False,
+                       msg='Checking for working strptime')
 
     conf.CHECK_CODE('gettimeofday(NULL, NULL)', 'HAVE_GETTIMEOFDAY_TZ', execute=False)
 
@@ -460,6 +461,9 @@ REPLACEMENT_FUNCTIONS = {
     # Note: C99_VSNPRINTF is not a function, but a special condition
     # for replacement
     'snprintf.c': ['C99_VSNPRINTF', 'snprintf', 'vsnprintf', 'asprintf', 'vasprintf'],
+    # Note: WORKING_STRPTIME is not a function, but a special condition
+    # for replacement
+    'strptime.c': ['WORKING_STRPTIME', 'strptime'],
     }
 
 
@@ -468,7 +472,6 @@ def build(bld):
 
     REPLACE_HOSTCC_SOURCE = ''
 
-    if bld.CONFIG_SET('REPLACE_STRPTIME'):       REPLACE_HOSTCC_SOURCE += ' strptime.c'
     for filename, functions in REPLACEMENT_FUNCTIONS.iteritems():
         for function in functions:
             if not bld.CONFIG_SET('HAVE_%s' % function.upper()):