Commit 7fcdbdd2 by Jonathan Wakely Committed by Jonathan Wakely

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.

From-SVN: r228417
parent 43222a5e
2015-10-02 Jonathan Wakely <jwakely@redhat.com> 2015-10-02 Jonathan Wakely <jwakely@redhat.com>
* 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.
* testsuite/util/testsuite_fs.h (nonexistent_path): Use less generic * testsuite/util/testsuite_fs.h (nonexistent_path): Use less generic
name for paths. Prefer snprintf to sprintf. name for paths. Prefer snprintf to sprintf.
......
...@@ -44,8 +44,6 @@ namespace std _GLIBCXX_VISIBILITY(default) ...@@ -44,8 +44,6 @@ namespace std _GLIBCXX_VISIBILITY(default)
{ {
_GLIBCXX_BEGIN_NAMESPACE_VERSION _GLIBCXX_BEGIN_NAMESPACE_VERSION
#ifdef _GLIBCXX_USE_WCHAR_T
/** /**
* @addtogroup locales * @addtogroup locales
* @{ * @{
...@@ -157,6 +155,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -157,6 +155,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
return __str_codecvt_out(__first, __last, __outstr, __cvt, __state, __n); return __str_codecvt_out(__first, __last, __outstr, __cvt, __state, __n);
} }
#ifdef _GLIBCXX_USE_WCHAR_T
_GLIBCXX_BEGIN_NAMESPACE_CXX11 _GLIBCXX_BEGIN_NAMESPACE_CXX11
/// String conversions /// String conversions
...@@ -533,10 +533,10 @@ _GLIBCXX_END_NAMESPACE_CXX11 ...@@ -533,10 +533,10 @@ _GLIBCXX_END_NAMESPACE_CXX11
bool _M_always_noconv; bool _M_always_noconv;
}; };
/// @} group locales
#endif // _GLIBCXX_USE_WCHAR_T #endif // _GLIBCXX_USE_WCHAR_T
/// @} group locales
_GLIBCXX_END_NAMESPACE_VERSION _GLIBCXX_END_NAMESPACE_VERSION
} // namespace } // namespace
......
...@@ -279,7 +279,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 ...@@ -279,7 +279,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
string(const _Allocator& __a = _Allocator()) const; string(const _Allocator& __a = _Allocator()) const;
std::string string() const; std::string string() const;
#if _GLIBCXX_USE_WCHAR_T
std::wstring wstring() const; std::wstring wstring() const;
#endif
std::string u8string() const; std::string u8string() const;
std::u16string u16string() const; std::u16string u16string() const;
std::u32string u32string() const; std::u32string u32string() const;
...@@ -291,7 +293,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 ...@@ -291,7 +293,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
generic_string(const _Allocator& __a = _Allocator()) const; generic_string(const _Allocator& __a = _Allocator()) const;
std::string generic_string() const; std::string generic_string() const;
#if _GLIBCXX_USE_WCHAR_T
std::wstring generic_wstring() const; std::wstring generic_wstring() const;
#endif
std::string generic_u8string() const; std::string generic_u8string() const;
std::u16string generic_u16string() const; std::u16string generic_u16string() const;
std::u32string generic_u32string() const; std::u32string generic_u32string() const;
...@@ -828,8 +832,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 ...@@ -828,8 +832,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
inline std::string inline std::string
path::string() const { return string<char>(); } path::string() const { return string<char>(); }
#if _GLIBCXX_USE_WCHAR_T
inline std::wstring inline std::wstring
path::wstring() const { return string<wchar_t>(); } path::wstring() const { return string<wchar_t>(); }
#endif
inline std::string inline std::string
path::u8string() const path::u8string() const
...@@ -865,8 +871,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 ...@@ -865,8 +871,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
inline std::string inline std::string
path::generic_string() const { return string(); } path::generic_string() const { return string(); }
#if _GLIBCXX_USE_WCHAR_T
inline std::wstring inline std::wstring
path::generic_wstring() const { return wstring(); } path::generic_wstring() const { return wstring(); }
#endif
inline std::string inline std::string
path::generic_u8string() const { return u8string(); } path::generic_u8string() const { return u8string(); }
......
...@@ -437,8 +437,9 @@ path::_M_trim() ...@@ -437,8 +437,9 @@ path::_M_trim()
path::string_type path::string_type
path::_S_convert_loc(const char* __first, const char* __last, 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<codecvt<wchar_t, char, mbstate_t>>(__loc); auto& __cvt = std::use_facet<codecvt<wchar_t, char, mbstate_t>>(__loc);
basic_string<wchar_t> __ws; basic_string<wchar_t> __ws;
if (!__str_codecvt_in(__first, __last, __ws, __cvt)) if (!__str_codecvt_in(__first, __last, __ws, __cvt))
...@@ -450,6 +451,9 @@ path::_S_convert_loc(const char* __first, const char* __last, ...@@ -450,6 +451,9 @@ path::_S_convert_loc(const char* __first, const char* __last,
#else #else
return _Cvt<wchar_t>::_S_convert(__ws.data(), __ws.data() + __ws.size()); return _Cvt<wchar_t>::_S_convert(__ws.data(), __ws.data() + __ws.size());
#endif #endif
#else
return {__first, __last};
#endif
} }
std::size_t std::size_t
......
...@@ -36,6 +36,7 @@ test01() ...@@ -36,6 +36,7 @@ test01()
p2 = s.c_str(); p2 = s.c_str();
compare_paths(p0, p2); compare_paths(p0, p2);
#if _GLIBCXX_USE_WCHAR_T
std::wstring ws(s.begin(), s.end()); std::wstring ws(s.begin(), s.end());
p3 = ws; p3 = ws;
...@@ -43,6 +44,7 @@ test01() ...@@ -43,6 +44,7 @@ test01()
p4 = ws.c_str(); p4 = ws.c_str();
compare_paths(p0, p4); compare_paths(p0, p4);
#endif
} }
} }
...@@ -65,6 +67,7 @@ test02() ...@@ -65,6 +67,7 @@ test02()
p4.assign( s.c_str(), s.c_str() + s.size() ); p4.assign( s.c_str(), s.c_str() + s.size() );
compare_paths(p0, p4); compare_paths(p0, p4);
#if _GLIBCXX_USE_WCHAR_T
std::wstring ws(s.begin(), s.end()); std::wstring ws(s.begin(), s.end());
p5.assign(ws); p5.assign(ws);
...@@ -78,6 +81,7 @@ test02() ...@@ -78,6 +81,7 @@ test02()
p8.assign( ws.c_str(), ws.c_str() + ws.size() ); p8.assign( ws.c_str(), ws.c_str() + ws.size() );
compare_paths(p0, p8); compare_paths(p0, p8);
#endif
} }
} }
......
...@@ -35,7 +35,11 @@ test01() ...@@ -35,7 +35,11 @@ test01()
VERIFY( p.filename() == "foobar" ); VERIFY( p.filename() == "foobar" );
p += '/'; p += '/';
VERIFY( p.parent_path() == "/foobar" && p.filename() == "." ); VERIFY( p.parent_path() == "/foobar" && p.filename() == "." );
#if _GLIBCXX_USE_WCHAR_T
p += L"baz.txt"; p += L"baz.txt";
#else
p += "baz.txt";
#endif
VERIFY( p.filename() == "baz.txt" ); VERIFY( p.filename() == "baz.txt" );
p.concat("/dir/"); p.concat("/dir/");
VERIFY( p.parent_path() == "/foobar/baz.txt/dir" && p.filename() == "." ); VERIFY( p.parent_path() == "/foobar/baz.txt/dir" && p.filename() == "." );
......
...@@ -37,19 +37,22 @@ test01() ...@@ -37,19 +37,22 @@ test01()
path p3( s.c_str() ); path p3( s.c_str() );
path p4( s.c_str(), s.c_str() + s.size() ); 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()); std::wstring ws(s.begin(), s.end());
path p5 = ws; path p5 = ws;
path p6( ws.begin(), ws.end() ); path p6( ws.begin(), ws.end() );
path p7( ws.c_str() ); path p7( ws.c_str() );
path p8( ws.c_str(), ws.c_str() + ws.size() ); 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, p5);
compare_paths(p1, p6); compare_paths(p1, p6);
compare_paths(p1, p7); compare_paths(p1, p7);
compare_paths(p1, p8); compare_paths(p1, p8);
#endif
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment