mirror of
https://git.freebsd.org/src.git
synced 2026-01-16 23:02:24 +00:00
tzcode: Use -00 only for invalid time zones
As of tzcode 2025a, if we are unable to load a time zone, we set tzname
to "-00" to indicate an error. This penalizes users who simply don't
set TZ or create /etc/localtime as a faster way of setting the time zone
to UTC (pointing /etc/localtime at /usr/share/zoneinfo/UTC forces us to
parse it every time for no real benefit). To rectify this, use "-00"
only if TZ was set or zoneinit() returned something else than ENOENT.
MFC after: 3 days
Fixes: 967a49a21a ("Update tzcode to 2025b")
Reviewed by: philip
Differential Revision: https://reviews.freebsd.org/D52680
This commit is contained in:
parent
3aac05f566
commit
a5f14e4f90
1 changed files with 6 additions and 2 deletions
|
|
@ -1649,9 +1649,13 @@ tzset_unlocked_name(char const *name)
|
|||
lclptr = sp = malloc(sizeof *lclptr);
|
||||
# endif
|
||||
if (sp) {
|
||||
if (zoneinit(sp, name, TZLOAD_FROMENV | TZLOAD_TZSTRING) != 0) {
|
||||
int err = zoneinit(sp, name, TZLOAD_FROMENV | TZLOAD_TZSTRING);
|
||||
if (err != 0) {
|
||||
zoneinit(sp, "", 0);
|
||||
strcpy(sp->chars, UNSPEC);
|
||||
/* Abbreviate with "-00" if there was an error.
|
||||
Do not treat a missing TZDEFAULT file as an error. */
|
||||
if (name || err != ENOENT)
|
||||
strcpy(sp->chars, UNSPEC);
|
||||
}
|
||||
if (0 < lcl)
|
||||
strcpy(lcl_TZname, name);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue