From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) by sourceware.org (Postfix) with ESMTPS id 308563858D1E; Sat, 24 Dec 2022 12:04:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 308563858D1E 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-ej1-x633.google.com with SMTP id bj12so17310622ejb.13; Sat, 24 Dec 2022 04:04:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=H0Xe4/FMfc3S6SO8FeNEFu0zWIOgFWYrM/0wt4+MxvU=; b=LKz3xTn0osqU6HOMg2fhVABULBYAk07Tnq3XkKj9ZeizUzhKNolX2ZLY+oSMBA6a2N idKFXliJ4tP4XPcRYsJ/A4Hc7TdR2gMAr7PqH8cRwsMPyj0o64CyRZE3zJTNdBNYiNKb 7q/Sedg1NM5TZWYSv8zqacFWwOwS8zwjkG3lpvCtIL9BZ+33BQvX391cuMyaJqr1FSve FGKT/gD4+ba3+VQ/KykNTeNIyBr6ZTWHoCRqf9o/HpcSNETHI9rHxxaTiy8jwpZAzcJM bTEYPBlGm7hfpTr3S6HhmJyvta/HZYtZQPabE+MpTayOM2nZ7gLZcksU8d2xalh2cmFb 72Hw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=H0Xe4/FMfc3S6SO8FeNEFu0zWIOgFWYrM/0wt4+MxvU=; b=CfAm2rabaJUyDeEfSw6k4lWLdZYFodT8QiB7RIpkyoDg+Z5bw3jTjMIINFYOnoX+cc O8BZ4ZCdCxRIpAFDiEQg0kZFVY0JqfyeVJm0TdCGtjUoodKS9Mb81dJk649+9810r/FV rEpph2ShlE64aV6eNIKVa7Zjqs2fvOeYQt3ngbGqqWg94kxq29OBfNCMvHYlv0hm3be8 p6+3fEn+ZJdgON4e9/jQKQ5olw/nTIqZMvV7w0yYmDaZn2rDxkAJ95bEJIiiCWeF/bCt h10EcWADsZJEdXJ/YO6sl7t+kROx3tLC8JxiZDHrc6NPWpze9ODVoxw8zo4IqtOoRNNX gHdA== X-Gm-Message-State: AFqh2kp1LuGToHIzqHmw1UoJh4zXMpFtw04awA+vz7BobcxkI1Yg84RP u45Wj0OREGz6M4ZyTPM9sBzoTCHi81Spu5ygG/I= X-Google-Smtp-Source: AMrXdXvTjW+deUSNZ143qZ8upQhgjyO7FFmEGNERuQ8f0kfbNDKaepey8iPNLLuCXE6+/nJSyujHd3oKV5+cF+H/VNc= X-Received: by 2002:a17:906:9243:b0:7c0:d58f:3409 with SMTP id c3-20020a170906924300b007c0d58f3409mr693589ejx.416.1671883445899; Sat, 24 Dec 2022 04:04:05 -0800 (PST) MIME-Version: 1.0 References: <20221224114009.20261-1-iain@sandoe.co.uk> In-Reply-To: <20221224114009.20261-1-iain@sandoe.co.uk> From: Jonathan Wakely Date: Sat, 24 Dec 2022 12:03:54 +0000 Message-ID: Subject: Re: [PATCH] libstdc++: Test for tzdata.zi before fallback version files. To: Iain Sandoe Cc: "libstdc++" , gcc-patches , Iain Sandoe Content-Type: multipart/alternative; boundary="000000000000e6146105f091b252" X-Spam-Status: No, score=-6.7 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,HTML_MESSAGE,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: --000000000000e6146105f091b252 Content-Type: text/plain; charset="UTF-8" On Sat, 24 Dec 2022, 11:40 Iain Sandoe via Libstdc++, wrote: > 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. > Yeah, my thinking was that you could still query the "remote version" i.e. the one on disk, even if it can't be loaded (in which case, the basic fallback one has version "ersatz", so you can tell it doesn't match the one on disk). > 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. > Oh yes, good point. If we have an override for tzdata then than is the on-disk one and we should check its version. OK for trunk, thanks. > 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) > > --000000000000e6146105f091b252--