Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ ParseCDataOrComment() [2/2]

bool System.Xml.XmlTextReaderImpl.ParseCDataOrComment ( XmlNodeType type,
out int outStartPos,
out int outEndPos )
inlineprivate

Definition at line 6038 of file XmlTextReaderImpl.cs.

6039 {
6040 if (_ps.charsUsed - _ps.charPos < 3 && ReadData() == 0)
6041 {
6042 Throw(System.SR.Xml_UnexpectedEOF, (type == XmlNodeType.Comment) ? "Comment" : "CDATA");
6043 }
6044 int num = _ps.charPos;
6045 char[] chars = _ps.chars;
6046 int num2 = 0;
6047 int num3 = -1;
6048 char c = ((type == XmlNodeType.Comment) ? '-' : ']');
6049 while (true)
6050 {
6051 char c2;
6052 if (XmlCharType.IsTextChar(c2 = chars[num]) && c2 != c)
6053 {
6054 num++;
6055 continue;
6056 }
6057 if (chars[num] == c)
6058 {
6059 if (chars[num + 1] == c)
6060 {
6061 if (chars[num + 2] == '>')
6062 {
6063 if (num2 > 0)
6064 {
6065 ShiftBuffer(num3 + num2, num3, num - num3 - num2);
6066 outEndPos = num - num2;
6067 }
6068 else
6069 {
6070 outEndPos = num;
6071 }
6073 _ps.charPos = num + 3;
6074 return true;
6075 }
6076 if (num + 2 == _ps.charsUsed)
6077 {
6078 break;
6079 }
6080 if (type == XmlNodeType.Comment)
6081 {
6083 }
6084 }
6085 else if (num + 1 == _ps.charsUsed)
6086 {
6087 break;
6088 }
6089 num++;
6090 continue;
6091 }
6092 switch (chars[num])
6093 {
6094 case '\n':
6095 num++;
6096 OnNewLine(num);
6097 continue;
6098 case '\r':
6099 if (chars[num + 1] == '\n')
6100 {
6101 if (!_ps.eolNormalized && _parsingMode == ParsingMode.Full)
6102 {
6103 if (num - _ps.charPos > 0)
6104 {
6105 if (num2 == 0)
6106 {
6107 num2 = 1;
6108 num3 = num;
6109 }
6110 else
6111 {
6112 ShiftBuffer(num3 + num2, num3, num - num3 - num2);
6113 num3 = num - num2;
6114 num2++;
6115 }
6116 }
6117 else
6118 {
6119 _ps.charPos++;
6120 }
6121 }
6122 num += 2;
6123 }
6124 else
6125 {
6126 if (num + 1 >= _ps.charsUsed && !_ps.isEof)
6127 {
6128 break;
6129 }
6130 if (!_ps.eolNormalized)
6131 {
6132 chars[num] = '\n';
6133 }
6134 num++;
6135 }
6136 OnNewLine(num);
6137 continue;
6138 case '\t':
6139 case '&':
6140 case '<':
6141 case ']':
6142 num++;
6143 continue;
6144 default:
6145 {
6146 if (num == _ps.charsUsed)
6147 {
6148 break;
6149 }
6150 char ch = chars[num];
6151 if (XmlCharType.IsHighSurrogate(ch))
6152 {
6153 if (num + 1 == _ps.charsUsed)
6154 {
6155 break;
6156 }
6157 num++;
6158 if (XmlCharType.IsLowSurrogate(chars[num]))
6159 {
6160 num++;
6161 continue;
6162 }
6163 }
6165 break;
6166 }
6167 }
6168 break;
6169 }
6170 if (num2 > 0)
6171 {
6172 ShiftBuffer(num3 + num2, num3, num - num3 - num2);
6173 outEndPos = num - num2;
6174 }
6175 else
6176 {
6177 outEndPos = num;
6178 }
6180 _ps.charPos = num;
6181 return false;
6182 }
static string Xml_InvalidCommentChars
Definition SR.cs:288
static string Xml_UnexpectedEOF
Definition SR.cs:36
Definition SR.cs:7
void ThrowInvalidChar(char[] data, int length, int invCharPos)
void Throw(int pos, string res, string arg)
void ShiftBuffer(int sourcePos, int destPos, int count)

References System.Xml.XmlTextReaderImpl._parsingMode, System.Xml.XmlTextReaderImpl._ps, System.ch, System.Xml.XmlTextReaderImpl.ParsingState.charPos, System.chars, System.Xml.XmlTextReaderImpl.ParsingState.chars, System.Xml.XmlTextReaderImpl.ParsingState.charsUsed, System.Xml.Dictionary, System.Xml.XmlTextReaderImpl.ParsingState.eolNormalized, System.Xml.XmlTextReaderImpl.ParsingState.isEof, System.Xml.XmlCharType.IsHighSurrogate(), System.Xml.XmlCharType.IsLowSurrogate(), System.Xml.XmlCharType.IsTextChar(), System.Xml.XmlTextReaderImpl.OnNewLine(), System.Xml.XmlTextReaderImpl.ReadData(), System.Xml.XmlTextReaderImpl.ShiftBuffer(), System.Xml.XmlTextReaderImpl.Throw(), System.Xml.XmlTextReaderImpl.ThrowInvalidChar(), System.type, System.SR.Xml_InvalidCommentChars, and System.SR.Xml_UnexpectedEOF.