mailing list of musl libc
 help / color / mirror / code / Atom feed
* [musl] strftime %Z behavior with manually populated struct tm
@ 2020-08-10 13:31 Nikita Popov
  2020-08-10 16:53 ` Rich Felker
  2020-08-12 12:57 ` [musl] " Nikita Popov
  0 siblings, 2 replies; 5+ messages in thread
From: Nikita Popov @ 2020-08-10 13:31 UTC (permalink / raw)
  To: musl

[-- Attachment #1: Type: text/plain, Size: 1084 bytes --]

Hi,

Currently, strftime() %Z will print an empty string if the provided tm_zone
does not originate from musl. It appears that this behavior is explicitly
implemented in __tm_to_tzname(). Would it be possible to instead print any
non-NULL tm_zone as provided?

For consumers manually populating the struct tm structure, it is
non-trivial to work around the current behavior. Python introduced a work
around in
https://github.com/python/cpython/commit/163eca34c48f1b25e1504e37f4656773fd0fdc78,
but it is not easy to generalize.

From what I gathered, the original concern here was that a consumer
manually initializing struct tm may not initialize the tm_zone field. As
struct tm is only specified to contain "at least" certain members, manual
initialization of this structure is already on shaky ground anyway and I
think it is more useful to assume the initialization is correct than try to
deal with garbage data. Because other libc implementation do not try to
validate the pointer either (beyond being non-NULL), incorrect
initialization is unlikely in practice.

Regards,
Nikita

[-- Attachment #2: Type: text/html, Size: 2154 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-08-12 15:18 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-10 13:31 [musl] strftime %Z behavior with manually populated struct tm Nikita Popov
2020-08-10 16:53 ` Rich Felker
2020-08-12 12:57 ` [musl] " Nikita Popov
2020-08-12 14:05   ` Nikita Popov
2020-08-12 15:17   ` Rich Felker

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).