From patchwork Mon Feb 11 16:37:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paul Eggert X-Patchwork-Id: 1039944 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-99934-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=cs.ucla.edu Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="umzLSeS7"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43ys0C1HMbz9sML for ; Tue, 12 Feb 2019 03:37:46 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id :mime-version:content-type:content-transfer-encoding; q=dns; s= default; b=rkbISby291SgGTDqzqhLmzGdlXvYgQYRTtrfUwhLqD1rJAvqU/tZJ JJnDcpnVvOhNC70kc1y1NaVtgTQgGTp7ViNQ1GU9PRPe6mj/cf3miI9bCln8FaIC MAl2d6VzkJ+KckQYeu7oQ1JAO4r39drF0EVuxWmnyIufd84euTJ2HI= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id :mime-version:content-type:content-transfer-encoding; s=default; bh=wdku2G1PHjkSeTuJhRp0tpOE0CU=; b=umzLSeS7s3Z4Tczisd3Fev++m9m0 5aRkW8HC3CrBG8tuqXpZheRjMcGjGlJDCztkN1Tp8GlrBTY6Hg+aA9atUxR9ftK1 bTpqjS53Y5vYDEOIDvEjGt/AMkgw74udtMyKhc07P2EzfSizwDVWJUSSivSBSh3d oY1hFZrdHXGaYuA= Received: (qmail 64173 invoked by alias); 11 Feb 2019 16:37:41 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 64164 invoked by uid 89); 11 Feb 2019 16:37:41 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_PASS autolearn=ham version=3.3.2 spammy=NEWS, affecting, universal, Universal X-HELO: zimbra.cs.ucla.edu From: Paul Eggert To: libc-alpha@sourceware.org Cc: Paul Eggert Subject: [PATCH] Fix multiple minor tzset glitches [BZ #24004] Date: Mon, 11 Feb 2019 08:37:28 -0800 Message-Id: <20190211163728.31655-1-eggert@cs.ucla.edu> MIME-Version: 1.0 Avoid polling if TZ is unset. Consistently ignore leading ":" in TZ as per documentation. Treat TZ="" as Universal Time without leap seconds, for consistency with upstream. * time/tzset.c (tzset_internal): Check for null TZ first. Do not substitute "Universal" for ""; this is __tzfile_read’s job and we were doing it incorrectly as we treated TZ="" differently from TZ=":". * time/tzfile.c (__tzfile_read): Simplify, as FILE cannot be null. --- ChangeLog | 13 +++++++++++++ NEWS | 7 +++++++ time/tzfile.c | 5 +---- time/tzset.c | 15 ++++++--------- 4 files changed, 27 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6f1d967f62..831d89ba8f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2019-02-11 Paul Eggert + + Fix multiple minor tzset glitches [BZ #24004] + Avoid polling if TZ is unset. + Consistently ignore leading ":" in TZ as per documentation. + Treat TZ="" as Universal Time without leap seconds, + for consistency with upstream. + * time/tzset.c (tzset_internal): Check for null TZ first. + Do not substitute "Universal" for ""; this is __tzfile_read’s + job and we were doing it incorrectly as we treated TZ="" + differently from TZ=":". + * time/tzfile.c (__tzfile_read): Simplify, as FILE cannot be null. + 2019-02-11 Paul A. Clarke * sysdeps/powerpc/fpu/e_sqrt.c (__slow_ieee754_sqrtf): diff --git a/NEWS b/NEWS index 0a3b6c7a5a..87de5030c1 100644 --- a/NEWS +++ b/NEWS @@ -22,6 +22,13 @@ Deprecated and removed features, and other changes affecting compatibility: definitions in libc will be used automatically, which have been available since glibc 2.17. +* If the TZ environment variable is unset, functions like localtime no + longer stat the file /etc/localtime if the file has already been + consulted. Instead, they reuse the cached timezone info, just as they + would with TZ="/etc/localtime". If TZ="", these functions now omit leap + seconds even on unusual installations where TZ="Universal" identifies a + TZif file with leap seconds; this is for consistency with tzcode and BSD. + Changes to build and runtime requirements: * GCC 6.2 or later is required to build the GNU C Library. diff --git a/time/tzfile.c b/time/tzfile.c index 7229ed93b7..db66f22a4e 100644 --- a/time/tzfile.c +++ b/time/tzfile.c @@ -115,10 +115,7 @@ __tzfile_read (const char *file, size_t extra, char **extrap) __use_tzfile = 0; - if (file == NULL) - /* No user specification; use the site-wide default. */ - file = TZDEFAULT; - else if (*file == '\0') + if (*file == '\0') /* User specified the empty string; use UTC with no leap seconds. */ goto ret_free_transitions; else diff --git a/time/tzset.c b/time/tzset.c index 307eb651ad..1903ef864d 100644 --- a/time/tzset.c +++ b/time/tzset.c @@ -375,25 +375,22 @@ tzset_internal (int always) /* Examine the TZ environment variable. */ tz = getenv ("TZ"); - if (tz && *tz == '\0') - /* User specified the empty string; use UTC explicitly. */ - tz = "Universal"; + + if (tz == NULL) + /* No user specification; use the site-wide default. */ + tz = TZDEFAULT; /* A leading colon means "implementation defined syntax". We ignore the colon and always use the same algorithm: try a data file, and if none exists parse the 1003.1 syntax. */ - if (tz && *tz == ':') + if (*tz == ':') ++tz; /* Check whether the value changed since the last run. */ - if (old_tz != NULL && tz != NULL && strcmp (tz, old_tz) == 0) + if (old_tz != NULL && strcmp (tz, old_tz) == 0) /* No change, simply return. */ return; - if (tz == NULL) - /* No user specification; use the site-wide default. */ - tz = TZDEFAULT; - tz_rules[0].name = NULL; tz_rules[1].name = NULL;