public virtual Node GetCdata(Node container)
{
int c, lastc, start;
bool endtag = false;
Lines = Input.CursorLine;
Columns = Input.CursorColumn;
Waswhite = false;
Txtstart = Lexsize;
Txtend = Lexsize;
lastc = '\x0000';
start = - 1;
while (true)
{
c = Input.ReadChar();
if (c == StreamIn.END_OF_STREAM)
{
break;
}
/* treat \r\n as \n and \r as \n */
if (c == '/' && lastc == '<')
{
if (endtag)
{
Lines = Input.CursorLine;
Columns = Input.CursorColumn - 3;
Report.Warning(this, null, null, Report.BAD_CDATA_CONTENT);
}
start = Lexsize + 1; /* to first letter */
endtag = true;
}
else if (c == '>' && start >= 0)
{
int len = Lexsize - start;
if (len == container.Element.Length)
{
string str = GetString(Lexbuf, start, len);
if (String.CompareOrdinal(str, container.Element) == 0)
{
Txtend = start - 2;
break;
}
}
Lines = Input.CursorLine;
Columns = Input.CursorColumn - 3;
Report.Warning(this, null, null, Report.BAD_CDATA_CONTENT);
/* if javascript insert backslash before / */
if (ParserImpl.IsJavaScript(container))
{
int i;
for (i = Lexsize; i > start - 1; --i)
{
Lexbuf[i] = Lexbuf[i - 1];
}
Lexbuf[start - 1] = (byte) '\\';
Lexsize++;
}
start = - 1;
}
else if (c == '\r')
{
c = Input.ReadChar();
if (c != '\n')
{
Input.UngetChar(c);
}
c = '\n';
}
AddCharToLexer(c);
Txtend = Lexsize;
lastc = c;
}
if (c == StreamIn.END_OF_STREAM)
{
Report.Warning(this, container, null, Report.MISSING_ENDTAG_FOR);
}
if (Txtend > Txtstart)
{
Token = NewNode(Node.TEXT_NODE, Lexbuf, Txtstart, Txtend);
return Token;
}
return null;
}