From patchwork Sat Dec 24 11:40:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iain Sandoe X-Patchwork-Id: 62377 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 464843850F0A for ; Sat, 24 Dec 2022 11:40:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 464843850F0A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1671882041; bh=lHgCZdP5dJuTKKzDQiuzflBaAfQu05m8h3004SP7ltc=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=rMQ+YzJbhUv5YWPIZK0F2TWuoXZuYTWWz19VpLsnb0bPztRkl1IOgERhQUhKwbkES bGT14M5tLumSo0NJ/Kl59N6GG0+gZx9BCCWbRhvAX3niG+4GpugHSOaIsmDGjRQgRC hghfoLsUblX2Ebm8dDcAEGbXtw3UTgxxBweI8cZg= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by sourceware.org (Postfix) with ESMTPS id 61F423858284; Sat, 24 Dec 2022 11:40:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 61F423858284 Received: by mail-wm1-x32a.google.com with SMTP id f13-20020a1cc90d000000b003d08c4cf679so5053952wmb.5; Sat, 24 Dec 2022 03:40:12 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:reply-to:message-id:date :subject:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=lHgCZdP5dJuTKKzDQiuzflBaAfQu05m8h3004SP7ltc=; b=rFnN4lj9NKXIZ28Xbmor1+WbpBBuQuJfO2K1BYOaQi1M0JTZOtqZn7XoZvqvCBUFxo FN1CqyjrH0M9aYWVwdm1EH2fldBIvtiblaa3chK8izMqyxQdXaHQ1e+Fzd1Jm+NM+YF/ AtLls5VwnQ8B6Vk0ZR8iWLZT5XNhLkvTJ7XmeO1gKXWSzRtm001IQcKE3HNE5CJLK1eI Bq9dVNmrtGO8lyeSXCoRUlsE5oHtnMX37lcy7vUhC3bx2w91pWRuMA8Xz32awhAHO33H 1F6zbEK3BsLHA/xS4d+T44fUAK5zHR7OU4sa4Ecj5VRlosyWjlv12mBb6WCu3NQSRk8o qhgw== X-Gm-Message-State: AFqh2kodM+xY0/CZDwaENMqCZ0+Sr8XP/plCna+z2t4d0cc++zsV+HBI I6gnDXX/97wOdk4evUy2Jw/VvRFyuQM= X-Google-Smtp-Source: AMrXdXsfOFqAF3bN+/bZ+eM9kTfE1bsLwwsIzbRhYSM+Ggh+s2ta3yzUvxaLv6HkewWC6WdKYYZiJA== X-Received: by 2002:a05:600c:34d1:b0:3d7:72e3:f437 with SMTP id d17-20020a05600c34d100b003d772e3f437mr9433501wmq.21.1671882010920; Sat, 24 Dec 2022 03:40:10 -0800 (PST) Received: from localhost.localdomain (host81-138-1-83.in-addr.btopenworld.com. [81.138.1.83]) by smtp.gmail.com with ESMTPSA id q185-20020a1c43c2000000b003cff309807esm12419238wma.23.2022.12.24.03.40.10 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sat, 24 Dec 2022 03:40:10 -0800 (PST) X-Google-Original-From: Iain Sandoe To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [PATCH] libstdc++: Test for tzdata.zi before fallback version files. Date: Sat, 24 Dec 2022 11:40:09 +0000 Message-Id: <20221224114009.20261-1-iain@sandoe.co.uk> X-Mailer: git-send-email 2.37.1 (Apple Git-137.1) MIME-Version: 1.0 X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Iain Sandoe via Gcc-patches From: Iain Sandoe Reply-To: iain@sandoe.co.uk Cc: Iain Sandoe Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" I tested this (along with the other posted patches for zoneinfo) using an installation built from the 2022g release on x86_64-darwin21. Wider testing will follow. If we are in an installation without the tzdata.zi then although we'll report the version OK, the available functionality will be basic. OK for trunk? Iain --- 8< --- Several systems/distributions do not provide the raw tzdata.zi file in their zoneinfo installation. However, we might provide an alternate installation path at configure time, so that we should check for the tzdata.zi file first and then fall back to system-specific files like +VERSION etc. on those systems. Signed-off-by: Iain Sandoe libstdc++-v3/ChangeLog: * src/c++20/tzdb.cc (remote_version): Look for the tzdata.zi file before falling back to system-specific ones on Darwin and BSD. --- libstdc++-v3/src/c++20/tzdb.cc | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/libstdc++-v3/src/c++20/tzdb.cc b/libstdc++-v3/src/c++20/tzdb.cc index c4311d0902a..39e4466f932 100644 --- a/libstdc++-v3/src/c++20/tzdb.cc +++ b/libstdc++-v3/src/c++20/tzdb.cc @@ -1061,16 +1061,11 @@ namespace std::chrono namespace { // Read the version number from a tzdata.zi file. + // Note that some systems do not have this file available by default + // but we can configure the library to point to an alternate installation. string remote_version(istream* zif) { -#if defined __NetBSD__ - if (string ver; ifstream(zoneinfo_dir() + "/TZDATA_VERSION") >> ver) - return ver; -#elif defined __APPLE__ - if (string ver; ifstream(zoneinfo_dir() + "/+VERSION") >> ver) - return ver; -#else ifstream f; if (!zif) { @@ -1083,6 +1078,14 @@ namespace std::chrono if (*zif >> hash >> label >> version) if (hash == '#' && label == "version") return version; +#if defined __NetBSD__ + if (string ver; ifstream(zoneinfo_dir() + "/TZDATA_VERSION") >> ver) + return ver; +#elif defined __APPLE__ + // The standard install on macOS has no tzdata.zi, but we can find the + // version from +VERSION. + if (string ver; ifstream(zoneinfo_dir() + "/+VERSION") >> ver) + return ver; #endif __throw_runtime_error("tzdb: no version found in tzdata.zi"); }