diff --git a/configure.ac b/configure.ac index 9797b8c..af1d25a 100644 --- a/configure.ac +++ b/configure.ac @@ -16,6 +16,7 @@ AC_PROG_CC_STDC AC_PROG_CXX AC_PROG_INSTALL AC_CHECK_FUNC(gettimeofday, AC_DEFINE(HAVE_GETTIMEOFDAY, 1, [Defines if gettimeofday is available on your system])) +AC_CHECK_FUNC(localtime_r, AC_DEFINE(HAVE_LOCALTIME_R, 1, [Defines if localtime_r is available on your system])) dnl Enable these unconditionally. AC_DEFINE([OPI_SUPPORT], [1], [Generate OPI comments in PS output.]) diff --git a/glib/test-poppler-glib.c b/glib/test-poppler-glib.c index 007353c..6c8e840 100644 --- a/glib/test-poppler-glib.c +++ b/glib/test-poppler-glib.c @@ -3,6 +3,7 @@ #include #include #include "poppler.h" +#include "config.h" #define FAIL(msg) \ do { fprintf (stderr, "FAIL: %s\n", msg); exit (-1); } while (0) @@ -11,14 +12,19 @@ static gchar * poppler_format_date (GTime utime) { time_t time = (time_t) utime; - struct tm t; char s[256]; const char *fmt_hack = "%c"; size_t len; - +#ifdef HAVE_LOCALTIME_R + struct tm t; if (time == 0 || !localtime_r (&time, &t)) return NULL; - len = strftime (s, sizeof (s), fmt_hack, &t); +#else + struct tm *t; + if (time == 0 || !(t = localtime (&time)) ) return NULL; + len = strftime (s, sizeof (s), fmt_hack, t); +#endif + if (len == 0 || s[0] == '\0') return NULL; return g_locale_to_utf8 (s, -1, NULL, NULL, NULL);