summaryrefslogtreecommitdiff
path: root/lib/strftime.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1997-01-22 22:43:15 +0000
committerJim Meyering <jim@meyering.net>1997-01-22 22:43:15 +0000
commitd64cc3c1ef17658217f1efc4d5fdb1871ef77372 (patch)
tree958a71c64ff82ce28ca605ee87eae3cdee896f97 /lib/strftime.c
parentdb7201835dda2bb16be6f48d03dc26d7548ee532 (diff)
downloadcoreutils-d64cc3c1ef17658217f1efc4d5fdb1871ef77372.tar.xz
(_strftime_copytm): New function, to work around Solaris 2.5 tzset bug.
From Paul Eggert.
Diffstat (limited to 'lib/strftime.c')
-rw-r--r--lib/strftime.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/lib/strftime.c b/lib/strftime.c
index a1c9a39bb..649cdf431 100644
--- a/lib/strftime.c
+++ b/lib/strftime.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 92, 93, 94, 95, 96 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 92, 93, 94, 95, 96, 97 Free Software Foundation, Inc.
NOTE: The canonical source of this file is maintained with the GNU C
Library. Bugs can be reported to bug-glibc@prep.ai.mit.edu.
@@ -329,6 +329,30 @@ static char const month_name[][10] =
};
#endif
+
+#if !defined _LIBC && HAVE_TZNAME && HAVE_TZSET
+ /* Solaris 2.5 tzset sometimes modifies the storage returned by localtime.
+ Work around this bug by copying *tp before it might be munged. */
+ size_t _strftime_copytm __P ((char *, size_t, const char *,
+ const struct tm *));
+ size_t
+ strftime (s, maxsize, format, tp)
+ char *s;
+ size_t maxsize;
+ const char *format;
+ const struct tm *tp;
+ {
+ struct tm tmcopy;
+ tmcopy = *tp;
+ return _strftime_copytm (s, maxsize, format, &tmcopy);
+ }
+# ifdef strftime
+# undef strftime
+# endif
+# define strftime _strftime_copytm
+#endif
+
+
/* Write information from TP into S according to the format
string FORMAT, writing no more that MAXSIZE characters
(including the terminating '\0') and returning number of