version 1.4, 1999/03/25 17:39:04
|
version 1.5, 1999/03/31 11:52:30
|
Line 4239 boolean withUndo;
|
Line 4239 boolean withUndo;
|
else |
else |
c = GetNextInputChar (&eof); |
c = GetNextInputChar (&eof); |
CSSbuffer[CSSindex] = c; |
CSSbuffer[CSSindex] = c; |
switch (c) |
if (CSScomment == MAX_CSS_LENGTH || c == '*' || c == '/') |
{ |
{ |
case '\r': |
/* we're not within a comment or we're parsing * or / */ |
c = EOS; |
switch (c) |
break; |
|
case '@': |
|
/* perhaps an import primitive */ |
|
import = CSSindex; |
|
break; |
|
case ';': |
|
if (import != MAX_CSS_LENGTH) |
|
{ |
{ |
if (ustrncasecmp (&CSSbuffer[import+1], "import", 6)) |
case '\r': |
/* it's not an import */ |
c = EOS; |
import = MAX_CSS_LENGTH; |
break; |
/* save the text */ |
case '@': |
noRule = TRUE; |
/* perhaps an import primitive */ |
|
import = CSSindex; |
|
break; |
|
case ';': |
|
if (import != MAX_CSS_LENGTH) |
|
{ |
|
if (ustrncasecmp (&CSSbuffer[import+1], "import", 6)) |
|
/* it's not an import */ |
|
import = MAX_CSS_LENGTH; |
|
/* save the text */ |
|
noRule = TRUE; |
|
} |
|
break; |
|
case '*': |
|
if (CSSindex > 0 && CSSbuffer[CSSindex - 1] == '/') |
|
/* start a comment */ |
|
CSScomment = CSSindex - 1; |
|
break; |
|
case '/': |
|
if (CSSindex > 0 && CSSbuffer[CSSindex - 1] == '*' && CSScomment != MAX_CSS_LENGTH) |
|
{ |
|
/* close a comment */ |
|
CSSindex = CSScomment - 1; /* incremented later */ |
|
CSScomment = MAX_CSS_LENGTH; |
|
} |
|
else if (CSSindex > 0 && CSSbuffer[CSSindex - 1] == '<') |
|
{ |
|
/* this is the closing tag ! */ |
|
CSSparsing = FALSE; |
|
CSSindex -= 2; /* remove </ from the CSS string */ |
|
} |
|
break; |
|
case '<': |
|
if (buffer != NULL) |
|
{ |
|
c = buffer[index++]; |
|
eof = (c == EOS); |
|
} |
|
else |
|
c = GetNextInputChar (&eof); |
|
if (c == '!') |
|
{ |
|
/* CSS within an HTML comment */ |
|
HTMLcomment = TRUE; |
|
CSSindex++; |
|
CSSbuffer[CSSindex] = c; |
|
} |
|
else if (c == '/' && CSScomment == MAX_CSS_LENGTH) |
|
{ |
|
CSSindex--; |
|
/* Ok we consider this as a closing tag ! */ |
|
CSSparsing = FALSE; |
|
} |
|
else if (c == EOS) |
|
CSSindex++; |
|
break; |
|
case '-': |
|
if (CSSindex > 0 && CSSbuffer[CSSindex - 1] == '-' && HTMLcomment) |
|
/* CSS within an HTML comment */ |
|
noRule = TRUE; |
|
break; |
|
case '>': |
|
if (HTMLcomment) |
|
noRule = TRUE; |
|
break; |
|
case '{': |
|
openRule++; |
|
if (import != MAX_CSS_LENGTH && openRule == 1) |
|
{ |
|
/* is it the screen concerned? */ |
|
CSSbuffer[CSSindex+1] = EOS; |
|
base = ustrstr (&CSSbuffer[import], "screen"); |
|
if (base == NULL) |
|
ignoreMedia = TRUE; |
|
noRule = TRUE; |
|
} |
|
break; |
|
case '}': |
|
openRule--; |
|
if (import != MAX_CSS_LENGTH && openRule == 0) |
|
{ |
|
import = MAX_CSS_LENGTH; |
|
noRule = TRUE; |
|
ignoreMedia = FALSE; |
|
} |
|
else |
|
toParse = TRUE; |
|
break; |
|
default: |
|
break; |
} |
} |
break; |
if (c != EOS) |
case '*': |
|
if (CSSindex > 0 && CSSbuffer[CSSindex - 1] == '/') |
|
/* start a comment */ |
|
CSScomment = CSSindex - 1; |
|
break; |
|
case '/': |
|
if (CSSindex > 0 && CSSbuffer[CSSindex - 1] == '*' && CSScomment != MAX_CSS_LENGTH) |
|
{ |
|
/* close a comment */ |
|
CSSindex = CSScomment - 1; /* incremented later */ |
|
CSScomment = MAX_CSS_LENGTH; |
|
} |
|
else if (CSSindex > 0 && CSSbuffer[CSSindex - 1] == '<') |
|
{ |
|
/* this is the closing tag ! */ |
|
CSSparsing = FALSE; |
|
CSSindex -= 2; /* remove </ from the CSS string */ |
|
} |
|
break; |
|
case '<': |
|
if (buffer != NULL) |
|
{ |
|
c = buffer[index++]; |
|
eof = (c == EOS); |
|
} |
|
else |
|
c = GetNextInputChar (&eof); |
|
if (c == '!') |
|
{ |
|
/* CSS within an HTML comment */ |
|
HTMLcomment = TRUE; |
|
CSSindex++; |
|
CSSbuffer[CSSindex] = c; |
|
} |
|
else if (c == '/' && CSScomment == MAX_CSS_LENGTH) |
|
{ |
|
CSSindex--; |
|
/* Ok we consider this as a closing tag ! */ |
|
CSSparsing = FALSE; |
|
} |
|
else if (c == EOS) |
|
CSSindex++; |
CSSindex++; |
break; |
|
case '-': |
|
if (CSSindex > 0 && CSSbuffer[CSSindex - 1] == '-' && HTMLcomment) |
|
/* CSS within an HTML comment */ |
|
noRule = TRUE; |
|
break; |
|
case '>': |
|
if (HTMLcomment) |
|
noRule = TRUE; |
|
break; |
|
case '{': |
|
openRule++; |
|
if (import != MAX_CSS_LENGTH && openRule == 1) |
|
{ |
|
/* is it the screen concerned? */ |
|
CSSbuffer[CSSindex+1] = EOS; |
|
base = ustrstr (&CSSbuffer[import], "screen"); |
|
if (base == NULL) |
|
ignoreMedia = TRUE; |
|
noRule = TRUE; |
|
} |
|
break; |
|
case '}': |
|
openRule--; |
|
if (import != MAX_CSS_LENGTH && openRule == 0) |
|
{ |
|
import = MAX_CSS_LENGTH; |
|
noRule = TRUE; |
|
ignoreMedia = FALSE; |
|
} |
|
else |
|
toParse = TRUE; |
|
break; |
|
default: |
|
break; |
|
} |
} |
if (c != EOS) |
|
CSSindex++; |
|
if (CSSindex >= MAX_CSS_LENGTH || !CSSparsing || toParse || noRule) |
if (CSSindex >= MAX_CSS_LENGTH || !CSSparsing || toParse || noRule) |
{ |
{ |
CSSbuffer[CSSindex] = EOS; |
CSSbuffer[CSSindex] = EOS; |