summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarshall Clow <mclow.lists@gmail.com>2014-12-15 23:57:56 +0000
committerMarshall Clow <mclow.lists@gmail.com>2014-12-15 23:57:56 +0000
commitb04058e8c103a9afe223b202360de3da0eb918a1 (patch)
tree1d92c8a4a18d6710447d1fad3d9515c57e370ae0
parent8210281d13dec1141f52abf9af8fca913cc0e9b9 (diff)
downloadbcm5719-llvm-b04058e8c103a9afe223b202360de3da0eb918a1.tar.gz
bcm5719-llvm-b04058e8c103a9afe223b202360de3da0eb918a1.zip
Implement LWG 2217 - operator==(sub_match, string) slices on embedded '\0's
llvm-svn: 224292
-rw-r--r--libcxx/include/regex8
-rw-r--r--libcxx/test/re/re.submatch/re.submatch.op/compare.pass.cpp30
-rw-r--r--libcxx/www/cxx1z_status.html2
3 files changed, 22 insertions, 18 deletions
diff --git a/libcxx/include/regex b/libcxx/include/regex
index 5e1c37c64e8..690213a978d 100644
--- a/libcxx/include/regex
+++ b/libcxx/include/regex
@@ -4926,7 +4926,7 @@ bool
operator==(const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __x,
const sub_match<_BiIter>& __y)
{
- return __y.compare(__x.c_str()) == 0;
+ return __y.compare(typename sub_match<_BiIter>::string_type(__x.data(), __x.size())) == 0;
}
template <class _BiIter, class _ST, class _SA>
@@ -4944,7 +4944,7 @@ bool
operator<(const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __x,
const sub_match<_BiIter>& __y)
{
- return __y.compare(__x.c_str()) > 0;
+ return __y.compare(typename sub_match<_BiIter>::string_type(__x.data(), __x.size())) > 0;
}
template <class _BiIter, class _ST, class _SA>
@@ -4979,7 +4979,7 @@ bool
operator==(const sub_match<_BiIter>& __x,
const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __y)
{
- return __x.compare(__y.c_str()) == 0;
+ return __x.compare(typename sub_match<_BiIter>::string_type(__y.data(), __y.size())) == 0;
}
template <class _BiIter, class _ST, class _SA>
@@ -4997,7 +4997,7 @@ bool
operator<(const sub_match<_BiIter>& __x,
const basic_string<typename iterator_traits<_BiIter>::value_type, _ST, _SA>& __y)
{
- return __x.compare(__y.c_str()) < 0;
+ return __x.compare(typename sub_match<_BiIter>::string_type(__y.data(), __y.size())) < 0;
}
template <class _BiIter, class _ST, class _SA>
diff --git a/libcxx/test/re/re.submatch/re.submatch.op/compare.pass.cpp b/libcxx/test/re/re.submatch/re.submatch.op/compare.pass.cpp
index 45e72adcc41..3a500d37b02 100644
--- a/libcxx/test/re/re.submatch/re.submatch.op/compare.pass.cpp
+++ b/libcxx/test/re/re.submatch/re.submatch.op/compare.pass.cpp
@@ -218,7 +218,7 @@
template <class CharT>
void
-test(const std::basic_string<CharT>& x, const std::basic_string<CharT>& y)
+test(const std::basic_string<CharT>& x, const std::basic_string<CharT>& y, bool doCStrTests = true)
{
typedef std::basic_string<CharT> string;
typedef std::sub_match<typename string::const_iterator> sub_match;
@@ -248,18 +248,20 @@ test(const std::basic_string<CharT>& x, const std::basic_string<CharT>& y)
assert((sm1 > y) == (x > y));
assert((sm1 <= y) == (x <= y));
assert((sm1 >= y) == (x >= y));
- assert((x.c_str() == sm2) == (x == y));
- assert((x.c_str() != sm2) == (x != y));
- assert((x.c_str() < sm2) == (x < y));
- assert((x.c_str() > sm2) == (x > y));
- assert((x.c_str() <= sm2) == (x <= y));
- assert((x.c_str() >= sm2) == (x >= y));
- assert((sm1 == y.c_str()) == (x == y));
- assert((sm1 != y.c_str()) == (x != y));
- assert((sm1 < y.c_str()) == (x < y));
- assert((sm1 > y.c_str()) == (x > y));
- assert((sm1 <= y.c_str()) == (x <= y));
- assert((sm1 >= y.c_str()) == (x >= y));
+ if (doCStrTests) {
+ assert((x.c_str() == sm2) == (x == y));
+ assert((x.c_str() != sm2) == (x != y));
+ assert((x.c_str() < sm2) == (x < y));
+ assert((x.c_str() > sm2) == (x > y));
+ assert((x.c_str() <= sm2) == (x <= y));
+ assert((x.c_str() >= sm2) == (x >= y));
+ assert((sm1 == y.c_str()) == (x == y));
+ assert((sm1 != y.c_str()) == (x != y));
+ assert((sm1 < y.c_str()) == (x < y));
+ assert((sm1 > y.c_str()) == (x > y));
+ assert((sm1 <= y.c_str()) == (x <= y));
+ assert((sm1 >= y.c_str()) == (x >= y));
+ }
assert((x[0] == sm2) == (string(1, x[0]) == y));
assert((x[0] != sm2) == (string(1, x[0]) != y));
assert((x[0] < sm2) == (string(1, x[0]) < y));
@@ -280,4 +282,6 @@ int main()
test(std::string("1234"), std::string("123"));
test(std::wstring(L"123"), std::wstring(L"123"));
test(std::wstring(L"1234"), std::wstring(L"123"));
+ test(std::string("123\056", 6), std::string("123\056", 6), false);
+ test(std::wstring(L"123\056", 6), std::wstring(L"123\056", 6), false);
}
diff --git a/libcxx/www/cxx1z_status.html b/libcxx/www/cxx1z_status.html
index caa750b586f..16b16f77dcf 100644
--- a/libcxx/www/cxx1z_status.html
+++ b/libcxx/www/cxx1z_status.html
@@ -87,7 +87,7 @@
<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2106">2106</td><td><code>move_iterator</code> wrapping iterators returning prvalues</td><td>Urbana</td><td></td></tr>
<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2129">2129</td><td>User specializations of <code>std::initializer_list</code></td><td>Urbana</td><td>Complete</td></tr>
<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2212">2212</td><td><code>tuple_size</code> for <code>const pair</code> request <tuple> header</td><td>Urbana</td><td>Complete</td></tr>
- <tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2217">2217</td><td><code>operator==(sub_match, string)</code> slices on embedded '\0's</td><td>Urbana</td><td></td></tr>
+ <tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2217">2217</td><td><code>operator==(sub_match, string)</code> slices on embedded '\0's</td><td>Urbana</td><td>Complete</td></tr>
<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2230">2230</td><td>"see below" for <code>initializer_list</code> constructors of unordered containers</td><td>Urbana</td><td>Complete</td></tr>
<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2233">2233</td><td><code>bad_function_call::what()</code> unhelpful</td><td>Urbana</td><td>Complete</td></tr>
<tr><td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2266">2266</td><td><code>vector</code> and <code>deque</code> have incorrect insert requirements</td><td>Urbana</td><td></td></tr>
OpenPOWER on IntegriCloud