Get the prototype for strptime() when it's available
authorEmilio Pozuelo Monfort <pochu27@gmail.com>
Thu, 17 Dec 2009 21:03:06 +0000 (22:03 +0100)
committerEmilio Pozuelo Monfort <pochu27@gmail.com>
Thu, 17 Dec 2009 21:03:06 +0000 (22:03 +0100)
Instead of only getting it on Linux. Also use nl_langinfo()
when available, and not only on Linux.

https://bugzilla.gnome.org/show_bug.cgi?id=604858

configure.ac
libedataserver/e-time-utils.c

index f6e449c..ae9f70a 100644 (file)
@@ -269,7 +269,7 @@ AC_FUNC_ALLOCA
 dnl ******************************
 dnl Checks for functions
 dnl ******************************
-AC_CHECK_FUNCS(fsync strptime strtok_r)
+AC_CHECK_FUNCS(fsync strptime strtok_r nl_langinfo)
 
 dnl ***********************************
 dnl Check for base dependencies early.
index 73759c5..7fd2cc2 100644 (file)
@@ -9,19 +9,14 @@
  */
 
 #include <config.h>
-
-#ifdef __linux__
-/* We need this to get a prototype for strptime. */
-#define _GNU_SOURCE
-#endif /* __linux__ */
+#define _XOPEN_SOURCE
 
 #include <time.h>
 #include <sys/time.h>
 
-#ifdef __linux__
+#ifdef HAVE_NL_LANGINFO
 #include <langinfo.h>
-#undef _GNU_SOURCE
-#endif /* __linux__ */
+#endif /* HAVE_NL_LANGINFO */
 
 #include <string.h>
 #include <ctype.h>
@@ -2028,7 +2023,7 @@ e_time_get_d_fmt_with_4digit_year (void)
 {
        gchar *p;
        gchar *res = NULL;
-#if defined(__linux__)
+#if defined(HAVE_NL_LANGINFO)
        res = g_strdup (nl_langinfo (D_FMT) );
 #elif defined(G_OS_WIN32)
   #define GET_LOCALE_INFO(str, len) GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SLONGDATE, str, len)