MCPcopy Create free account
hub / github.com/NanoMichael/MicroTeX / GetStr

Method GetStr

src/xml/tinyxml2.cpp:179–266  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

177
178
179const char* StrPair::GetStr() {
180 TIXMLASSERT( _start );
181 TIXMLASSERT( _end );
182 if ( _flags & NEEDS_FLUSH ) {
183 *_end = 0;
184 _flags ^= NEEDS_FLUSH;
185
186 if ( _flags ) {
187 char* p = _start; // the read pointer
188 char* q = _start; // the write pointer
189
190 while( p < _end ) {
191 if ( (_flags & NEEDS_NEWLINE_NORMALIZATION) && *p == CR ) {
192 // CR-LF pair becomes LF
193 // CR alone becomes LF
194 // LF-CR becomes LF
195 if ( *(p+1) == LF ) {
196 p += 2;
197 } else {
198 ++p;
199 }
200 *q++ = LF;
201 } else if ( (_flags & NEEDS_NEWLINE_NORMALIZATION) && *p == LF ) {
202 if ( *(p+1) == CR ) {
203 p += 2;
204 } else {
205 ++p;
206 }
207 *q++ = LF;
208 } else if ( (_flags & NEEDS_ENTITY_PROCESSING) && *p == '&' ) {
209 // Entities handled by tinyXML2:
210 // - special entities in the entity table [in/out]
211 // - numeric character reference [in]
212 // &#20013; or &#x4e2d;
213
214 if ( *(p+1) == '#' ) {
215 const int buflen = 10;
216 char buf[buflen] = { 0 };
217 int len = 0;
218 char* adjusted = const_cast<char*>( XMLUtil::GetCharacterRef( p, buf, &len ) );
219 if ( adjusted == 0 ) {
220 *q = *p;
221 ++p;
222 ++q;
223 } else {
224 TIXMLASSERT( 0 <= len && len <= buflen );
225 TIXMLASSERT( q + len <= adjusted );
226 p = adjusted;
227 memcpy( q, buf, len );
228 q += len;
229 }
230 } else {
231 int i=0;
232 for(; i<NUM_ENTITIES; ++i ) {
233 const Entity& entity = entities[i];
234 if ( strncmp( p + 1, entity.pattern, entity.length ) == 0
235 && *( p + entity.length + 1 ) == ';' ) {
236 // Found an entity - convert.

Callers 3

ValueMethod · 0.80
ParseDeepMethod · 0.80
NameMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected