From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wm1-x32a.google.com with SMTP id f13-20020a1cc90d000000b003d08c4cf679so5053952wmb.5; Sat, 24 Dec 2022 03:40:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:reply-to:message-id:date :subject:to:from:from:to:cc:subject:date:message-id:reply-to; bh=lHgCZdP5dJuTKKzDQiuzflBaAfQu05m8h3004SP7ltc=; b=gSxmjXEUcC5fZew69hdl4QHkPhuQBQ5FAdcghq9sI2poUG+TqO51gO0bfF4wzvNtTQ se3hPREqGvb2wOJ40e8AYOu+0BKv6+leOs5fwaWX2orHXx5yfluSy/xOKNFjyRmCLubV Owuq+5chYAMpNU8rv05pTh+kZPd+c/MSAaNAAGjId8CuEIZmCmKdCigmYCDiPz1M4tcE VCV+Ayziwra7H6dlPUGo7+oG1JIt2yrOlsb3Wjq1pr8iuxHfwc1x6QtXo/Zzo4j2AsGs scN3HxSYUK5KNzguOQpK2aQlMjC8Jj3jC9d0Wg7KIhEO2Gz4Ex3UZtXSgZzSt5RG3OTJ YJvQ== 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) From: Iain Sandoe 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) Reply-To: iain@sandoe.co.uk MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 List-Id: 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"); } -- 2.37.1 (Apple Git-137.1)