diff --git a/Makefile b/Makefile index 3a52875..a4a74e6 100644 --- a/Makefile +++ b/Makefile @@ -115,6 +115,8 @@ LDLIBS= # -DHAVE_SETTIMEOFDAY=2 if settimeofday uses 2nd arg (4.3BSD) # -DHAVE_SETTIMEOFDAY=3 if settimeofday ignores 2nd arg (4.4BSD) # -DHAVE_STDINT_H=1 if you have a pre-C99 compiler with "stdint.h" +# -DHAVE_STRFTIME_L=1 if declares locale_t and strftime_l +# This defaults to 0 if _POSIX_VERSION < 200809, 1 otherwise. # -DHAVE_SYMLINK=0 if your system lacks the symlink function # -DHAVE_SYS_STAT_H=0 if your compiler lacks a "sys/stat.h" # -DHAVE_SYS_WAIT_H=0 if your compiler lacks a "sys/wait.h" diff --git a/NEWS b/NEWS index 9432dd4..8e4be29 100644 --- a/NEWS +++ b/NEWS @@ -67,6 +67,11 @@ Unreleased, experimental changes more likely to guess right for ambiguous time stamps near transitions where tm_isdst does not change. + If HAVE_STRFTIME_L is defined to 1, the tz library now defines + strftime_l for compatibility with recent versions of POSIX. + Only the C locale is supported, though. HAVE_STRFTIME_L defaults + to 1 on recent POSIX versions, and to 0 otherwise. + zdump now builds with the tz library unless USE_LTZ is defined to 0, This lets zdump use tz features even if the system library lacks them. To build zdump with the system library, use 'make CFLAGS=-DUSE_LTZ=0 diff --git a/private.h b/private.h index 5d44919..1858bae 100644 --- a/private.h +++ b/private.h @@ -101,6 +101,14 @@ #include "unistd.h" /* for F_OK, R_OK, and other POSIX goodness */ #endif /* HAVE_UNISTD_H */ +#ifndef HAVE_STRFTIME_L +# if _POSIX_VERSION < 200809 +# define HAVE_STRFTIME_L 0 +# else +# define HAVE_STRFTIME_L 1 +# endif +#endif + #ifndef F_OK #define F_OK 0 #endif /* !defined F_OK */ diff --git a/strftime.c b/strftime.c index ef2471b..632f395 100644 --- a/strftime.c +++ b/strftime.c @@ -106,6 +106,16 @@ extern char * tzname[]; #define IN_THIS 2 #define IN_ALL 3 +#if HAVE_STRFTIME_L +size_t +strftime_l(char *s, size_t maxsize, char const *format, struct tm const *t, + locale_t locale) +{ + /* Just call strftime, as only the C locale is supported. */ + return strftime(s, maxsize, format, t); +} +#endif + size_t strftime(char * const s, const size_t maxsize, const char *const format, const struct tm *const t)