4 dnl If you use this macro in a package, you should
5 dnl add the following two lines to acconfig.h:
6 dnl /* Define to gnu_strftime if the replacement function should be used. */
9 AC_DEFUN(jm_FUNC_GNU_STRFTIME,
10 [AC_REQUIRE([AC_HEADER_TIME])dnl
11 AC_REQUIRE([AC_C_CONST])dnl
12 AC_REQUIRE([AC_HEADER_STDC])dnl
13 AC_CHECK_HEADERS(sys/time.h)
14 AC_CACHE_CHECK([for working GNU strftime], jm_cv_func_working_gnu_strftime,
16 changequote(<<, >>)dnl
17 << /* Ulrich Drepper provided parts of the test program. */
22 #if TIME_WITH_SYS_TIME
23 # include <sys/time.h>
27 # include <sys/time.h>
34 compare (const char *fmt, const struct tm *tm, const char *expected)
37 strftime (buf, 99, fmt, tm);
38 if (strcmp (buf, expected))
41 printf ("fmt: \"%s\", expected \"%s\", got \"%s\"\n",
54 time_t t = 738367; /* Fri Jan 9 13:06:07 1970 */
57 /* This is necessary to make strftime give consistent zone strings and
58 e.g., seconds since the epoch (%s). */
62 #define CMP(Fmt, Expected) n_fail += compare ((Fmt), tm, (Expected))
64 CMP ("%-m", "1"); /* GNU */
66 CMP ("%^A", "FRIDAY"); /* The ^ is a GNU extension. */
67 CMP ("%B", "January");
68 CMP ("%^B", "JANUARY");
69 CMP ("%C", "19"); /* POSIX.2 */
70 CMP ("%D", "01/09/70"); /* POSIX.2 */
71 CMP ("%G", "1970"); /* GNU */
76 CMP ("%R", "13:06"); /* POSIX.2 */
78 CMP ("%T", "13:06:07"); /* POSIX.2 */
82 CMP ("%X", "13:06:07");
85 CMP ("%_m", " 1"); /* GNU */
90 CMP ("%c", "Fri Jan 9 13:06:07 1970");
91 CMP ("%^c", "FRI JAN 9 13:06:07 1970");
93 CMP ("%e", " 9"); /* POSIX.2 */
94 CMP ("%g", "70"); /* GNU */
95 CMP ("%h", "Jan"); /* POSIX.2 */
98 CMP ("%k", "13"); /* GNU */
99 CMP ("%l", " 1"); /* GNU */
101 CMP ("%n", "\n"); /* POSIX.2 */
103 CMP ("%r", "01:06:07 PM"); /* POSIX.2 */
104 CMP ("%s", "738367"); /* GNU */
105 CMP ("%t", "\t"); /* POSIX.2 */
106 CMP ("%u", "5"); /* POSIX.2 */
108 CMP ("%x", "01/09/70");
110 CMP ("%z", "+0000"); /* GNU */
112 exit (n_fail ? 1 : 0);
116 jm_cv_func_working_gnu_strftime=yes,
117 jm_cv_func_working_gnu_strftime=no,
118 dnl When crosscompiling, assume strftime is missing or broken.
119 jm_cv_func_working_gnu_strftime=no)
121 if test $jm_cv_func_working_gnu_strftime = no; then
122 LIBOBJS="$LIBOBJS strftime.o"
123 AC_DEFINE_UNQUOTED(strftime, gnu_strftime)