-/* 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.
# if ! HAVE_LOCALTIME_R
# if ! HAVE_TM_GMTOFF
/* Approximate gmtime_r as best we can in its absence. */
-# define gmtime_r my_gmtime_r
+# define gmtime_r my_gmtime_r
static struct tm *gmtime_r __P ((const time_t *, struct tm *));
static struct tm *
gmtime_r (t, tp)
};
#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(S, Maxsize, Format, Tp) \
+ _strftime_copytm ((S), (Maxsize), (Format), (Tp))
+#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
#endif /* ! DO_MULTIBYTE */
- /* Check for flags that can modify a number format. */
+ /* Check for flags that can modify a format. */
+ pad = 0;
while (1)
{
switch (*++f)
{
+ /* This influences the number formats. */
case '_':
case '-':
case '0':
pad = *f;
continue;
+ /* This changes textual output. */
case '^':
to_uppcase = 1;
continue;
default:
- pad = 0;
break;
}
break;