Module Name: src Committed By: christos Date: Sun Apr 7 14:51:15 UTC 2019
Modified Files: src/lib/libc/time: strftime.c Log Message: Don't try to print NULL if we can't get a timezone name. First we try dst, then we try the non-dst name and finally we just print ??? if that did not work. This is not needed to handle the "TZ= date" case which was crashing before because the default timezone was not consistently initialized, but should handle any timezone now. To generate a diff of this commit: cvs rdiff -u -r1.44 -r1.45 src/lib/libc/time/strftime.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/lib/libc/time/strftime.c diff -u src/lib/libc/time/strftime.c:1.44 src/lib/libc/time/strftime.c:1.45 --- src/lib/libc/time/strftime.c:1.44 Fri Apr 5 17:27:44 2019 +++ src/lib/libc/time/strftime.c Sun Apr 7 10:51:14 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: strftime.c,v 1.44 2019/04/05 21:27:44 christos Exp $ */ +/* $NetBSD: strftime.c,v 1.45 2019/04/07 14:51:14 christos Exp $ */ /* Convert a broken-down timestamp to a string. */ @@ -35,7 +35,7 @@ static char elsieid[] = "@(#)strftime.c 7.64"; static char elsieid[] = "@(#)strftime.c 8.3"; #else -__RCSID("$NetBSD: strftime.c,v 1.44 2019/04/05 21:27:44 christos Exp $"); +__RCSID("$NetBSD: strftime.c,v 1.45 2019/04/07 14:51:14 christos Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -544,9 +544,15 @@ label: #ifdef TM_ZONE pt = _add(t->TM_ZONE, pt, ptlim); #elif HAVE_TZNAME - if (t->tm_isdst >= 0) - pt = _add(tzgetname(sp, t->tm_isdst), - pt, ptlim); + if (t->tm_isdst >= 0) { + int oerrno = errno, dst = t->tm_isdst; + const char *z = + tzgetname(sp, dst); + if (z == NULL) + z = tzgetname(sp, !dst); + pt = _add(z ? z : "???", pt, ptlim); + errno = oerrno; + } #endif /* ** C99 and later say that %Z must be