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 If you use this macro in a package, you should
17 dnl add the following two lines to acconfig.h:
18 dnl /* Define to gnu_strftime if the replacement function should be used. */
21 dnl From Jim Meyering.
23 AC_DEFUN(jm_FUNC_GNU_STRFTIME,
24 [AC_REQUIRE([AC_HEADER_TIME])dnl
28 AC_REQUIRE([AC_C_CONST])dnl
29 AC_REQUIRE([AC_HEADER_STDC])dnl
30 AC_CHECK_HEADERS(sys/time.h)
31 AC_CACHE_CHECK([for working GNU strftime], jm_cv_func_working_gnu_strftime,
33 changequote(<<, >>)dnl
34 << /* Ulrich Drepper provided parts of the test program. */
39 #if TIME_WITH_SYS_TIME
40 # include <sys/time.h>
44 # include <sys/time.h>
51 compare (const char *fmt, const struct tm *tm, const char *expected)
54 strftime (buf, 99, fmt, tm);
55 if (strcmp (buf, expected))
58 printf ("fmt: \"%s\", expected \"%s\", got \"%s\"\n",
71 time_t t = 738367; /* Fri Jan 9 13:06:07 1970 */
74 /* This is necessary to make strftime give consistent zone strings and
75 e.g., seconds since the epoch (%s). */
79 #define CMP(Fmt, Expected) n_fail += compare ((Fmt), tm, (Expected))
81 CMP ("%-m", "1"); /* GNU */
83 CMP ("%^A", "FRIDAY"); /* The ^ is a GNU extension. */
84 CMP ("%B", "January");
85 CMP ("%^B", "JANUARY");
86 CMP ("%C", "19"); /* POSIX.2 */
87 CMP ("%D", "01/09/70"); /* POSIX.2 */
88 CMP ("%F", "1970-01-09");
89 CMP ("%G", "1970"); /* GNU */
94 CMP ("%R", "13:06"); /* POSIX.2 */
96 CMP ("%T", "13:06:07"); /* POSIX.2 */
100 CMP ("%X", "13:06:07");
103 CMP ("%_m", " 1"); /* GNU */
108 CMP ("%c", "Fri Jan 9 13:06:07 1970");
109 CMP ("%^c", "FRI JAN 9 13:06:07 1970");
111 CMP ("%e", " 9"); /* POSIX.2 */
112 CMP ("%f", "5"); /* POSIX.2 */
113 CMP ("%g", "70"); /* GNU */
114 CMP ("%h", "Jan"); /* POSIX.2 */
117 CMP ("%k", "13"); /* GNU */
118 CMP ("%l", " 1"); /* GNU */
120 CMP ("%n", "\n"); /* POSIX.2 */
122 CMP ("%r", "01:06:07 PM"); /* POSIX.2 */
123 CMP ("%s", "738367"); /* GNU */
124 CMP ("%t", "\t"); /* POSIX.2 */
125 CMP ("%u", "5"); /* POSIX.2 */
127 CMP ("%x", "01/09/70");
129 CMP ("%z", "+0000"); /* GNU */
131 exit (n_fail ? 1 : 0);
135 jm_cv_func_working_gnu_strftime=yes,
136 jm_cv_func_working_gnu_strftime=no,
137 dnl When crosscompiling, assume strftime is missing or broken.
138 jm_cv_func_working_gnu_strftime=no)
140 if test $jm_cv_func_working_gnu_strftime = no; then
141 LIBOBJS="$LIBOBJS strftime.o"
142 AC_DEFINE_UNQUOTED(strftime, gnu_strftime)
146 AC_DEFUN(jm_FUNC_STRFTIME,
149 AC_REPLACE_FUNCS(strftime)