[Kst] kdeextragear-2/kst/kst

George Staikos staikos at kde.org
Fri Feb 11 00:14:09 CET 2005


CVS commit by staikos: 

add the ability to parse nested brackets in order to implement 96334 and other
related features


  M +14 -2     labelparser.cpp   1.12


--- kdeextragear-2/kst/kst/labelparser.cpp  #1.11:1.12
@@ -329,6 +329,18 @@ static Chunk *parseInternal(Chunk *ctail
       case '[':
         {
-          int pos = txt.find(']', i + 1);
-          if (pos < 0 || pos == int(i) + 1) {
+          int bracketStack = 1;
+          int pos = -1;
+          for (uint searchPt = i + 1; bracketStack != 0 && searchPt < cnt; ++searchPt) {
+            if (txt[searchPt] == ']') {
+              if (--bracketStack == 0) {
+                pos = searchPt;
+                break;
+              }
+            } else if (txt[searchPt] == '[') {
+              ++bracketStack;
+            }
+          }
+
+          if (pos < 0 || pos == int(i) + 1 /* empty [] */) {
             return 0L;
           }




More information about the Kst mailing list