diff --git a/contrib/tzcode/localtime.c b/contrib/tzcode/localtime.c --- a/contrib/tzcode/localtime.c +++ b/contrib/tzcode/localtime.c @@ -1624,14 +1624,14 @@ static void tzset_unlocked(void) { + char const *name = getenv("TZ"); #ifdef __FreeBSD__ - tzset_unlocked_name(getenv("TZ")); + tzset_unlocked_name(name); } static void tzset_unlocked_name(char const *name) { -#else - char const *name = getenv("TZ"); + int tzloadflags = TZLOAD_TZSTRING | (name ? TZLOAD_FROMENV : 0); #endif struct state *sp = lclptr; int lcl = name ? strlen(name) < sizeof lcl_TZname : -1; @@ -1647,7 +1647,11 @@ lclptr = sp = malloc(sizeof *lclptr); # endif if (sp) { +#ifdef __FreeBSD__ + if (zoneinit(sp, name, tzloadflags) != 0) { +#else if (zoneinit(sp, name, TZLOAD_FROMENV | TZLOAD_TZSTRING) != 0) { +#endif zoneinit(sp, "", 0); strcpy(sp->chars, UNSPEC); }