aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIain Sandoe <iain@sandoe.co.uk>2022-12-24 10:59:26 +0000
committerIain Sandoe <iain@sandoe.co.uk>2022-12-24 17:51:48 +0000
commit8ec139af5ea9657c7517c1483c7a577815bea48e (patch)
treebe2d6568657ec53457b4b75ea40a615f2aa96ca8
parent4c3a036be5f4dd68e0e4d8fb3a152c06538f5872 (diff)
downloadgcc-8ec139af5ea9657c7517c1483c7a577815bea48e.zip
gcc-8ec139af5ea9657c7517c1483c7a577815bea48e.tar.gz
gcc-8ec139af5ea9657c7517c1483c7a577815bea48e.tar.bz2
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.
-rw-r--r--libstdc++-v3/src/c++20/tzdb.cc17
1 files changed, 10 insertions, 7 deletions
diff --git a/libstdc++-v3/src/c++20/tzdb.cc b/libstdc++-v3/src/c++20/tzdb.cc
index 5f5c419..2a4e213 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");
}