From patchwork Wed Jul 12 20:04:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 119328 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp1384990vqm; Wed, 12 Jul 2023 13:05:55 -0700 (PDT) X-Google-Smtp-Source: APBJJlGK6BpIqEwznnQKXSAQhZ8VPv8f2L142txAb6jKrUtPkvj+k8ZKUIzptuM7jkBxXAFXDzD6 X-Received: by 2002:a17:906:2487:b0:988:8fce:17ba with SMTP id e7-20020a170906248700b009888fce17bamr16872529ejb.31.1689192355740; Wed, 12 Jul 2023 13:05:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689192355; cv=none; d=google.com; s=arc-20160816; b=Xr1rPxvchXPTpv8Jafrv+iG2jNgGoC3WY3hMV2EaBKUWFiJUp9nwwx5gPsI4gy/4ZK Ypne8g3Eac7WdB6/cgQLXRKjrkPrEKbSKn9cscjoRjqbCghqIguuQU2rX6TRECHsIru3 FGTNTJNTMgkPXVAywaxKmMbeDLlW+Zlb7QbGkxh3NbMEmsPw1DS6iDAgpaPeJrkOIHl/ UzR1H2mwiu14y4QeCWJ068AQqg8cNYYl+u2ug6ICft/TSN7gkAT1VUazCLlmHkE5E9sM EFn7wrtCR+uTKY9PAghwtxwp9d5G6rf7nXidVikM4N8eBautsn8e7r9/JUnCpEDqjov+ we4w== 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=+lg3V59tOQWR91zkQAXcU2YVJ5czv534GTUnuKvZQXY=; fh=sC8lnOfyH6gL5FYlMbZ1VDz6qVPMj/3ViLJWKNUCUgQ=; b=GXyzThi01rtF4FhbuaNUKZ4LTX7hYuISQFBEcBLRAZPLauliFZGuGcQZa3WDJk/+Y1 x0nQEzP+0ypjegnIjI8LPzp340L7ULetsHHOLBD2bSoi63zydMFmP66V8kgKj7HCFTxX YW39yqqQPNaUPd8yK+mRgVc20XjXd8f1VYYWLMo8WZhHE6YRA9tkaLf9mWkDcKLtIqIS cK7kCYUedMMoTIKr+xrHKaVPWoOatbr5RI9oM0aywr695Sn6oloLX088qt3+vMRvemuy yKWsU3jxwbpbm3mSFvPNL1G6cn1A7q1qUnjy+qZfVF9sIoCWm3cTSsCq4L8gtwbzeYfC pwpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=ilcZRQCo; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 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 (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id re7-20020a170906d8c700b00992f8116abdsi5506406ejb.480.2023.07.12.13.05.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jul 2023 13:05:55 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=ilcZRQCo; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 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 B6F5D3857029 for ; Wed, 12 Jul 2023 20:05:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B6F5D3857029 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1689192351; bh=+lg3V59tOQWR91zkQAXcU2YVJ5czv534GTUnuKvZQXY=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=ilcZRQCo5oBalOC3H0pM6LfKan9uNLzhxJZ5zb+bVhDSz6wbH9KdwkJYBvEQFpG44 hGciJfsJfGjtADxQbsx/qc7d4nHjMZwqw5hVmP7LwJsUr6Lgn1fO50dRCW94n7oFif a8voX904LK2g3Q/wmEeRPyTVy392g/T64avWGxyE= 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.133.124]) by sourceware.org (Postfix) with ESMTPS id 1B1F23858C1F for ; Wed, 12 Jul 2023 20:05:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1B1F23858C1F Received: from mimecast-mx02.redhat.com (66.187.233.73 [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-14-pmOozwAqNJe1GkZWhD2Vsw-1; Wed, 12 Jul 2023 16:05:02 -0400 X-MC-Unique: pmOozwAqNJe1GkZWhD2Vsw-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 A3FAB3C160F2; Wed, 12 Jul 2023 20:05:01 +0000 (UTC) Received: from localhost (unknown [10.42.28.140]) by smtp.corp.redhat.com (Postfix) with ESMTP id D79CA400E116; Wed, 12 Jul 2023 20:00:47 +0000 (UTC) To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Check conversion from filesystem::path to wide strings [PR95048] Date: Wed, 12 Jul 2023 21:04:38 +0100 Message-ID: <20230712200500.1914419-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=-12.1 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_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE 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: INBOX X-GMAIL-THRID: 1771246563573211227 X-GMAIL-MSGID: 1771246563573211227 Tested powerp64le-linux. Pushed to trunk. This can be backported too. -- >8 -- The testcase added for this bug only checks conversion from wide strings on construction, but the fix also covered conversion to wide stings via path::wstring(). Add checks for that, and u16string() and u32string(). libstdc++-v3/ChangeLog: PR libstdc++/95048 * testsuite/27_io/filesystem/path/construct/95048.cc: Check conversions to wide strings. * testsuite/experimental/filesystem/path/construct/95048.cc: Likewise. --- .../testsuite/27_io/filesystem/path/construct/95048.cc | 6 ++++++ .../experimental/filesystem/path/construct/95048.cc | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/libstdc++-v3/testsuite/27_io/filesystem/path/construct/95048.cc b/libstdc++-v3/testsuite/27_io/filesystem/path/construct/95048.cc index c1a382d1420..cd80d668b23 100644 --- a/libstdc++-v3/testsuite/27_io/filesystem/path/construct/95048.cc +++ b/libstdc++-v3/testsuite/27_io/filesystem/path/construct/95048.cc @@ -16,6 +16,8 @@ test_wide() VERIFY( CHECK(L, "\U0001F4C1") ); // folder VERIFY( CHECK(L, "\U0001F4C2") ); // open folder VERIFY( CHECK(L, "\U0001F4C4") ); // filing cabient + + VERIFY( path(u8"\U0001D11E").wstring() == L"\U0001D11E" ); // G Clef } void @@ -25,6 +27,8 @@ test_u16() VERIFY( CHECK(u, "\U0001F4C1") ); // folder VERIFY( CHECK(u, "\U0001F4C2") ); // open folder VERIFY( CHECK(u, "\U0001F4C4") ); // filing cabient + + VERIFY( path(u8"\U0001D11E").u16string() == u"\U0001D11E" ); // G Clef } void @@ -34,6 +38,8 @@ test_u32() VERIFY( CHECK(U, "\U0001F4C1") ); // folder VERIFY( CHECK(U, "\U0001F4C2") ); // open folder VERIFY( CHECK(U, "\U0001F4C4") ); // filing cabient + + VERIFY( path(u8"\U0001D11E").u32string() == U"\U0001D11E" ); // G Clef } int diff --git a/libstdc++-v3/testsuite/experimental/filesystem/path/construct/95048.cc b/libstdc++-v3/testsuite/experimental/filesystem/path/construct/95048.cc index b7a93f3c985..fc65bfecd4d 100644 --- a/libstdc++-v3/testsuite/experimental/filesystem/path/construct/95048.cc +++ b/libstdc++-v3/testsuite/experimental/filesystem/path/construct/95048.cc @@ -18,6 +18,8 @@ test_wide() VERIFY( CHECK(L, "\U0001F4C1") ); // folder VERIFY( CHECK(L, "\U0001F4C2") ); // open folder VERIFY( CHECK(L, "\U0001F4C4") ); // filing cabient + + VERIFY( path(u8"\U0001D11E").wstring() == L"\U0001D11E" ); // G Clef } void @@ -27,6 +29,8 @@ test_u16() VERIFY( CHECK(u, "\U0001F4C1") ); // folder VERIFY( CHECK(u, "\U0001F4C2") ); // open folder VERIFY( CHECK(u, "\U0001F4C4") ); // filing cabient + + VERIFY( path(u8"\U0001D11E").u16string() == u"\U0001D11E" ); // G Clef } void @@ -36,6 +40,8 @@ test_u32() VERIFY( CHECK(U, "\U0001F4C1") ); // folder VERIFY( CHECK(U, "\U0001F4C2") ); // open folder VERIFY( CHECK(U, "\U0001F4C4") ); // filing cabient + + VERIFY( path(u8"\U0001D11E").u32string() == U"\U0001D11E" ); // G Clef } int