commit 570be4760bf81a5236297ab8d4def66207cbd32e
Author: Kornel Benko <kor...@lyx.org>
Date:   Thu Mar 31 11:39:46 2022 +0200

    FindAdv: Amend a0daf5e5
    
    1.) Completed non backslashed '{' and '}' in regex in non format-search
---
 src/lyxfind.cpp |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/lyxfind.cpp b/src/lyxfind.cpp
index 73453cb..35fdd68 100644
--- a/src/lyxfind.cpp
+++ b/src/lyxfind.cpp
@@ -838,13 +838,14 @@ string correctRegex(string t, bool withformat)
         * and \{, \}, \[, \] => {, }, [, ]
         */
        string s("");
-       regex wordre("(\\\\)*(\\\\(([A-Za-z]+)( |\\{\\})?|[\\[\\]\\{\\}]))");
+       regex wordre("(\\\\)*(\\\\(([A-Za-z]+|[\\{\\}])( 
|\\{\\})?|[\\[\\]\\{\\}]))");
        size_t lastpos = 0;
        smatch sub;
        bool backslashed = false;
        if (accents.empty())
                buildAccentsMap();
 
+       //LYXERR0("correctRegex input '" << t << "'");
        for (sregex_iterator it(t.begin(), t.end(), wordre), end; it != end; 
++it) {
                sub = *it;
                string replace;
@@ -856,7 +857,6 @@ string correctRegex(string t, bool withformat)
                                replace = "\\";
                                {
                                        // transforms '\backslash \{' into '\{'
-                                       // and '\{' into '{'
                                        string next = t.substr(sub.position(2) 
+ sub.str(2).length(), 2);
                                        if ((next == "\\{") || (next == "\\}")) 
{
                                                replace = "";
@@ -889,6 +889,10 @@ string correctRegex(string t, bool withformat)
                                        }
                                }
                        }
+                       else if (sub.str(4) == "{") // transforms '\{' into '{'
+                               replace = "{";
+                       else if (sub.str(4) == "}")
+                                replace = "}";
                        else {
                                AccentsIterator it_ac = 
accents.find(sub.str(4));
                                if (it_ac == accents.end()) {
@@ -908,6 +912,7 @@ string correctRegex(string t, bool withformat)
                return t;
        else if (lastpos < t.length())
                s += t.substr(lastpos, t.length() - lastpos);
+       //LYXERR0("correctRegex output '" << s << "'");
        return s;
 }
 
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs

Reply via email to