gcc/libstdc++-v3/testsuite/28_regex
Jonathan Wakely ef5d671cd8 libstdc++: Fix std::regex_replace for strings with embedded null [PR103664]
The overload of std::regex_replace that takes a std::basic_string as the
fmt argument (for the replacement string) is implemented in terms of the
one taking a const C*, which uses std::char_traits to find the length.
That means it stops at a null character, even though the basic_string
might have additional characters beyond that.

Rather than duplicate the implementation of the const C* one for the
std::basic_string case, this moves that implementation to a new
__regex_replace function which takes a const C* and a length. Then both
the std::basic_string and const C* overloads can call that (with the
latter using char_traits to find the length to pass to the new
function).

libstdc++-v3/ChangeLog:

	PR libstdc++/103664
	* include/bits/regex.h (__regex_replace): Declare.
	(regex_replace): Use it.
	* include/bits/regex.tcc (__regex_replace): Replace regex_replace
	definition with __regex_replace.
	* testsuite/28_regex/algorithms/regex_replace/char/103664.cc: New test.
2021-12-13 11:11:30 +00:00
..
algorithms libstdc++: Fix std::regex_replace for strings with embedded null [PR103664] 2021-12-13 11:11:30 +00:00
basic_regex libstdc++: Fix 28_regex/basic_regex/84110.cc on Solaris 2021-10-26 14:07:57 +02:00
constants Update copyright years. 2021-01-04 10:26:59 +01:00
headers/regex Update copyright years. 2021-01-04 10:26:59 +01:00
iterators Update copyright years. 2021-01-04 10:26:59 +01:00
match_results libstdc++: Replace hyphens in effective target keywords 2021-11-24 13:20:26 +00:00
regex_error Update copyright years. 2021-01-04 10:26:59 +01:00
requirements Update copyright years. 2021-01-04 10:26:59 +01:00
sub_match Update copyright years. 2021-01-04 10:26:59 +01:00
traits libstdc++: Reduce header dependencies in <regex> 2021-08-03 15:24:52 +01:00
init-list.cc Update copyright years. 2021-01-04 10:26:59 +01:00
range_access.cc libstdc++: Add [[nodiscard]] to iterators and related utilities 2021-08-04 12:54:28 +01:00
regression.cc Update copyright years. 2021-01-04 10:26:59 +01:00
simple_c++11.cc Update copyright years. 2021-01-04 10:26:59 +01:00