private int EatWhitespaces(StringBuilder sb)
{
int pos = _ps.charPos;
int wsCount = 0;
char[] chars = _ps.chars;
for (; ;)
{
for (; ;)
{
switch (chars[pos])
{
case (char)0xA:
pos++;
OnNewLine(pos);
continue;
case (char)0xD:
if (chars[pos + 1] == (char)0xA)
{
int tmp1 = pos - _ps.charPos;
if (sb != null && !_ps.eolNormalized)
{
if (tmp1 > 0)
{
sb.Append(chars, _ps.charPos, tmp1);
wsCount += tmp1;
}
_ps.charPos = pos + 1;
}
pos += 2;
}
else if (pos + 1 < _ps.charsUsed || _ps.isEof)
{
if (!_ps.eolNormalized)
{
chars[pos] = (char)0xA; // EOL normalization of 0xD
}
pos++;
}
else
{
goto ReadData;
}
OnNewLine(pos);
continue;
case (char)0x9:
case (char)0x20:
pos++;
continue;
default:
if (pos == _ps.charsUsed)
{
goto ReadData;
}
else
{
int tmp2 = pos - _ps.charPos;
if (tmp2 > 0)
{
if (sb != null)
{
sb.Append(_ps.chars, _ps.charPos, tmp2);
}
_ps.charPos = pos;
wsCount += tmp2;
}
return wsCount;
}
}
}
ReadData:
int tmp3 = pos - _ps.charPos;
if (tmp3 > 0)
{
if (sb != null)
{
sb.Append(_ps.chars, _ps.charPos, tmp3);
}
_ps.charPos = pos;
wsCount += tmp3;
}
if (ReadData() == 0)
{
if (_ps.charsUsed - _ps.charPos == 0)
{
return wsCount;
}
if (_ps.chars[_ps.charPos] != (char)0xD)
{
Debug.Assert(false, "We should never get to this point.");
Throw(SR.Xml_UnexpectedEOF1);
}
Debug.Assert(_ps.isEof);
}
pos = _ps.charPos;
chars = _ps.chars;
}
}