]> git.lyx.org Git - lyx.git/commitdiff
Fix bug #10705
authorEnrico Forestieri <forenr@lyx.org>
Mon, 26 Jun 2017 14:14:27 +0000 (16:14 +0200)
committerEnrico Forestieri <forenr@lyx.org>
Mon, 26 Jun 2017 14:14:27 +0000 (16:14 +0200)
Seemingly, std::regex does not account for newlines in the string.

src/insets/InsetListings.cpp

index b847131f57acb95002b3e707dc73fea573e045f3..cf5892edec2a5896d7d5fa1fb88dd266856ae981 100644 (file)
@@ -515,7 +515,11 @@ TexString InsetListings::getCaption(OutputParams const & runparams) const
        // TexString validity: the substitution preserves the number of newlines.
        // Moreover we assume that $2 does not contain newlines, so that the texrow
        // information remains accurate.
-       cap.str = from_utf8(regex_replace(to_utf8(cap.str), reg, new_cap));
+       // Replace '\n' with an improbable character from Private Use Area-A
+       // and then return to '\n' after the regex replacement.
+       docstring const capstr = subst(cap.str, char_type('\n'), 0xffffd);
+       cap.str = subst(from_utf8(regex_replace(to_utf8(capstr), reg, new_cap)),
+                       0xffffd, char_type('\n'));
        return cap;
 }