[PATCH] [libcxx] Fix match_results for alternatives
Agustín Bergé
kaballo86 at hotmail.com
Fri Jan 23 11:55:42 PST 2015
Address review comments.
http://reviews.llvm.org/D7111
Files:
include/regex
test/std/re/re.results/re.results.acc/index.pass.cpp
Index: include/regex
===================================================================
--- include/regex
+++ include/regex
@@ -5601,12 +5601,17 @@
__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 @@
__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;
Index: test/std/re/re.results/re.results.acc/index.pass.cpp
===================================================================
--- test/std/re/re.results/re.results.acc/index.pass.cpp
+++ test/std/re/re.results/re.results.acc/index.pass.cpp
@@ -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 @@
int main()
{
- test();
+ test(std::regex_constants::ECMAScript);
+ test(std::regex_constants::extended);
}
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D7111.18688.patch
Type: text/x-patch
Size: 2422 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150123/48102736/attachment.bin>
More information about the cfe-commits
mailing list