private void ScanQName(bool isQName)
{
_tokenStartPos = _curPos;
int colonOffset = -1;
for (;;)
{
unsafe
{
if (_xmlCharType.IsStartNCNameSingleChar(_chars[_curPos]) || _chars[_curPos] == ':')
{
_curPos++;
}
#if XML10_FIFTH_EDITION
else if ( curPos + 1 < charsUsed && xmlCharType.IsNCNameSurrogateChar(chars[curPos+1], chars[curPos])) {
curPos += 2;
}
#endif
else
{
if (_curPos + 1 >= _charsUsed)
{
if (ReadDataInName())
{
continue;
}
Throw(_curPos, SR.Xml_UnexpectedEOF, "Name");
}
else
{
Throw(_curPos, SR.Xml_BadStartNameChar, XmlException.BuildCharExceptionArgs(_chars, _charsUsed, _curPos));
}
}
}
ContinueName:
unsafe
{
for (;;)
{
if (_xmlCharType.IsNCNameSingleChar(_chars[_curPos]))
{
_curPos++;
}
#if XML10_FIFTH_EDITION
else if ( curPos + 1 < charsUsed && xmlCharType.IsNameSurrogateChar(chars[curPos + 1], chars[curPos]) ) {
curPos += 2;
}
#endif
else
{
break;
}
}
}
if (_chars[_curPos] == ':')
{
if (isQName)
{
if (colonOffset != -1)
{
Throw(_curPos, SR.Xml_BadNameChar, XmlException.BuildCharExceptionArgs(':', '\0'));
}
colonOffset = _curPos - _tokenStartPos;
_curPos++;
continue;
}
else
{
_curPos++;
goto ContinueName;
}
}
// end of buffer
else if (_curPos == _charsUsed
#if XML10_FIFTH_EDITION
|| ( curPos + 1 == charsUsed && xmlCharType.IsNCNameHighSurrogateChar( chars[curPos] ) )
#endif
)
{
if (ReadDataInName())
{
goto ContinueName;
}
if (_tokenStartPos == _curPos)
{
Throw(_curPos, SR.Xml_UnexpectedEOF, "Name");
}
}
// end of name
_colonPos = (colonOffset == -1) ? -1 : _tokenStartPos + colonOffset;
return;
}
}