Skip to content

Commit

Permalink
[BZ #6612]
Browse files Browse the repository at this point in the history
* time/strftime.c: Pass reference to tzset_called around to handle
	recursive calls.

	[BZ #6612]
	* time/strftime.c (__strftime_internal): Call tzset() only
	when printing timezone-dependent values.
	Based on a patch by Petr Baudis <[email protected]>.
  • Loading branch information
Ulrich Drepper committed Jun 13, 2008
1 parent f854efd commit 5bcc6c0
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 15 deletions.
8 changes: 8 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
2008-06-12 Ulrich Drepper <[email protected]>

* time/strftime.c: Pass reference to tzset_called around to handle
recursive calls.

[BZ #6612]
* time/strftime.c (__strftime_internal): Call tzset() only
when printing timezone-dependent values.
Based on a patch by Petr Baudis <[email protected]>.

* resolv/nss_dns/dns-host.c (gaih_getanswer): Don't
unconditionally use second gaih_getanswer_slice result.

Expand Down
43 changes: 28 additions & 15 deletions time/strftime_l.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) 2002, 2004, 2007 Free Software Foundation, Inc.
/* Copyright (C) 2002, 2004, 2007, 2008 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
Expand Down Expand Up @@ -455,7 +455,8 @@ static CHAR_T const month_name[][10] =
#endif

static size_t __strftime_internal (CHAR_T *, size_t, const CHAR_T *,
const struct tm *, bool ut_argument_spec_iso
const struct tm *, bool *
ut_argument_spec_iso
LOCALE_PARAM_PROTO) __THROW;

/* Write information from TP into S according to the format
Expand All @@ -481,7 +482,8 @@ my_strftime (s, maxsize, format, tp ut_argument LOCALE_PARAM)
tmcopy = *tp;
tp = &tmcopy;
#endif
return __strftime_internal (s, maxsize, format, tp, false
bool tzset_called = false;
return __strftime_internal (s, maxsize, format, tp, &tzset_called
ut_argument LOCALE_ARG);
}
#ifdef _LIBC
Expand All @@ -495,7 +497,7 @@ __strftime_internal (s, maxsize, format, tp, tzset_called ut_argument
size_t maxsize;
const CHAR_T *format;
const struct tm *tp;
bool tzset_called;
bool *tzset_called;
ut_argument_spec
LOCALE_PARAM_DECL
{
Expand Down Expand Up @@ -563,16 +565,6 @@ __strftime_internal (s, maxsize, format, tp, tzset_called ut_argument
if (! (zone && *zone))
zone = "GMT";
}
else
{
/* POSIX.1 requires that local time zone information is used as
though strftime called tzset. */
# if HAVE_TZSET
if (!tzset_called)
tzset ();
tzset_called = true;
# endif
}
#endif

if (hour12 > 12)
Expand Down Expand Up @@ -1325,7 +1317,18 @@ __strftime_internal (s, maxsize, format, tp, tzset_called ut_argument
#if HAVE_TZNAME
/* The tzset() call might have changed the value. */
if (!(zone && *zone) && tp->tm_isdst >= 0)
zone = tzname[tp->tm_isdst];
{
/* POSIX.1 requires that local time zone information is used as
though strftime called tzset. */
# if HAVE_TZSET
if (!*tzset_called)
{
tzset ();
*tzset_called = true;
}
# endif
zone = tzname[tp->tm_isdst];
}
#endif
if (! zone)
zone = "";
Expand Down Expand Up @@ -1361,6 +1364,16 @@ __strftime_internal (s, maxsize, format, tp, tzset_called ut_argument
struct tm ltm;
time_t lt;

/* POSIX.1 requires that local time zone information is used as
though strftime called tzset. */
# if HAVE_TZSET
if (!*tzset_called)
{
tzset ();
*tzset_called = true;
}
# endif

ltm = *tp;
lt = mktime (&ltm);

Expand Down

0 comments on commit 5bcc6c0

Please sign in to comment.