re: Use the variable-width pcre2 type

This was what we always did in string. It makes it match the
annoyingly variable width of wchar_t.

Fixes #9502
This commit is contained in:
Fabian Boehm 2023-01-21 10:48:02 +01:00
parent 9b4c4ee7b6
commit 52d2087dd3

View File

@ -251,7 +251,8 @@ maybe_t<wcstring> regex_t::substitute(const wcstring &subject, const wcstring &r
error_code_t rc = error_code_t rc =
pcre2_substitute(get_code(code_), to_sptr(subject), subject.size(), start_idx, options, pcre2_substitute(get_code(code_), to_sptr(subject), subject.size(), start_idx, options,
nullptr /* match_data */, nullptr /* context */, to_sptr(replacement), nullptr /* match_data */, nullptr /* context */, to_sptr(replacement),
replacement.size(), reinterpret_cast<PCRE2_UCHAR32 *>(buffer), &bufflen); // (not using UCHAR32 here for cygwin's benefit)
replacement.size(), reinterpret_cast<PCRE2_UCHAR *>(buffer), &bufflen);
if (out_repl_count) { if (out_repl_count) {
*out_repl_count = std::max(rc, 0); *out_repl_count = std::max(rc, 0);