[libcxx] r225799 - Make regex::assign not clobber the regex in case of failure. Fixes PR#22213
Marshall Clow
mclow.lists at gmail.com
Tue Jan 13 08:49:52 PST 2015
Author: marshall
Date: Tue Jan 13 10:49:52 2015
New Revision: 225799
URL: http://llvm.org/viewvc/llvm-project?rev=225799&view=rev
Log:
Make regex::assign not clobber the regex in case of failure. Fixes PR#22213
Modified:
libcxx/trunk/include/regex
libcxx/trunk/test/std/re/re.regex/re.regex.assign/assign.pass.cpp
Modified: libcxx/trunk/include/regex
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/regex?rev=225799&r1=225798&r2=225799&view=diff
==============================================================================
--- libcxx/trunk/include/regex (original)
+++ libcxx/trunk/include/regex Tue Jan 13 10:49:52 2015
@@ -2599,9 +2599,7 @@ public:
assign(_ForwardIterator __first, _ForwardIterator __last,
flag_type __f = regex_constants::ECMAScript)
{
- __member_init(__f);
- __parse(__first, __last);
- return *this;
+ return assign(basic_regex(__first, __last, __f));
}
#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
Modified: libcxx/trunk/test/std/re/re.regex/re.regex.assign/assign.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.regex/re.regex.assign/assign.pass.cpp?rev=225799&r1=225798&r2=225799&view=diff
==============================================================================
--- libcxx/trunk/test/std/re/re.regex/re.regex.assign/assign.pass.cpp (original)
+++ libcxx/trunk/test/std/re/re.regex/re.regex.assign/assign.pass.cpp Tue Jan 13 10:49:52 2015
@@ -23,4 +23,13 @@ int main()
r2.assign(r1);
assert(r2.flags() == std::regex::ECMAScript);
assert(r2.mark_count() == 2);
+ assert(std::regex_search("ab", r2));
+
+ bool caught = false;
+ try { r2.assign("(def", std::regex::extended); }
+ catch(std::regex_error &) { caught = true; }
+ assert(caught);
+ assert(r2.flags() == std::regex::ECMAScript);
+ assert(r2.mark_count() == 2);
+ assert(std::regex_search("ab", r2));
}
More information about the cfe-commits
mailing list