aboutsummaryrefslogtreecommitdiff
path: root/src/cssparser.cc
diff options
context:
space:
mode:
authorJohannes Hofmann <Johannes.Hofmann@gmx.de>2009-11-19 21:44:01 +0100
committerJohannes Hofmann <Johannes.Hofmann@gmx.de>2009-11-19 21:44:01 +0100
commitff63b2cd1caf488b655d94687a2f01d4a6d2d2e5 (patch)
tree5c2bebab22dd556e2483e3e2619569f82734850a /src/cssparser.cc
parentec2cc09a2ce6d924ffa11b15c5bc49abf25c92fc (diff)
ignore XML comment markers in CSS
Diffstat (limited to 'src/cssparser.cc')
-rw-r--r--src/cssparser.cc46
1 files changed, 29 insertions, 17 deletions
diff --git a/src/cssparser.cc b/src/cssparser.cc
index 1b575aec..5782925a 100644
--- a/src/cssparser.cc
+++ b/src/cssparser.cc
@@ -410,6 +410,28 @@ void CssParser::ungetChar()
bufptr--;
}
+/*
+ * Skip string str if it is found in the input buffer.
+ * If not wind back. The first char is passed as parameter c
+ * to avoid unnecessary getChar() / ungetChar() calls.
+ */
+inline bool CssParser::skipString(int c, const char *str)
+{
+ int n = 0;
+
+ while (str[n]) {
+ if (str[n] != c) {
+ while (n--)
+ ungetChar();
+ return false;
+ }
+ c = getChar();
+ n++;
+ }
+
+ return true;
+}
+
void CssParser::nextToken()
{
int c, c1, d, j;
@@ -419,26 +441,16 @@ void CssParser::nextToken()
ttype = CSS_TK_CHAR; /* init */
spaceSeparated = false;
- c = getChar();
-
while (true) {
- if (isspace(c)) { // ignore whitespace
+ c = getChar();
+ if (isspace(c)) { // ignore whitespace
spaceSeparated = true;
- c = getChar();
- } else if (c == '/') { // ignore comments
- d = getChar();
- if (d == '*') {
- c = getChar();
- d = getChar();
- while (d != EOF && (c != '*' || d != '/')) {
- c = d;
- d = getChar();
- }
+ } else if (skipString(c, "/*")) { // ignore comments
+ do {
c = getChar();
- } else {
- ungetChar();
- break;
- }
+ } while (! skipString(c, "*/"));
+ } else if (skipString(c, "<!--")) { // ignore XML comment markers
+ } else if (skipString(c, "-->")) {
} else {
break;
}