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)],
21 dnl FIXME: having to put the closing square bracket on the
22 dnl FIXME: next line is a gross kludge to work around an
23 dnl FIXME: infelicity in how the new autoconf works.
24 dnl FIXME: This should be fixed pretty soon.
29 dnl Determine if the strftime function has all the features of the GNU one.
31 dnl From Jim Meyering.
33 AC_DEFUN(jm_FUNC_GNU_STRFTIME,
34 [AC_REQUIRE([AC_HEADER_TIME])dnl
38 AC_REQUIRE([AC_C_CONST])dnl
39 AC_REQUIRE([AC_HEADER_STDC])dnl
40 AC_CHECK_HEADERS(sys/time.h)
41 AC_CACHE_CHECK([for working GNU strftime], jm_cv_func_working_gnu_strftime,
43 changequote(<<, >>)dnl
44 << /* Ulrich Drepper provided parts of the test program. */
49 #if TIME_WITH_SYS_TIME
50 # include <sys/time.h>
54 # include <sys/time.h>
61 compare (const char *fmt, const struct tm *tm, const char *expected)
64 strftime (buf, 99, fmt, tm);
65 if (strcmp (buf, expected))
68 printf ("fmt: \"%s\", expected \"%s\", got \"%s\"\n",
81 time_t t = 738367; /* Fri Jan 9 13:06:07 1970 */
84 /* This is necessary to make strftime give consistent zone strings and
85 e.g., seconds since the epoch (%s). */
89 #define CMP(Fmt, Expected) n_fail += compare ((Fmt), tm, (Expected))
91 CMP ("%-m", "1"); /* GNU */
93 CMP ("%^A", "FRIDAY"); /* The ^ is a GNU extension. */
94 CMP ("%B", "January");
95 CMP ("%^B", "JANUARY");
96 CMP ("%C", "19"); /* POSIX.2 */
97 CMP ("%D", "01/09/70"); /* POSIX.2 */
98 CMP ("%F", "1970-01-09");
99 CMP ("%G", "1970"); /* GNU */
104 CMP ("%R", "13:06"); /* POSIX.2 */
106 CMP ("%T", "13:06:07"); /* POSIX.2 */
110 CMP ("%X", "13:06:07");
113 CMP ("%_m", " 1"); /* GNU */
118 CMP ("%c", "Fri Jan 9 13:06:07 1970");
119 CMP ("%^c", "FRI JAN 9 13:06:07 1970");
121 CMP ("%e", " 9"); /* POSIX.2 */
122 CMP ("%g", "70"); /* GNU */
123 CMP ("%h", "Jan"); /* POSIX.2 */
126 CMP ("%k", "13"); /* GNU */
127 CMP ("%l", " 1"); /* GNU */
129 CMP ("%n", "\n"); /* POSIX.2 */
131 CMP ("%r", "01:06:07 PM"); /* POSIX.2 */
132 CMP ("%s", "738367"); /* GNU */
133 CMP ("%t", "\t"); /* POSIX.2 */
134 CMP ("%u", "5"); /* POSIX.2 */
136 CMP ("%x", "01/09/70");
138 CMP ("%z", "+0000"); /* GNU */
140 exit (n_fail ? 1 : 0);
144 jm_cv_func_working_gnu_strftime=yes,
145 jm_cv_func_working_gnu_strftime=no,
146 dnl When crosscompiling, assume strftime is missing or broken.
147 jm_cv_func_working_gnu_strftime=no)
149 if test $jm_cv_func_working_gnu_strftime = no; then
151 LIBOBJS="$LIBOBJS strftime.$ac_objext"
152 AC_DEFINE_UNQUOTED(strftime, gnu_strftime,
153 [Define to gnu_strftime if the replacement function should be used.])
157 AC_DEFUN(jm_FUNC_STRFTIME,
160 AC_REPLACE_FUNCS(strftime)