From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1698) id 8F9E93858D1E; Sat, 24 Dec 2022 17:52:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8F9E93858D1E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1671904326; bh=xPgOhMYAvvOr0HeA7husHPBzktSz8uRvH5wbs+68biw=; h=From:To:Subject:Date:From; b=haK+pnXa8ZBZYPYquhyNCoficz76sCHXkesIfotSbCeH2fdaeqn8taC91RagKkcBM NIlS6xfuziqc5Dw7g8qz9vx9GHf9yek3FKySltBIQCTC18LN/cF+Cx3aFNu/Jfkwsx B+64QQu+1cjFgvl8eGfB2JaTw3GJBXERuqnWSLyc= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Iain D Sandoe To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r13-4885] libstdc++: Test for tzdata.zi before fallback version files. X-Act-Checkin: gcc X-Git-Author: Iain Sandoe X-Git-Refname: refs/heads/master X-Git-Oldrev: 4c3a036be5f4dd68e0e4d8fb3a152c06538f5872 X-Git-Newrev: 8ec139af5ea9657c7517c1483c7a577815bea48e Message-Id: <20221224175206.8F9E93858D1E@sourceware.org> Date: Sat, 24 Dec 2022 17:52:06 +0000 (GMT) List-Id: https://gcc.gnu.org/g:8ec139af5ea9657c7517c1483c7a577815bea48e commit r13-4885-g8ec139af5ea9657c7517c1483c7a577815bea48e Author: Iain Sandoe Date: Sat Dec 24 10:59:26 2022 +0000 libstdc++: Test for tzdata.zi before fallback version files. 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. Diff: --- 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 5f5c4199f65..2a4e213d3d9 100644 --- a/libstdc++-v3/src/c++20/tzdb.cc +++ b/libstdc++-v3/src/c++20/tzdb.cc @@ -1060,16 +1060,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) { @@ -1082,6 +1077,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"); }