Copy named sub-expression info when adapting ICU via iterators.

Fixes: https://svn.boost.org/trac10/ticket/13126.
This commit is contained in:
jzmaddock
2017-08-01 19:43:44 +01:00
parent 9d4a4b7e62
commit 5c543a8e2b
2 changed files with 41 additions and 6 deletions

View File

@ -389,12 +389,13 @@ inline u32regex make_u32regex(const U_NAMESPACE_QUALIFIER UnicodeString& s, boos
// regex_match overloads that widen the character type as appropriate:
//
namespace BOOST_REGEX_DETAIL_NS{
template<class MR1, class MR2>
void copy_results(MR1& out, MR2 const& in)
template<class MR1, class MR2, class NSubs>
void copy_results(MR1& out, MR2 const& in, NSubs named_subs)
{
// copy results from an adapted MR2 match_results:
out.set_size(in.size(), in.prefix().first.base(), in.suffix().second.base());
out.set_base(in.base().base());
out.set_named_subs(named_subs);
for(int i = 0; i < (int)in.size(); ++i)
{
if(in[i].matched || !i)
@ -443,7 +444,7 @@ bool do_regex_match(BidiIterator first, BidiIterator last,
match_type what;
bool result = ::boost::regex_match(conv_type(first, first, last), conv_type(last, first, last), what, e, flags);
// copy results across to m:
if(result) copy_results(m, what);
if(result) copy_results(m, what, e.get_named_subs());
return result;
}
template <class BidiIterator, class Allocator>
@ -459,7 +460,7 @@ bool do_regex_match(BidiIterator first, BidiIterator last,
match_type what;
bool result = ::boost::regex_match(conv_type(first, first, last), conv_type(last, first, last), what, e, flags);
// copy results across to m:
if(result) copy_results(m, what);
if(result) copy_results(m, what, e.get_named_subs());
return result;
}
} // namespace BOOST_REGEX_DETAIL_NS
@ -618,7 +619,7 @@ bool do_regex_search(BidiIterator first, BidiIterator last,
match_type what;
bool result = ::boost::regex_search(conv_type(first, first, last), conv_type(last, first, last), what, e, flags, conv_type(base));
// copy results across to m:
if(result) copy_results(m, what);
if(result) copy_results(m, what, e.get_named_subs());
return result;
}
template <class BidiIterator, class Allocator>
@ -635,7 +636,7 @@ bool do_regex_search(BidiIterator first, BidiIterator last,
match_type what;
bool result = ::boost::regex_search(conv_type(first, first, last), conv_type(last, first, last), what, e, flags, conv_type(base));
// copy results across to m:
if(result) copy_results(m, what);
if(result) copy_results(m, what, e.get_named_subs());
return result;
}
}