3 dnl This macro is intended to be used solely in this file.
4 dnl These are the prerequisite macros for GNU's strftime.c replacement.
5 AC_DEFUN(_jm_STRFTIME_PREREQS,
7 dnl strftime.c uses localtime_r if it exists. Check for it.
8 AC_CHECK_FUNCS(localtime_r)
10 AC_CHECK_HEADERS(limits.h)
11 AC_CHECK_FUNCS(bcopy tzset mempcpy memcpy memset)
13 # This defines (or not) HAVE_TZNAME and HAVE_TM_ZONE.
16 AC_CHECK_FUNCS(mblen mbrlen)
18 AC_CHECK_MEMBER(struct tm.tm_gmtoff,
19 [AC_DEFINE(HAVE_TM_GMTOFF, 1,
20 [Define if struct tm has the tm_gmtoff member.])],
25 dnl Determine if the strftime function has all the features of the GNU one.
27 dnl From Jim Meyering.
29 AC_DEFUN(jm_FUNC_GNU_STRFTIME,
30 [AC_REQUIRE([AC_HEADER_TIME])dnl
34 AC_REQUIRE([AC_C_CONST])dnl
35 AC_REQUIRE([AC_HEADER_STDC])dnl
36 AC_CHECK_HEADERS(sys/time.h)
37 AC_CACHE_CHECK([for working GNU strftime], jm_cv_func_working_gnu_strftime,
38 [# Set TZ to GMT0 to make strftime give consistent results during the test.
39 ac_save_TZ="${TZ-GMT0}"
43 [ /* Ulrich Drepper provided parts of the test program. */
48 #if TIME_WITH_SYS_TIME
49 # include <sys/time.h>
53 # include <sys/time.h>
60 compare (const char *fmt, const struct tm *tm, const char *expected)
63 strftime (buf, 99, fmt, tm);
64 if (strcmp (buf, expected))
67 printf ("fmt: \"%s\", expected \"%s\", got \"%s\"\n",
80 time_t t = 738367; /* Fri Jan 9 13:06:07 1970 */
84 #define CMP(Fmt, Expected) n_fail += compare ((Fmt), tm, (Expected))
86 CMP ("%-m", "1"); /* GNU */
88 CMP ("%^A", "FRIDAY"); /* The ^ is a GNU extension. */
89 CMP ("%B", "January");
90 CMP ("%^B", "JANUARY");
91 CMP ("%C", "19"); /* POSIX.2 */
92 CMP ("%D", "01/09/70"); /* POSIX.2 */
93 CMP ("%F", "1970-01-09");
94 CMP ("%G", "1970"); /* GNU */
99 CMP ("%R", "13:06"); /* POSIX.2 */
101 CMP ("%T", "13:06:07"); /* POSIX.2 */
105 CMP ("%X", "13:06:07");
108 CMP ("%_m", " 1"); /* GNU */
113 CMP ("%c", "Fri Jan 9 13:06:07 1970");
114 CMP ("%^c", "FRI JAN 9 13:06:07 1970");
116 CMP ("%e", " 9"); /* POSIX.2 */
117 CMP ("%g", "70"); /* GNU */
118 CMP ("%h", "Jan"); /* POSIX.2 */
121 CMP ("%k", "13"); /* GNU */
122 CMP ("%l", " 1"); /* GNU */
124 CMP ("%n", "\n"); /* POSIX.2 */
126 CMP ("%r", "01:06:07 PM"); /* POSIX.2 */
127 CMP ("%s", "738367"); /* GNU */
128 CMP ("%t", "\t"); /* POSIX.2 */
129 CMP ("%u", "5"); /* POSIX.2 */
131 CMP ("%x", "01/09/70");
133 CMP ("%z", "+0000"); /* GNU */
135 exit (n_fail ? 1 : 0);
137 jm_cv_func_working_gnu_strftime=yes,
138 jm_cv_func_working_gnu_strftime=no,
139 dnl When crosscompiling, assume strftime is missing or broken.
140 jm_cv_func_working_gnu_strftime=no)
141 dnl If TZ wasn't set before, this sets it to GMT0. No real harm done.
144 if test $jm_cv_func_working_gnu_strftime = no; then
146 LIBOBJS="$LIBOBJS strftime.$ac_objext"
147 AC_DEFINE_UNQUOTED(strftime, gnu_strftime,
148 [Define to gnu_strftime if the replacement function should be used.])
152 AC_DEFUN(jm_FUNC_STRFTIME,
155 AC_REPLACE_FUNCS(strftime)