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 and the underyling system strftime
9 AC_CHECK_FUNCS(localtime_r strftime)
11 AC_CHECK_HEADERS(limits.h)
12 AC_CHECK_FUNCS(bcopy tzset mempcpy memcpy memset)
14 # This defines (or not) HAVE_TZNAME and HAVE_TM_ZONE.
17 AC_CHECK_FUNCS(mblen mbrlen)
19 AC_CHECK_MEMBER([struct tm.tm_gmtoff],
20 [AC_DEFINE(HAVE_TM_GMTOFF, 1,
21 [Define if struct tm has the tm_gmtoff member.])],
26 dnl Determine if the strftime function has all the features of the GNU one.
28 dnl From Jim Meyering.
30 AC_DEFUN(jm_FUNC_GNU_STRFTIME,
31 [AC_REQUIRE([AC_HEADER_TIME])dnl
35 AC_REQUIRE([AC_C_CONST])dnl
36 AC_REQUIRE([AC_HEADER_STDC])dnl
37 AC_CHECK_HEADERS(sys/time.h)
38 AC_CACHE_CHECK([for working GNU strftime], jm_cv_func_working_gnu_strftime,
40 [ /* Ulrich Drepper provided parts of the test program. */
45 #if TIME_WITH_SYS_TIME
46 # include <sys/time.h>
50 # include <sys/time.h>
57 compare (const char *fmt, const struct tm *tm, const char *expected)
60 strftime (buf, 99, fmt, tm);
61 if (strcmp (buf, expected))
64 printf ("fmt: \"%s\", expected \"%s\", got \"%s\"\n",
77 time_t t = 738367; /* Fri Jan 9 13:06:07 1970 */
80 /* Undefine this in case the configure-time putenv test has defined it
81 to something else. The use we make of this function here doesn't
82 require the added functionality of the replacement one. */
85 /* This is necessary to make strftime give consistent zone strings and
86 e.g., seconds since the epoch (%s). */
90 #define CMP(Fmt, Expected) n_fail += compare ((Fmt), tm, (Expected))
92 CMP ("%-m", "1"); /* GNU */
94 CMP ("%^A", "FRIDAY"); /* The ^ is a GNU extension. */
95 CMP ("%B", "January");
96 CMP ("%^B", "JANUARY");
97 CMP ("%C", "19"); /* POSIX.2 */
98 CMP ("%D", "01/09/70"); /* POSIX.2 */
99 CMP ("%F", "1970-01-09");
100 CMP ("%G", "1970"); /* GNU */
105 CMP ("%R", "13:06"); /* POSIX.2 */
107 CMP ("%T", "13:06:07"); /* POSIX.2 */
111 CMP ("%X", "13:06:07");
114 CMP ("%_m", " 1"); /* GNU */
119 CMP ("%c", "Fri Jan 9 13:06:07 1970");
120 CMP ("%^c", "FRI JAN 9 13:06:07 1970");
122 CMP ("%e", " 9"); /* POSIX.2 */
123 CMP ("%g", "70"); /* GNU */
124 CMP ("%h", "Jan"); /* POSIX.2 */
127 CMP ("%k", "13"); /* GNU */
128 CMP ("%l", " 1"); /* GNU */
130 CMP ("%n", "\n"); /* POSIX.2 */
132 CMP ("%r", "01:06:07 PM"); /* POSIX.2 */
133 CMP ("%s", "738367"); /* GNU */
134 CMP ("%t", "\t"); /* POSIX.2 */
135 CMP ("%u", "5"); /* POSIX.2 */
137 CMP ("%x", "01/09/70");
139 CMP ("%z", "+0000"); /* GNU */
141 exit (n_fail ? 1 : 0);
143 jm_cv_func_working_gnu_strftime=yes,
144 jm_cv_func_working_gnu_strftime=no,
145 dnl When crosscompiling, assume strftime is missing or broken.
146 jm_cv_func_working_gnu_strftime=no)
148 if test $jm_cv_func_working_gnu_strftime = no; then
150 AC_DEFINE_UNQUOTED(strftime, gnu_strftime,
151 [Define to gnu_strftime if the replacement function should be used.])
155 AC_DEFUN(jm_FUNC_STRFTIME,
158 AC_REPLACE_FUNCS(strftime)