-/* 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.
#endif
#ifndef __P
-#if defined (__GNUC__) || (defined (__STDC__) && __STDC__)
-#define __P(args) args
-#else
-#define __P(args) ()
-#endif /* GCC. */
+# if defined (__GNUC__) || (defined (__STDC__) && __STDC__)
+# define __P(args) args
+# else
+# define __P(args) ()
+# endif /* GCC. */
#endif /* Not __P. */
#ifndef PTR
-#ifdef __STDC__
-#define PTR void *
-#else
-#define PTR char *
-#endif
+# ifdef __STDC__
+# define PTR void *
+# else
+# define PTR char *
+# endif
#endif
#ifndef CHAR_BIT
-#define CHAR_BIT 8
+# define CHAR_BIT 8
#endif
#ifndef NULL
-#define NULL 0
+# define NULL 0
#endif
#define TYPE_SIGNED(t) ((t) -1 < 0)
#ifndef __isleap
/* Nonzero if YEAR is a leap year (every 4 years,
except every 100th isn't, and every 400th is). */
-#define __isleap(year) \
+# define __isleap(year) \
((year) % 4 == 0 && ((year) % 100 != 0 || (year) % 400 == 0))
#endif
# 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 /* ! HAVE_TM_GMTOFF */
/* Approximate localtime_r as best we can in its absence. */
-#define localtime_r my_localtime_r
+# define localtime_r my_localtime_r
static struct tm *localtime_r __P ((const time_t *, struct tm *));
static struct tm *
localtime_r (t, tp)
# define TOUPPER(Ch) (islower (Ch) ? toupper (Ch) : (Ch))
# define TOLOWER(Ch) (isupper (Ch) ? tolower (Ch) : (Ch))
#endif
+/* We don't use `isdigit' here since the locale dependent
+ interpretation is not what we want here. We only need to accept
+ the arabic digits in the ASCII range. One day there is perhaps a
+ more reliable way to accept other sets of digits. */
+#define ISDIGIT(Ch) ((unsigned int) (Ch) - '0' <= 9)
static char *memcpy_lowcase __P ((char *dest, const char *src, size_t len));
};
#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;
}
/* As a GNU extension we allow to specify the field width. */
- if (isdigit (*f))
+ if (ISDIGIT (*f))
{
width = 0;
do
{
width *= 10;
width += *f - '0';
+ ++f;
}
- while (isdigit (*++f));
+ while (ISDIGIT (*f));
}
/* Check for modifiers. */