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 dnl FIXME: the list is far from complete
6 AC_DEFUN(_jm_STRFTIME_PREREQS,
8 dnl strftime.c uses localtime_r if it exists. Check for it.
9 AC_CHECK_FUNCS(localtime_r)
10 dnl FIXME: add tests for everything in strftime.c: e.g., HAVE_BCOPY,
11 dnl HAVE_TZNAME, HAVE_TZSET, HAVE_TM_ZONE, etc.
14 dnl Determine if the strftime function has all the features of the GNU one.
16 dnl From Jim Meyering.
18 AC_DEFUN(jm_FUNC_GNU_STRFTIME,
19 [AC_REQUIRE([AC_HEADER_TIME])dnl
23 AC_REQUIRE([AC_C_CONST])dnl
24 AC_REQUIRE([AC_HEADER_STDC])dnl
25 AC_CHECK_HEADERS(sys/time.h)
26 AC_CACHE_CHECK([for working GNU strftime], jm_cv_func_working_gnu_strftime,
28 changequote(<<, >>)dnl
29 << /* Ulrich Drepper provided parts of the test program. */
34 #if TIME_WITH_SYS_TIME
35 # include <sys/time.h>
39 # include <sys/time.h>
46 compare (const char *fmt, const struct tm *tm, const char *expected)
49 strftime (buf, 99, fmt, tm);
50 if (strcmp (buf, expected))
53 printf ("fmt: \"%s\", expected \"%s\", got \"%s\"\n",
66 time_t t = 738367; /* Fri Jan 9 13:06:07 1970 */
69 /* This is necessary to make strftime give consistent zone strings and
70 e.g., seconds since the epoch (%s). */
74 #define CMP(Fmt, Expected) n_fail += compare ((Fmt), tm, (Expected))
76 CMP ("%-m", "1"); /* GNU */
78 CMP ("%^A", "FRIDAY"); /* The ^ is a GNU extension. */
79 CMP ("%B", "January");
80 CMP ("%^B", "JANUARY");
81 CMP ("%C", "19"); /* POSIX.2 */
82 CMP ("%D", "01/09/70"); /* POSIX.2 */
83 CMP ("%F", "1970-01-09");
84 CMP ("%G", "1970"); /* GNU */
89 CMP ("%R", "13:06"); /* POSIX.2 */
91 CMP ("%T", "13:06:07"); /* POSIX.2 */
95 CMP ("%X", "13:06:07");
98 CMP ("%_m", " 1"); /* GNU */
103 CMP ("%c", "Fri Jan 9 13:06:07 1970");
104 CMP ("%^c", "FRI JAN 9 13:06:07 1970");
106 CMP ("%e", " 9"); /* POSIX.2 */
107 CMP ("%g", "70"); /* GNU */
108 CMP ("%h", "Jan"); /* POSIX.2 */
111 CMP ("%k", "13"); /* GNU */
112 CMP ("%l", " 1"); /* GNU */
114 CMP ("%n", "\n"); /* POSIX.2 */
116 CMP ("%r", "01:06:07 PM"); /* POSIX.2 */
117 CMP ("%s", "738367"); /* GNU */
118 CMP ("%t", "\t"); /* POSIX.2 */
119 CMP ("%u", "5"); /* POSIX.2 */
121 CMP ("%x", "01/09/70");
123 CMP ("%z", "+0000"); /* GNU */
125 exit (n_fail ? 1 : 0);
129 jm_cv_func_working_gnu_strftime=yes,
130 jm_cv_func_working_gnu_strftime=no,
131 dnl When crosscompiling, assume strftime is missing or broken.
132 jm_cv_func_working_gnu_strftime=no)
134 if test $jm_cv_func_working_gnu_strftime = no; then
136 LIBOBJS="$LIBOBJS strftime.$ac_objext"
137 AC_DEFINE_UNQUOTED(strftime, gnu_strftime,
138 [Define to gnu_strftime if the replacement function should be used.])
142 AC_DEFUN(jm_FUNC_STRFTIME,
145 AC_REPLACE_FUNCS(strftime)