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: 36404 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp120164wrt; Sat, 24 Dec 2022 03:41:09 -0800 (PST) X-Google-Smtp-Source: AMrXdXvz7p8MHDt5gAvVQoW2FcVaXVG/hA7JGOjg8WtU33qNkIUVssrp0r0Vvttdn1LH5sORUxm3 X-Received: by 2002:a17:906:5dad:b0:7c0:dfba:54d3 with SMTP id n13-20020a1709065dad00b007c0dfba54d3mr10615520ejv.20.1671882069868; Sat, 24 Dec 2022 03:41:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671882069; cv=none; d=google.com; s=arc-20160816; b=qDxs0Bse3ZI+ri6Q/UB3e9bMqUebN5Yb28rQezLqqPOC7/SClq3mNAcK/rTJr8aDZU oPJI9REM84WGiWcV+4JeHaE+riQSzrCOyDeEHYc5Pm7rhNVV468pqybxt5kTUapKUDG5 xJ9x41M3ki00OE3Y0/WggEFTr+/jGc5zcCsd1lSlRwrJW/WNNUic8Cd04UVhVEvddfsg tuR+qlEsUIB1HHQgZWqtRl5SAYgHFJfdJy7TQ7CaPmFI3U51A3UHVu//Cp1LzJjmHrUi A7KWhe9vHFyXun/yYybZRClCTzbVimRMMM1CRI/6HDqC9c3hVTqFZcUorG7tXo2WTY1j drPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:reply-to:from:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=lHgCZdP5dJuTKKzDQiuzflBaAfQu05m8h3004SP7ltc=; b=RrZiZHtiCKpBYnl1BZTuk7sGZN5jkm3tBx6KW3inMwMTZldpI2CbXwKdlIEE7bD8cz qlCg+ZjcuVaJtJHgukKz1Sc+MZj6rlW+4lcyKhqpAAxypMlsGkXTB+2HNe02Erm4tN1a H2ajBacr+RffePqNr0HUnBZibGAhq52Yl2C/KszltUQcdWZqPLb9djdp7tndqYC0WhPa mJlOEIhJPFoTC+ZH1iVIF4fTyfnJV6HrnMrkRYvbSwuq5x7ySFoymjkLJpfon6Z7ZOnV NkICLPbanybQXws4skUseYGnNbK+A0WJEvjkpYA4ocrKFUAop7aoQJ/DahigiljAnBoI RzVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=anAvWky0; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id nc19-20020a1709071c1300b008334aeea09esi4850587ejc.187.2022.12.24.03.41.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 24 Dec 2022 03:41:09 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=anAvWky0; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2F515384F031 for ; Sat, 24 Dec 2022 11:40:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2F515384F031 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1671882056; bh=lHgCZdP5dJuTKKzDQiuzflBaAfQu05m8h3004SP7ltc=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=anAvWky0zsXKL1zK4Rm+LBpcean54zl+lSEiFdwiwFFllD3UaSzD1mvRQUaXVLZKc assKxm5fZHEMBfXPsSutzUiTeJBoaBUTHDiiamO9IKb39f5NvWJiWcKvaPWHeYKJwy hek5qsX8ue9mzT++lgY4IMhpk8zbqnGQmb3fOy9g= 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-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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1753095413215370536?= X-GMAIL-MSGID: =?utf-8?q?1753095413215370536?= 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"); }