private int ParseQName(bool isQName, int startOffset, out int colonPos)
{
int colonOffset = -1;
int pos = _ps.charPos + startOffset;
ContinueStartName:
char[] chars = _ps.chars;
// start name char
unsafe
{
if (_xmlCharType.IsStartNCNameSingleChar(chars[pos]))
{
pos++;
}
#if XML10_FIFTH_EDITION
else if (pos + 1 < ps.charsUsed && xmlCharType.IsNCNameSurrogateChar(chars[pos + 1], chars[pos]))
{
pos += 2;
}
#endif
else
{
if (pos + 1 >= _ps.charsUsed)
{
if (ReadDataInName(ref pos))
{
goto ContinueStartName;
}
Throw(pos, SR.Xml_UnexpectedEOF, "Name");
}
if (chars[pos] != ':' || _supportNamespaces)
{
Throw(pos, SR.Xml_BadStartNameChar, XmlException.BuildCharExceptionArgs(chars, _ps.charsUsed, pos));
}
}
}
ContinueName:
// parse name
unsafe
{
for (;;)
{
if (_xmlCharType.IsNCNameSingleChar(chars[pos]))
{
pos++;
}
#if XML10_FIFTH_EDITION
else if ( pos + 1 < ps.charsUsed && xmlCharType.IsNCNameSurrogateChar( chars[pos + 1], chars[pos] ) ) {
pos += 2;
}
#endif
else
{
break;
}
}
}
// colon
if (chars[pos] == ':')
{
if (_supportNamespaces)
{
if (colonOffset != -1 || !isQName)
{
Throw(pos, SR.Xml_BadNameChar, XmlException.BuildCharExceptionArgs(':', '\0'));
}
colonOffset = pos - _ps.charPos;
pos++;
goto ContinueStartName;
}
else
{
colonOffset = pos - _ps.charPos;
pos++;
goto ContinueName;
}
}
// end of buffer
else if (pos == _ps.charsUsed
#if XML10_FIFTH_EDITION
|| ( pos + 1 == ps.charsUsed && xmlCharType.IsNCNameHighSurrogateChar( chars[pos] ) )
#endif
)
{
if (ReadDataInName(ref pos))
{
chars = _ps.chars;
goto ContinueName;
}
Throw(pos, SR.Xml_UnexpectedEOF, "Name");
}
// end of name
colonPos = (colonOffset == -1) ? -1 : _ps.charPos + colonOffset;
return pos;
}