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.])],
22 dnl FIXME: having to put the closing square bracket on the
23 dnl FIXME: next line is a gross kludge to work around an
24 dnl FIXME: infelicity in how the new autoconf works.
25 dnl FIXME: This should be fixed pretty soon.
30 dnl Determine if the strftime function has all the features of the GNU one.
32 dnl From Jim Meyering.
34 AC_DEFUN(jm_FUNC_GNU_STRFTIME,
35 [AC_REQUIRE([AC_HEADER_TIME])dnl
39 AC_REQUIRE([AC_C_CONST])dnl
40 AC_REQUIRE([AC_HEADER_STDC])dnl
41 AC_CHECK_HEADERS(sys/time.h)
42 AC_CACHE_CHECK([for working GNU strftime], jm_cv_func_working_gnu_strftime,
44 changequote(<<, >>)dnl
45 << /* Ulrich Drepper provided parts of the test program. */
50 #if TIME_WITH_SYS_TIME
51 # include <sys/time.h>
55 # include <sys/time.h>
62 compare (const char *fmt, const struct tm *tm, const char *expected)
65 strftime (buf, 99, fmt, tm);
66 if (strcmp (buf, expected))
69 printf ("fmt: \"%s\", expected \"%s\", got \"%s\"\n",
82 time_t t = 738367; /* Fri Jan 9 13:06:07 1970 */
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);
145 jm_cv_func_working_gnu_strftime=yes,
146 jm_cv_func_working_gnu_strftime=no,
147 dnl When crosscompiling, assume strftime is missing or broken.
148 jm_cv_func_working_gnu_strftime=no)
150 if test $jm_cv_func_working_gnu_strftime = no; then
152 LIBOBJS="$LIBOBJS strftime.$ac_objext"
153 AC_DEFINE_UNQUOTED(strftime, gnu_strftime,
154 [Define to gnu_strftime if the replacement function should be used.])
158 AC_DEFUN(jm_FUNC_STRFTIME,
161 AC_REPLACE_FUNCS(strftime)