Remove C-style comment lines from stylesheets
authorManuel Nickschas <sputnick@quassel-irc.org>
Thu, 25 Jun 2009 17:49:40 +0000 (19:49 +0200)
committerManuel Nickschas <sputnick@quassel-irc.org>
Thu, 6 Aug 2009 18:25:05 +0000 (20:25 +0200)
We also now remove all sections we parse and handle from the stylesheet
prior to handing it over to QApplication, so we can use incompatible extensions.

src/uisupport/qssparser.cpp

index 91ecac5..f46147b 100644 (file)
@@ -55,13 +55,17 @@ void QssParser::processStyleSheet(QString &ss) {
   if(ss.isEmpty())
     return;
 
   if(ss.isEmpty())
     return;
 
-  // Now we have the stylesheet itself in ss, start parsing
+  // Remove C-style comments /* */ or //
+  QRegExp commentRx("(//.*(\\n|$)|/\\*.*\\*/)");
+  commentRx.setMinimal(true);
+  ss.remove(commentRx);
+
   // Palette definitions first, so we can apply roles later on
   QRegExp paletterx("(Palette[^{]*)\\{([^}]+)\\}");
   int pos = 0;
   while((pos = paletterx.indexIn(ss, pos)) >= 0) {
     parsePaletteData(paletterx.cap(1).trimmed(), paletterx.cap(2).trimmed());
   // Palette definitions first, so we can apply roles later on
   QRegExp paletterx("(Palette[^{]*)\\{([^}]+)\\}");
   int pos = 0;
   while((pos = paletterx.indexIn(ss, pos)) >= 0) {
     parsePaletteData(paletterx.cap(1).trimmed(), paletterx.cap(2).trimmed());
-    pos += paletterx.matchedLength();
+    ss.remove(pos, paletterx.matchedLength());
   }
 
   // Now we can parse the rest of our custom blocks
   }
 
   // Now we can parse the rest of our custom blocks
@@ -75,9 +79,8 @@ void QssParser::processStyleSheet(QString &ss) {
     //else
     // TODO: add moar here
 
     //else
     // TODO: add moar here
 
-    pos += blockrx.matchedLength();
+    ss.remove(pos, blockrx.matchedLength());
   }
   }
-
 }
 
 void QssParser::parseChatLineData(const QString &decl, const QString &contents) {
 }
 
 void QssParser::parseChatLineData(const QString &decl, const QString &contents) {