X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Fstrftime.c;h=8c838f7834d8af0d29d44c21b2ccc1f883fa5e8a;hb=3b9c7bc21c762948ae4f0d273b0797f97276ed70;hp=aa8351641d142e52246b31aea582907b7b493554;hpb=4b2496208422ff3fee43b1e9c4fb73841a29b4bc;p=gnulib.git diff --git a/lib/strftime.c b/lib/strftime.c index aa8351641..8c838f783 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. @@ -139,7 +139,7 @@ extern int __tz_compute __P ((time_t timer, const struct tm *tm)); # 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) @@ -230,6 +230,11 @@ static const char spaces[16] = " "; # 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)); @@ -324,6 +329,31 @@ 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 @@ -488,38 +518,41 @@ strftime (s, maxsize, format, tp) #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. */