Merge remote-tracking branch 'origin/master'

This commit is contained in:
Lee Thomason 2014-12-26 12:20:18 -08:00
commit ac503ea88a
2 changed files with 12 additions and 19 deletions

View File

@ -1861,7 +1861,6 @@ XMLError XMLDocument::SaveFile( FILE* fp, bool compact )
XMLError XMLDocument::Parse( const char* p, size_t len ) XMLError XMLDocument::Parse( const char* p, size_t len )
{ {
const char* start = p;
Clear(); Clear();
if ( len == 0 || !p || !*p ) { if ( len == 0 || !p || !*p ) {
@ -1875,6 +1874,7 @@ XMLError XMLDocument::Parse( const char* p, size_t len )
memcpy( _charBuffer, p, len ); memcpy( _charBuffer, p, len );
_charBuffer[len] = 0; _charBuffer[len] = 0;
const char* start = p;
p = XMLUtil::SkipWhiteSpace( p ); p = XMLUtil::SkipWhiteSpace( p );
p = XMLUtil::ReadBOM( p, &_writeBOM ); p = XMLUtil::ReadBOM( p, &_writeBOM );
if ( !p || !*p ) { if ( !p || !*p ) {
@ -2069,9 +2069,7 @@ void XMLPrinter::PushHeader( bool writeBOM, bool writeDec )
void XMLPrinter::OpenElement( const char* name, bool compactMode ) void XMLPrinter::OpenElement( const char* name, bool compactMode )
{ {
if ( _elementJustOpened ) { SealElementIfJustOpened();
SealElement();
}
_stack.Push( name ); _stack.Push( name );
if ( _textDepth < 0 && !_firstElement && !compactMode ) { if ( _textDepth < 0 && !_firstElement && !compactMode ) {
@ -2155,8 +2153,11 @@ void XMLPrinter::CloseElement( bool compactMode )
} }
void XMLPrinter::SealElement() void XMLPrinter::SealElementIfJustOpened()
{ {
if ( !_elementJustOpened ) {
return;
}
_elementJustOpened = false; _elementJustOpened = false;
Print( ">" ); Print( ">" );
} }
@ -2166,9 +2167,7 @@ void XMLPrinter::PushText( const char* text, bool cdata )
{ {
_textDepth = _depth-1; _textDepth = _depth-1;
if ( _elementJustOpened ) { SealElementIfJustOpened();
SealElement();
}
if ( cdata ) { if ( cdata ) {
Print( "<![CDATA[" ); Print( "<![CDATA[" );
Print( "%s", text ); Print( "%s", text );
@ -2221,9 +2220,7 @@ void XMLPrinter::PushText( double value )
void XMLPrinter::PushComment( const char* comment ) void XMLPrinter::PushComment( const char* comment )
{ {
if ( _elementJustOpened ) { SealElementIfJustOpened();
SealElement();
}
if ( _textDepth < 0 && !_firstElement && !_compactMode) { if ( _textDepth < 0 && !_firstElement && !_compactMode) {
Print( "\n" ); Print( "\n" );
PrintSpace( _depth ); PrintSpace( _depth );
@ -2235,9 +2232,7 @@ void XMLPrinter::PushComment( const char* comment )
void XMLPrinter::PushDeclaration( const char* value ) void XMLPrinter::PushDeclaration( const char* value )
{ {
if ( _elementJustOpened ) { SealElementIfJustOpened();
SealElement();
}
if ( _textDepth < 0 && !_firstElement && !_compactMode) { if ( _textDepth < 0 && !_firstElement && !_compactMode) {
Print( "\n" ); Print( "\n" );
PrintSpace( _depth ); PrintSpace( _depth );
@ -2249,9 +2244,7 @@ void XMLPrinter::PushDeclaration( const char* value )
void XMLPrinter::PushUnknown( const char* value ) void XMLPrinter::PushUnknown( const char* value )
{ {
if ( _elementJustOpened ) { SealElementIfJustOpened();
SealElement();
}
if ( _textDepth < 0 && !_firstElement && !_compactMode) { if ( _textDepth < 0 && !_firstElement && !_compactMode) {
Print( "\n" ); Print( "\n" );
PrintSpace( _depth ); PrintSpace( _depth );

View File

@ -563,10 +563,10 @@ public:
} }
inline static bool StringEqual( const char* p, const char* q, int nChar=INT_MAX ) { inline static bool StringEqual( const char* p, const char* q, int nChar=INT_MAX ) {
int n = 0;
if ( p == q ) { if ( p == q ) {
return true; return true;
} }
int n = 0;
while( *p && *q && *p == *q && n<nChar ) { while( *p && *q && *p == *q && n<nChar ) {
++p; ++p;
++q; ++q;
@ -2069,7 +2069,7 @@ protected:
virtual void PrintSpace( int depth ); virtual void PrintSpace( int depth );
void Print( const char* format, ... ); void Print( const char* format, ... );
void SealElement(); void SealElementIfJustOpened();
bool _elementJustOpened; bool _elementJustOpened;
DynArray< const char*, 10 > _stack; DynArray< const char*, 10 > _stack;