]> git.lyx.org Git - features.git/commitdiff
Fix InsetListings::getCaption() for std::regex
authorGeorg Baum <baum@lyx.org>
Sun, 22 Nov 2015 16:43:10 +0000 (17:43 +0100)
committerGeorg Baum <baum@lyx.org>
Sun, 22 Nov 2015 16:43:10 +0000 (17:43 +0100)
Back references in the format string of regex_replace use the syntax $n both
in std::regex and in boost::regex for the default format. Boost seems to
support the syntax \n in addition, but it is not documented at
http://www.boost.org/doc/libs/master/libs/regex/doc/html/boost_regex/format.html.
Therefore it is a good idea to use $n also for boost.

src/insets/InsetListings.cpp
src/tests/check_ListingsCaption.cpp

index 9c7daf22198cfa05cd3d0c1c206fc7a332139dcc..91125d8895796518c3fb89f179f56eb525f1bf62 100644 (file)
@@ -418,7 +418,7 @@ docstring InsetListings::getCaption(OutputParams const & runparams) const
        //
        // NOTE that } is not allowed in blah2.
        regex const reg("(.*)\\\\label\\{(.*?)\\}(.*)");
-       string const new_cap("\\1\\3},label={\\2");
+       string const new_cap("$1$3},label={$2");
        return from_utf8(regex_replace(to_utf8(cap), reg, new_cap));
 }
 
index 2df43e8cdc475678bc726e5d39bab9b8f3c331c7..874e3d67b8754399196beb815fc7a90dbe2bb636 100644 (file)
@@ -23,7 +23,7 @@ string test_ListingsCaption(string const & cap)
        //
        // NOTE that } is not allowed in blah2.
        regex const reg("(.*)\\\\label\\{(.*?)\\}(.*)");
-       string const new_cap("\\1\\3},label={\\2");
+       string const new_cap("$1$3},label={$2");
        return regex_replace(cap, reg, new_cap);
 }