diff options
author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2016-02-03 19:30:20 +0000 |
---|---|---|
committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2016-02-03 19:30:20 +0000 |
commit | f42ef3efcad9095920232a0a710a80c5c4720170 (patch) | |
tree | d5f41002a9b443e9771eda155ecc4ea97082eb6a /libcxx/include/regex | |
parent | 0fc3a001682c0bd076a329024192e57b3bc950fd (diff) | |
download | bcm5719-llvm-f42ef3efcad9095920232a0a710a80c5c4720170.tar.gz bcm5719-llvm-f42ef3efcad9095920232a0a710a80c5c4720170.zip |
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.
llvm-svn: 259682
Diffstat (limited to 'libcxx/include/regex')
-rw-r--r-- | libcxx/include/regex | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/libcxx/include/regex b/libcxx/include/regex index ca455f0ceea..f1f3264d320 100644 --- a/libcxx/include/regex +++ b/libcxx/include/regex @@ -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 { |