mirror of https://github.com/AxioDL/tinyxml2.git
Unify character casts, reorganize checks
This commit is contained in:
parent
ebb0c8f904
commit
8b67d741d4
17
tinyxml2.cpp
17
tinyxml2.cpp
|
@ -1962,16 +1962,13 @@ XMLPrinter::XMLPrinter( FILE* file, bool compact, int depth ) :
|
||||||
_restrictedEntityFlag[i] = false;
|
_restrictedEntityFlag[i] = false;
|
||||||
}
|
}
|
||||||
for( int i=0; i<NUM_ENTITIES; ++i ) {
|
for( int i=0; i<NUM_ENTITIES; ++i ) {
|
||||||
TIXMLASSERT( entities[i].value < ENTITY_RANGE );
|
const char entityValue = entities[i].value;
|
||||||
if ( entities[i].value < ENTITY_RANGE ) {
|
TIXMLASSERT( 0 <= entityValue && entityValue < ENTITY_RANGE );
|
||||||
_entityFlag[ (int)entities[i].value ] = true;
|
_entityFlag[ (unsigned char)entityValue ] = true;
|
||||||
}
|
}
|
||||||
}
|
_restrictedEntityFlag[(unsigned char)'&'] = true;
|
||||||
// Clang doesn't like indexing arrays with 'char'
|
_restrictedEntityFlag[(unsigned char)'<'] = true;
|
||||||
// so cast to int. (Looks strange.)
|
_restrictedEntityFlag[(unsigned char)'>'] = true; // not required, but consistency is nice
|
||||||
_restrictedEntityFlag[(int)'&'] = true;
|
|
||||||
_restrictedEntityFlag[(int)'<'] = true;
|
|
||||||
_restrictedEntityFlag[(int)'>'] = true; // not required, but consistency is nice
|
|
||||||
_buffer.Push( 0 );
|
_buffer.Push( 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2039,7 +2036,7 @@ void XMLPrinter::PrintString( const char* p, bool restricted )
|
||||||
// Check for entities. If one is found, flush
|
// Check for entities. If one is found, flush
|
||||||
// the stream up until the entity, write the
|
// the stream up until the entity, write the
|
||||||
// entity, and keep looking.
|
// entity, and keep looking.
|
||||||
if ( flag[(unsigned)(*q)] ) {
|
if ( flag[(unsigned char)(*q)] ) {
|
||||||
while ( p < q ) {
|
while ( p < q ) {
|
||||||
Print( "%c", *p );
|
Print( "%c", *p );
|
||||||
++p;
|
++p;
|
||||||
|
|
|
@ -1398,6 +1398,10 @@ int main( int argc, const char ** argv )
|
||||||
doc.DeleteNode(pRoot);
|
doc.DeleteNode(pRoot);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
// Should not assert in DEBUG
|
||||||
|
XMLPrinter printer;
|
||||||
|
}
|
||||||
|
|
||||||
// ----------- Performance tracking --------------
|
// ----------- Performance tracking --------------
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue