[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [ktexteditor] /: support multi char captures only in {xxx} to avoid regressions
From:       Christoph Cullmann <cullmann () kde ! org>
Date:       2016-09-08 20:17:54
Message-ID: E1bi5li-0001Iq-20 () code ! kde ! org
[Download RAW message or body]

Git commit 650f1a3a854fa9a27b9ffab563306327f8aa5c1a by Christoph Cullmann.
Committed on 08/09/2016 at 20:17.
Pushed by cullmann into branch 'master'.

support multi char captures only in {xxx} to avoid regressions

M  +1    -1    autotests/src/searchbar_test.cpp
M  +14   -2    src/search/kateregexpsearch.cpp

http://commits.kde.org/ktexteditor/650f1a3a854fa9a27b9ffab563306327f8aa5c1a

diff --git a/autotests/src/searchbar_test.cpp b/autotests/src/searchbar_test.cpp
index c5b8e69..e3c568e 100644
--- a/autotests/src/searchbar_test.cpp
+++ b/autotests/src/searchbar_test.cpp
@@ -632,7 +632,7 @@ void SearchBarTest::testReplaceManyCapturesBug365124()
 
     bar.setSearchPattern("^(.*) (.*) (.*) (.*) (.*) (.*) (.*) (.*) (.*) (.*) (.*) \
(.*) (.*)$");  bar.setSearchMode(KateSearchBar::MODE_REGEX);
-    bar.setReplacementPattern("\\1::\\2::\\3::\\4::\\5::\\6::\\7::\\8::\\9::\\10::\\11::\\12::\\13");
 +    bar.setReplacementPattern("\\{1}::\\2::\\3::\\4::\\5::\\6::\\7::\\8::\\9::\\{10}::\\{11}::\\{12}::\\{13}");
  
     bar.replaceAll();
 
diff --git a/src/search/kateregexpsearch.cpp b/src/search/kateregexpsearch.cpp
index 1ba7abd..2eea756 100644
--- a/src/search/kateregexpsearch.cpp
+++ b/src/search/kateregexpsearch.cpp
@@ -555,6 +555,7 @@ QVector<KTextEditor::Range> KateRegExpSearch::search(
                 }
                 break;
 
+            // single letter captures
             case L'1':
             case L'2':
             case L'3':
@@ -564,8 +565,15 @@ QVector<KTextEditor::Range> KateRegExpSearch::search(
             case L'7':
             case L'8':
             case L'9': {
-                // allow 1212124.... captures, see bug 365124 + \
                testReplaceManyCapturesBug365124
-                int capture = 9 - (L'9' - text[input + 1].unicode());
+                out << ReplacementStream::cap(9 - (L'9' - text[input + \
1].unicode())); +                input += 2;
+                break;
+            }
+
+            // multi letter captures
+            case L'{': {
+                // allow {1212124}.... captures, see bug 365124 + \
testReplaceManyCapturesBug365124 +                int capture = 0;
                 int captureSize = 2;
                 while ((input + captureSize) < inputLen) {
                     const ushort nextDigit = text[input + captureSize].unicode();
@@ -574,6 +582,10 @@ QVector<KTextEditor::Range> KateRegExpSearch::search(
                         ++captureSize;
                         continue;
                     }
+                    if (nextDigit == L'}') {
+                        ++captureSize;
+                        break;
+                    }
                     break;
                 }
                 out << ReplacementStream::cap(capture);


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic