From patchwork Thu Jan 5 00:53:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 39237 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp50124wrt; Wed, 4 Jan 2023 16:55:15 -0800 (PST) X-Google-Smtp-Source: AMrXdXvX0wEJF6YOgNt0e2+MxKRGF+Jt7DxpJL0k0rAEL6M+yo6u+2JQOkNxziCndx5GbYxTwh0a X-Received: by 2002:a05:6402:33a:b0:47d:c06a:c272 with SMTP id q26-20020a056402033a00b0047dc06ac272mr42873670edw.31.1672880115436; Wed, 04 Jan 2023 16:55:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672880115; cv=none; d=google.com; s=arc-20160816; b=YIxbakjrfHALFtdI64O7722pJYa1GabUL72WOqiYJZHSacDiAzTz2r8Deimi5XS22U gC+jLe9Ay+Vsni+44Yo35vCXutjABiyXjPH/69p+Q8TA0i5e85ioaugGixpJ9QX+mfzl oL77Tct4UUBtSWwWgygi2v0WIYYJwOebCBL0F5/3zx8QH6sYk5DCV8Uqus50fcGFpvwo fk5E2PIdclxEg9WfjXAYrOONEGH7QBW6gmGx3PHf6/dh/OSNDcLORcfs4vgWeVlB+fwO 49BjxHqtwUGUAJrr7ryil6NxuKvKqjb4dh41M0CRa8JLyUeqKN5H+vtdVxlYLeyBFYJK VZSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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=iqy0U8P0GaSc2Ggq7Krj0z1ZuoWHZ7XX2RJxm9MVf9c=; b=a/4FwfiChQrsrO7htvZ5blgh1kV8FyEvRHB1xRhOE3deJ/fQMQ+lN7Z2ThaiX0Gv06 jTTULcsUBspxPRkL1nAWb4/LJ40oJ8G7j2ImmPas3zZAy/k6bFqLT1cGcvbXsZc7umOM 9GGe9WweH9py2Z1bAaoq3UC4V1p59vOH4tnLArekkwSpVVnXahmtHFIkftpO67Aiab1l EH1pPLmT/ouC2FohNqfcSVRVJDxOova0ajGFXQxBLG2gcxDCcF2tGjTVblq9QUthMVFG 1ceD8o8CjTm4MfOPjQwgA74XzIyMNTrrnVxs1Y5rHm4jZxvQbcwnPtpPGuTfYuUPu2NG hYpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=mC5o30lV; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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 (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id l16-20020a056402255000b0047010e04c4dsi36011076edb.481.2023.01.04.16.55.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Jan 2023 16:55:15 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=mC5o30lV; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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 8A549382FC86 for ; Thu, 5 Jan 2023 00:54:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8A549382FC86 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1672880053; bh=iqy0U8P0GaSc2Ggq7Krj0z1ZuoWHZ7XX2RJxm9MVf9c=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=mC5o30lV3t7jgK2P21Ug/M0YkgOMQdVfmbswHHHTt+v51w21zRQRWVCuARAPChCHf ikvj6xFYGi7JPfqWvjcv9IsnzGf0MGtEdPXj0QudvP5uDc04mYogAWbEQaMgVD2Q9n QmkSDGwLYs0F/KSs9pI7IoJ/H0wgKMKXCXc54ZTQ= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 2EB3638438D6 for ; Thu, 5 Jan 2023 00:53:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2EB3638438D6 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-307-ncdVNF7YPlq5UGcYAZoZBw-1; Wed, 04 Jan 2023 19:53:18 -0500 X-MC-Unique: ncdVNF7YPlq5UGcYAZoZBw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DABAA8030A4; Thu, 5 Jan 2023 00:53:17 +0000 (UTC) Received: from localhost (unknown [10.33.36.242]) by smtp.corp.redhat.com (Postfix) with ESMTP id A572840C945A; Thu, 5 Jan 2023 00:53:17 +0000 (UTC) To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Support single components in name of chrono::current_zone() [PR108211] Date: Thu, 5 Jan 2023 00:53:16 +0000 Message-Id: <20230105005316.140306-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, 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: Jonathan Wakely via Gcc-patches From: Jonathan Wakely Reply-To: Jonathan Wakely 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?1754141940096523655?= X-GMAIL-MSGID: =?utf-8?q?1754141940096523655?= Tested x86_64-linux. Pushed to trunk. -- >8 -- 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. --- 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; }