Explorar o código

Drop genAllCaseVariants hack, use new "insensitive" attribute for the "keyword" tag instead.

git-svn-id: file:///var/svn/tigccpp/branches/ktigcc-1-branch@1181 9552661e-59e3-4036-b4f2-dbe53926924f
kevinkofler %!s(int64=17) %!d(string=hai) anos
pai
achega
a9bdfef48e
Modificáronse 2 ficheiros con 8 adicións e 44 borrados
  1. 2 0
      ktigcc/NEWS
  2. 6 44
      ktigcc/preferences.cpp

+ 2 - 0
ktigcc/NEWS

@@ -5,6 +5,8 @@ CVS ktigcc-1-branch (2007-07-02):
 * KDElibs 3.5.7 or higher are now required.
 * Ctrl+Return now works for "Open file at cursor" (not just Ctrl+Numpad Enter)
 * Fixed extra newline incorrectly added each time a file is saved.
+* Now generating smaller syntax highlighting descriptions for mixes of
+  case-sensitive and case-insensitive word lists (using new KatePart feature).
 
 
 KTIGCC 1.07 (2007-04-03):

+ 6 - 44
ktigcc/preferences.cpp

@@ -44,36 +44,12 @@
 
 // versions of the syntax highlighting description file:
 // 1.00 = KTIGCC 20060807 Beta
-// 1.01 = current
-#define CURRENT_SYNFILE_VERSION "1.01"
+// 1.01 = KTIGCC 20060814 Beta - 1.07 
+// 1.02 = current KTIGCC 1 (since 1.08)
+#define CURRENT_SYNFILE_VERSION "1.02"
 
 TIGCCPrefs preferences;
 
-static void genAllCaseVariants(QString keyword, unsigned pos,
-                               QStringList &stringList)
-{
-  // WARNING: Exponential complexity in the keyword length. Yuck!
-  // Blame Kate's lack of flexibility.
-  // Also note that this just LOOKS like a functional recursion, there ARE side
-  // effects.
-  QChar c=keyword[pos];
-  if (c.isNull())
-    stringList.append(keyword);
-  else {
-    QChar upper=c.upper();
-    QChar lower=c.lower();
-    if (lower==upper)
-      genAllCaseVariants(keyword,pos+1,stringList);
-    else {
-      keyword[pos]=upper;
-      genAllCaseVariants(keyword,pos+1,stringList);
-      keyword[pos]=lower;
-      genAllCaseVariants(keyword,pos+1,stringList);
-      keyword[pos]=c;
-    }
-  }
-}
-
 static void writeSyntaxXML(const Syn_SettingsForDoc &synprefs,
                            const QString &name, const QString &internalName)
 {
@@ -119,23 +95,7 @@ static void writeSyntaxXML(const Syn_SettingsForDoc &synprefs,
     const Syn_WordList &wordList=*it;
     CHILD_NODE(list,highlighting,"list");
     ADD_ATTR(list,"name",wordList.name);
-    QStringList stringList;
-    if (wordList.caseSensitive || allWordListsCaseInsensitive)
-      stringList=wordList.list;
-    else {
-      // This is really ugly. Why can't Kate allow me to specify
-      // case-sensitivity per word list?
-      for (QStringList::ConstIterator it=wordList.list.begin();
-           it!=wordList.list.end(); ++it) {
-        const QString &keyword=*it;
-        // This is bad, but I need to cap time, memory and disk space
-        // requirements somewhere.
-        if (keyword.length()<=10)
-          genAllCaseVariants(keyword,0,stringList);
-        else
-          stringList.append(keyword);
-      }
-    }
+    QStringList stringList=wordList.list;
     for (QStringList::ConstIterator it=stringList.begin(); it!=stringList.end();
          ++it) {
       const QString &keyword=*it;
@@ -195,6 +155,8 @@ static void writeSyntaxXML(const Syn_SettingsForDoc &synprefs,
     ADD_ATTR(detectWordList,"attribute",wordList.name);
     ADD_ATTR(detectWordList,"context","#stay");
     ADD_ATTR(detectWordList,"String",wordList.name);
+    if (!(wordList.caseSensitive || allWordListsCaseInsensitive))
+      ADD_ATTR(detectWordList,"insensitive","true");
   }
   CHILD_NODE(numFloat,defaultContext,"Float");
   ADD_ATTR(numFloat,"attribute","Number");