3 AC_DEFUN(jm_STRFTIME_PREREQS,
5 dnl strftime.c uses localtime_r if it exists. Check for it.
6 AC_CHECK_FUNCS(localtime_r)
7 dnl FIXME: add tests for everything in strftime.c: e.g., HAVE_BCOPY,
8 dnl HAVE_TZNAME, HAVE_TZSET, HAVE_TM_ZONE, etc.
11 dnl From Jim Meyering.
12 dnl If you use this macro in a package, you should
13 dnl add the following two lines to acconfig.h:
14 dnl /* Define to gnu_strftime if the replacement function should be used. */
17 AC_DEFUN(jm_FUNC_GNU_STRFTIME,
18 [AC_REQUIRE([AC_HEADER_TIME])dnl
22 AC_REQUIRE([AC_C_CONST])dnl
23 AC_REQUIRE([AC_HEADER_STDC])dnl
24 AC_CHECK_HEADERS(sys/time.h)
25 AC_CACHE_CHECK([for working GNU strftime], jm_cv_func_working_gnu_strftime,
27 changequote(<<, >>)dnl
28 << /* Ulrich Drepper provided parts of the test program. */
33 #if TIME_WITH_SYS_TIME
34 # include <sys/time.h>
38 # include <sys/time.h>
45 compare (const char *fmt, const struct tm *tm, const char *expected)
48 strftime (buf, 99, fmt, tm);
49 if (strcmp (buf, expected))
52 printf ("fmt: \"%s\", expected \"%s\", got \"%s\"\n",
65 time_t t = 738367; /* Fri Jan 9 13:06:07 1970 */
68 /* This is necessary to make strftime give consistent zone strings and
69 e.g., seconds since the epoch (%s). */
73 #define CMP(Fmt, Expected) n_fail += compare ((Fmt), tm, (Expected))
75 CMP ("%-m", "1"); /* GNU */
77 CMP ("%^A", "FRIDAY"); /* The ^ is a GNU extension. */
78 CMP ("%B", "January");
79 CMP ("%^B", "JANUARY");
80 CMP ("%C", "19"); /* POSIX.2 */
81 CMP ("%D", "01/09/70"); /* POSIX.2 */
82 CMP ("%G", "1970"); /* GNU */
87 CMP ("%R", "13:06"); /* POSIX.2 */
89 CMP ("%T", "13:06:07"); /* POSIX.2 */
93 CMP ("%X", "13:06:07");
96 CMP ("%_m", " 1"); /* GNU */
101 CMP ("%c", "Fri Jan 9 13:06:07 1970");
102 CMP ("%^c", "FRI JAN 9 13:06:07 1970");
104 CMP ("%e", " 9"); /* POSIX.2 */
105 CMP ("%f", "5"); /* POSIX.2 */
106 CMP ("%g", "70"); /* GNU */
107 CMP ("%h", "Jan"); /* POSIX.2 */
110 CMP ("%k", "13"); /* GNU */
111 CMP ("%l", " 1"); /* GNU */
113 CMP ("%n", "\n"); /* POSIX.2 */
115 CMP ("%r", "01:06:07 PM"); /* POSIX.2 */
116 CMP ("%s", "738367"); /* GNU */
117 CMP ("%t", "\t"); /* POSIX.2 */
118 CMP ("%u", "5"); /* POSIX.2 */
120 CMP ("%x", "01/09/70");
122 CMP ("%z", "+0000"); /* GNU */
124 exit (n_fail ? 1 : 0);
128 jm_cv_func_working_gnu_strftime=yes,
129 jm_cv_func_working_gnu_strftime=no,
130 dnl When crosscompiling, assume strftime is missing or broken.
131 jm_cv_func_working_gnu_strftime=no)
133 if test $jm_cv_func_working_gnu_strftime = no; then
134 LIBOBJS="$LIBOBJS strftime.o"
135 AC_DEFINE_UNQUOTED(strftime, gnu_strftime)
139 AC_DEFUN(jm_FUNC_STRFTIME,
142 AC_REPLACE_FUNCS(strftime)