Explorar el Código

Merge pull request #142 from mcclure/xmlbreak

TinyXML fixes: linebreaks, license junk
Ivan Safrin hace 13 años
padre
commit
624b29b603
Se han modificado 1 ficheros con 10 adiciones y 6 borrados
  1. 10 6
      Core/Contents/Source/tinyxml.cpp

+ 10 - 6
Core/Contents/Source/tinyxml.cpp

@@ -31,6 +31,10 @@ distribution.
 
 
 #include "tinyxml.h"
 #include "tinyxml.h"
 
 
+// This document has been altered from the original in the following ways:
+// * It opens files through the Polycode OSFile abstraction rather than directly.
+// * It now uses Windows linebreaks consistently regardless of platform.
+#define NEWLINE "\r\n"
 
 
 bool TiXmlBase::condenseWhiteSpace = true;
 bool TiXmlBase::condenseWhiteSpace = true;
 
 
@@ -800,11 +804,11 @@ void TiXmlElement::Print( FILE* cfile, int depth ) const
 		{
 		{
 			if ( !node->ToText() )
 			if ( !node->ToText() )
 			{
 			{
-				fprintf( cfile, "\n" );
+				fprintf( cfile, NEWLINE );
 			}
 			}
 			node->Print( cfile, depth+1 );
 			node->Print( cfile, depth+1 );
 		}
 		}
-		fprintf( cfile, "\n" );
+		fprintf( cfile, NEWLINE );
 		for( i=0; i<depth; ++i ) {
 		for( i=0; i<depth; ++i ) {
 			fprintf( cfile, "    " );
 			fprintf( cfile, "    " );
 		}
 		}
@@ -1083,7 +1087,7 @@ bool TiXmlDocument::LoadFile( OSFILE* file, TiXmlEncoding encoding )
 bool TiXmlDocument::SaveFile( const char * filename ) const
 bool TiXmlDocument::SaveFile( const char * filename ) const
 {
 {
 	// The old c stuff lives on...
 	// The old c stuff lives on...
-	OSFILE* fp = TiXmlFOpen( filename, "w" );
+	OSFILE* fp = TiXmlFOpen( filename, "wb" );
 	if ( fp )
 	if ( fp )
 	{
 	{
 		bool result = SaveFile( fp->file );
 		bool result = SaveFile( fp->file );
@@ -1147,7 +1151,7 @@ void TiXmlDocument::Print( FILE* cfile, int depth ) const
 	for ( const TiXmlNode* node=FirstChild(); node; node=node->NextSibling() )
 	for ( const TiXmlNode* node=FirstChild(); node; node=node->NextSibling() )
 	{
 	{
 		node->Print( cfile, depth );
 		node->Print( cfile, depth );
-		fprintf( cfile, "\n" );
+		fprintf( cfile, NEWLINE );
 	}
 	}
 }
 }
 
 
@@ -1333,11 +1337,11 @@ void TiXmlText::Print( FILE* cfile, int depth ) const
 	if ( cdata )
 	if ( cdata )
 	{
 	{
 		int i;
 		int i;
-		fprintf( cfile, "\n" );
+		fprintf( cfile, NEWLINE );
 		for ( i=0; i<depth; i++ ) {
 		for ( i=0; i<depth; i++ ) {
 			fprintf( cfile, "    " );
 			fprintf( cfile, "    " );
 		}
 		}
-		fprintf( cfile, "<![CDATA[%s]]>\n", value.c_str() );	// unformatted output
+		fprintf( cfile, "<![CDATA[%s]]>" NEWLINE, value.c_str() );	// unformatted output
 	}
 	}
 	else
 	else
 	{
 	{