public inbox for libstdc++-cvs@sourceware.org
help / color / mirror / Atom feed
From: Iain D Sandoe <iains@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org
Subject: [gcc r13-4885] libstdc++: Test for tzdata.zi before fallback version files.
Date: Sat, 24 Dec 2022 17:52:06 +0000 (GMT)	[thread overview]
Message-ID: <20221224175206.8F9E93858D1E@sourceware.org> (raw)

https://gcc.gnu.org/g:8ec139af5ea9657c7517c1483c7a577815bea48e

commit r13-4885-g8ec139af5ea9657c7517c1483c7a577815bea48e
Author: Iain Sandoe <iain@sandoe.co.uk>
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 <iain@sandoe.co.uk>
    
    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");
     }

                 reply	other threads:[~2022-12-24 17:52 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221224175206.8F9E93858D1E@sourceware.org \
    --to=iains@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    --cc=libstdc++-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).