From patchwork Fri Oct 2 19:38:41 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 525760 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 5D93B140D6D for ; Sat, 3 Oct 2015 05:39:02 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=vv6Xil/Z; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=Ruex9v73jHL7PgqFKyGWYFGBv4CsVTWjypj3JQ08M3CzFvOYxPClO fFqrEUqGKKnJX3jERHPq9sU6s4gWcVX75ZaeUgh+Lk+Y4IltQ2nbcQbQlAAr5rf5 tnxeeh8VdjnO1kpJ3VXbcVc5GOpyaXOp/USA20kasPnbKmpQqqWjoQ= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; s= default; bh=Z+pSxbugWU4qlBGaSl7ompbLc/o=; b=vv6Xil/Z4edWBLG8eaSm PH4gnUUz8YlwIf1w40+6OD617Ky9r8GkHq4eReInPwm8heNJo2YIqqWWZpNFG05I zIDBJtlWwWvGlduWDwlRk/phYBdjePONCSSESgVBx0AEDPSt4B4/ytfe7ho79RA2 +1RKyYHIz8WM5+htPJ6VRdU= Received: (qmail 119556 invoked by alias); 2 Oct 2015 19:38:55 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 119447 invoked by uid 89); 2 Oct 2015 19:38:53 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL, BAYES_00, SPF_HELO_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-Spam-User: qpsmtpd, 2 recipients X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 02 Oct 2015 19:38:43 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 60AE6558DE; Fri, 2 Oct 2015 19:38:42 +0000 (UTC) Received: from localhost (ovpn-116-138.ams2.redhat.com [10.36.116.138]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t92JcfNn005496; Fri, 2 Oct 2015 15:38:42 -0400 Date: Fri, 2 Oct 2015 20:38:41 +0100 From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [patch] Allow Filesystem TS to compile without wchar_t Message-ID: <20151002193840.GW12094@redhat.com> MIME-Version: 1.0 Content-Disposition: inline X-Clacks-Overhead: GNU Terry Pratchett User-Agent: Mutt/1.5.23 (2014-03-12) This guards all uses of wchar_t with _GLIBCXX_USE_WCHAR_T. There's also a second patch that improves a testsuite helper function slightly. Tested powerpc64le-linux, x86_64dragonfly, powerpc-aix. Committed to trunk. commit e765e9d79405c7979f656460b995e6237900eea3 Author: Jonathan Wakely Date: Fri Oct 2 18:07:27 2015 +0100 Allow Filesystem TS to compile without wchar_t * include/bits/locale_conv.h [!_GLIBCXX_USE_WCHAR_T] (__do_str_codecvt, __str_codecvt_in, __str_codecvt_out): Enable. * include/experimental/fs_path.h [!_GLIBCXX_USE_WCHAR_T] (path::wstring, path::generic_wstring): Disable. * src/filesystem/path.cc (path::_S_convert_loc) [!_GLIBCXX_USE_WCHAR_T]: Skip conversion. * testsuite/experimental/filesystem/path/assign/assign.cc: Check for wchar_t support. * testsuite/experimental/filesystem/path/concat/strings.cc: Likewise. * testsuite/experimental/filesystem/path/construct/range.cc: Likewise. diff --git a/libstdc++-v3/include/bits/locale_conv.h b/libstdc++-v3/include/bits/locale_conv.h index 146f78b..16b4875 100644 --- a/libstdc++-v3/include/bits/locale_conv.h +++ b/libstdc++-v3/include/bits/locale_conv.h @@ -44,8 +44,6 @@ namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION -#ifdef _GLIBCXX_USE_WCHAR_T - /** * @addtogroup locales * @{ @@ -157,6 +155,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION return __str_codecvt_out(__first, __last, __outstr, __cvt, __state, __n); } +#ifdef _GLIBCXX_USE_WCHAR_T + _GLIBCXX_BEGIN_NAMESPACE_CXX11 /// String conversions @@ -533,10 +533,10 @@ _GLIBCXX_END_NAMESPACE_CXX11 bool _M_always_noconv; }; - /// @} group locales - #endif // _GLIBCXX_USE_WCHAR_T + /// @} group locales + _GLIBCXX_END_NAMESPACE_VERSION } // namespace diff --git a/libstdc++-v3/include/experimental/fs_path.h b/libstdc++-v3/include/experimental/fs_path.h index 5daef12..40462a6 100644 --- a/libstdc++-v3/include/experimental/fs_path.h +++ b/libstdc++-v3/include/experimental/fs_path.h @@ -279,7 +279,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 string(const _Allocator& __a = _Allocator()) const; std::string string() const; +#if _GLIBCXX_USE_WCHAR_T std::wstring wstring() const; +#endif std::string u8string() const; std::u16string u16string() const; std::u32string u32string() const; @@ -291,7 +293,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 generic_string(const _Allocator& __a = _Allocator()) const; std::string generic_string() const; +#if _GLIBCXX_USE_WCHAR_T std::wstring generic_wstring() const; +#endif std::string generic_u8string() const; std::u16string generic_u16string() const; std::u32string generic_u32string() const; @@ -828,8 +832,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 inline std::string path::string() const { return string(); } +#if _GLIBCXX_USE_WCHAR_T inline std::wstring path::wstring() const { return string(); } +#endif inline std::string path::u8string() const @@ -865,8 +871,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 inline std::string path::generic_string() const { return string(); } +#if _GLIBCXX_USE_WCHAR_T inline std::wstring path::generic_wstring() const { return wstring(); } +#endif inline std::string path::generic_u8string() const { return u8string(); } diff --git a/libstdc++-v3/src/filesystem/path.cc b/libstdc++-v3/src/filesystem/path.cc index a5441b9..e85c9fc 100644 --- a/libstdc++-v3/src/filesystem/path.cc +++ b/libstdc++-v3/src/filesystem/path.cc @@ -437,8 +437,9 @@ path::_M_trim() path::string_type path::_S_convert_loc(const char* __first, const char* __last, - const std::locale& __loc) + const std::locale& __loc) { +#if _GLIBCXX_USE_WCHAR_T auto& __cvt = std::use_facet>(__loc); basic_string __ws; if (!__str_codecvt_in(__first, __last, __ws, __cvt)) @@ -450,6 +451,9 @@ path::_S_convert_loc(const char* __first, const char* __last, #else return _Cvt::_S_convert(__ws.data(), __ws.data() + __ws.size()); #endif +#else + return {__first, __last}; +#endif } std::size_t diff --git a/libstdc++-v3/testsuite/experimental/filesystem/path/assign/assign.cc b/libstdc++-v3/testsuite/experimental/filesystem/path/assign/assign.cc index 6fd24a7..fe4f96c 100644 --- a/libstdc++-v3/testsuite/experimental/filesystem/path/assign/assign.cc +++ b/libstdc++-v3/testsuite/experimental/filesystem/path/assign/assign.cc @@ -36,6 +36,7 @@ test01() p2 = s.c_str(); compare_paths(p0, p2); +#if _GLIBCXX_USE_WCHAR_T std::wstring ws(s.begin(), s.end()); p3 = ws; @@ -43,6 +44,7 @@ test01() p4 = ws.c_str(); compare_paths(p0, p4); +#endif } } @@ -65,6 +67,7 @@ test02() p4.assign( s.c_str(), s.c_str() + s.size() ); compare_paths(p0, p4); +#if _GLIBCXX_USE_WCHAR_T std::wstring ws(s.begin(), s.end()); p5.assign(ws); @@ -78,6 +81,7 @@ test02() p8.assign( ws.c_str(), ws.c_str() + ws.size() ); compare_paths(p0, p8); +#endif } } diff --git a/libstdc++-v3/testsuite/experimental/filesystem/path/concat/strings.cc b/libstdc++-v3/testsuite/experimental/filesystem/path/concat/strings.cc index e75e790..61ef7e4 100644 --- a/libstdc++-v3/testsuite/experimental/filesystem/path/concat/strings.cc +++ b/libstdc++-v3/testsuite/experimental/filesystem/path/concat/strings.cc @@ -35,7 +35,11 @@ test01() VERIFY( p.filename() == "foobar" ); p += '/'; VERIFY( p.parent_path() == "/foobar" && p.filename() == "." ); +#if _GLIBCXX_USE_WCHAR_T p += L"baz.txt"; +#else + p += "baz.txt"; +#endif VERIFY( p.filename() == "baz.txt" ); p.concat("/dir/"); VERIFY( p.parent_path() == "/foobar/baz.txt/dir" && p.filename() == "." ); diff --git a/libstdc++-v3/testsuite/experimental/filesystem/path/construct/range.cc b/libstdc++-v3/testsuite/experimental/filesystem/path/construct/range.cc index 03e5085..2e892291 100644 --- a/libstdc++-v3/testsuite/experimental/filesystem/path/construct/range.cc +++ b/libstdc++-v3/testsuite/experimental/filesystem/path/construct/range.cc @@ -37,19 +37,22 @@ test01() path p3( s.c_str() ); path p4( s.c_str(), s.c_str() + s.size() ); + compare_paths(p1, p2); + compare_paths(p1, p3); + compare_paths(p1, p4); + +#if _GLIBCXX_USE_WCHAR_T std::wstring ws(s.begin(), s.end()); path p5 = ws; path p6( ws.begin(), ws.end() ); path p7( ws.c_str() ); path p8( ws.c_str(), ws.c_str() + ws.size() ); - compare_paths(p1, p2); - compare_paths(p1, p3); - compare_paths(p1, p4); compare_paths(p1, p5); compare_paths(p1, p6); compare_paths(p1, p7); compare_paths(p1, p8); +#endif } } commit 00e2e9e7053d2d557e832da2055b8ae220f65c74 Author: Jonathan Wakely Date: Fri Oct 2 17:38:08 2015 +0100 * testsuite/util/testsuite_fs.h (nonexistent_path): Use less generic name for paths. Prefer snprintf to sprintf. diff --git a/libstdc++-v3/testsuite/util/testsuite_fs.h b/libstdc++-v3/testsuite/util/testsuite_fs.h index 524972e..44aef11 100644 --- a/libstdc++-v3/testsuite/util/testsuite_fs.h +++ b/libstdc++-v3/testsuite/util/testsuite_fs.h @@ -73,7 +73,7 @@ namespace __gnu_test { std::experimental::filesystem::path p; #if defined(_GNU_SOURCE) || _XOPEN_SOURCE >= 500 || _POSIX_C_SOURCE >= 200112L - char tmp[] = "test.XXXXXX"; + char tmp[] = "filesystem-ts-test.XXXXXX"; int fd = ::mkstemp(tmp); if (fd == -1) throw std::experimental::filesystem::filesystem_error("mkstemp failed", @@ -83,7 +83,11 @@ namespace __gnu_test p = tmp; #else char buf[64]; - std::sprintf(buf, "test.%lu", (unsigned long)::getpid()); +#if _GLIBCXX_USE_C99 + std::snprintf(buf, 64, "filesystem-ts-test.%lu", (unsigned long)::getpid()); +#else + std::sprintf(buf, "filesystem-ts-test.%lu", (unsigned long)::getpid()); +#endif p = buf; #endif return p;