From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2181) id 54B8E3858434; Thu, 5 Jan 2023 00:53:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 54B8E3858434 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1672879986; bh=YqmYV6CgwUj+uQS2kG1l9ytZ4RqrDvlH/ASIeYEuk/w=; h=From:To:Subject:Date:From; b=fHAHlhB02JaDXJRHW3ND5N0OCzRo5CvczQIebr32qEgRmJtxb3N4UbrzU5fQgZ9mb scmvs9Dq3pqN2147lQzvBm8DHTQP2gLYdRXlpzYGl0huzfnMa4j/cLBYoypQOpUDfr J5+SJnOik4b8irygaBkS1Do/ml9x4ZARgdvLkV1s= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jonathan Wakely To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r13-5004] libstdc++: Support single components in name of chrono::current_zone() [PR108211] X-Act-Checkin: gcc X-Git-Author: Jonathan Wakely X-Git-Refname: refs/heads/master X-Git-Oldrev: b1ad748754401613b5cf8e5d46b38ad1ee49d07a X-Git-Newrev: 56be1970765b6302de19977790a537d6feaaa34b Message-Id: <20230105005306.54B8E3858434@sourceware.org> Date: Thu, 5 Jan 2023 00:53:06 +0000 (GMT) List-Id: https://gcc.gnu.org/g:56be1970765b6302de19977790a537d6feaaa34b commit r13-5004-g56be1970765b6302de19977790a537d6feaaa34b Author: Jonathan Wakely Date: Wed Jan 4 20:49:59 2023 +0000 libstdc++: Support single components in name of chrono::current_zone() [PR108211] We currently only handle the case where /etc/localtime is a symlink to a path like ".../Etc/UTC" and fail for ".../UTC". This makes both work. libstdc++-v3/ChangeLog: PR libstdc++/108211 * src/c++20/tzdb.cc (chrono::current_zone()): Check for zone using only last component of the name. Diff: --- libstdc++-v3/src/c++20/tzdb.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libstdc++-v3/src/c++20/tzdb.cc b/libstdc++-v3/src/c++20/tzdb.cc index 6772517d55a..9103b159400 100644 --- a/libstdc++-v3/src/c++20/tzdb.cc +++ b/libstdc++-v3/src/c++20/tzdb.cc @@ -1501,8 +1501,11 @@ namespace std::chrono if (std::distance(first, last) > 2) { --last; - string name = std::prev(last)->string() + '/'; - name += last->string(); + string name = last->string(); + if (auto tz = do_locate_zone(this->zones, this->links, name)) + return tz; + --last; + name = last->string() + '/' + name; if (auto tz = do_locate_zone(this->zones, this->links, name)) return tz; }