re.results.form: Format out-of-range subexpression references as null
Rather than crashing in match_results::format() when a reference to a marked subexpression is out of range, format the subexpression as empty (i.e., replace it with an empty string). Note that match_results::operator[]() has a range-check and returns a null match in this case, so this just re-uses that logic. git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@259682 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -5387,8 +5387,8 @@ match_results<_BidirectionalIterator, _Allocator>::format(_OutputIter __out,
|
||||
if ('0' <= *__fmt_first && *__fmt_first <= '9')
|
||||
{
|
||||
size_t __i = *__fmt_first - '0';
|
||||
__out = _VSTD::copy(__matches_[__i].first,
|
||||
__matches_[__i].second, __out);
|
||||
__out = _VSTD::copy((*this)[__i].first,
|
||||
(*this)[__i].second, __out);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -5439,8 +5439,8 @@ match_results<_BidirectionalIterator, _Allocator>::format(_OutputIter __out,
|
||||
++__fmt_first;
|
||||
__i = 10 * __i + *__fmt_first - '0';
|
||||
}
|
||||
__out = _VSTD::copy(__matches_[__i].first,
|
||||
__matches_[__i].second, __out);
|
||||
__out = _VSTD::copy((*this)[__i].first,
|
||||
(*this)[__i].second, __out);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user