[libcxx] r227384 - Fix for PR22061 by K-ballo

Marshall Clow mclow.lists at gmail.com
Wed Jan 28 14:22:35 PST 2015


Author: marshall
Date: Wed Jan 28 16:22:35 2015
New Revision: 227384

URL: http://llvm.org/viewvc/llvm-project?rev=227384&view=rev
Log:
Fix for PR22061 by K-ballo

Modified:
    libcxx/trunk/include/regex
    libcxx/trunk/test/std/re/re.results/re.results.acc/index.pass.cpp

Modified: libcxx/trunk/include/regex
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/regex?rev=227384&r1=227383&r2=227384&view=diff
==============================================================================
--- libcxx/trunk/include/regex (original)
+++ libcxx/trunk/include/regex Wed Jan 28 16:22:35 2015
@@ -5601,12 +5601,17 @@ basic_regex<_CharT, _Traits>::__match_at
     __node* __st = __start_.get();
     if (__st)
     {
+        sub_match<const _CharT*> __unmatched;
+        __unmatched.first   = __last;
+        __unmatched.second  = __last;
+        __unmatched.matched = false;
+
         __states.push_back(__state());
         __states.back().__do_ = 0;
         __states.back().__first_ = __first;
         __states.back().__current_ = __first;
         __states.back().__last_ = __last;
-        __states.back().__sub_matches_.resize(mark_count());
+        __states.back().__sub_matches_.resize(mark_count(), __unmatched);
         __states.back().__loop_data_.resize(__loop_count());
         __states.back().__node_ = __st;
         __states.back().__flags_ = __flags;
@@ -5746,12 +5751,17 @@ basic_regex<_CharT, _Traits>::__match_at
     __node* __st = __start_.get();
     if (__st)
     {
+        sub_match<const _CharT*> __unmatched;
+        __unmatched.first   = __last;
+        __unmatched.second  = __last;
+        __unmatched.matched = false;
+
         __states.push_back(__state());
         __states.back().__do_ = 0;
         __states.back().__first_ = __first;
         __states.back().__current_ = __first;
         __states.back().__last_ = __last;
-        __states.back().__sub_matches_.resize(mark_count());
+        __states.back().__sub_matches_.resize(mark_count(), __unmatched);
         __states.back().__loop_data_.resize(__loop_count());
         __states.back().__node_ = __st;
         __states.back().__flags_ = __flags;

Modified: libcxx/trunk/test/std/re/re.results/re.results.acc/index.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.results/re.results.acc/index.pass.cpp?rev=227384&r1=227383&r2=227384&view=diff
==============================================================================
--- libcxx/trunk/test/std/re/re.results/re.results.acc/index.pass.cpp (original)
+++ libcxx/trunk/test/std/re/re.results/re.results.acc/index.pass.cpp Wed Jan 28 16:22:35 2015
@@ -17,11 +17,13 @@
 #include <cassert>
 
 void
-test()
+test(std::regex_constants::syntax_option_type syntax)
 {
     std::match_results<const char*> m;
     const char s[] = "abcdefghijk";
-    assert(std::regex_search(s, m, std::regex("cd((e)fg)hi")));
+    assert(std::regex_search(s, m, std::regex("cd((e)fg)hi|(z)", syntax)));
+
+    assert(m.size() == 4);
 
     assert(m[0].first == s+2);
     assert(m[0].second == s+9);
@@ -46,5 +48,6 @@ test()
 
 int main()
 {
-    test();
+    test(std::regex_constants::ECMAScript);
+    test(std::regex_constants::extended);
 }





More information about the cfe-commits mailing list