Test on gcc. Fix warning. Fix uneeded params. Up VS debug to level 4 and fix warnings.

This commit is contained in:
Lee Thomason (grinliz) 2012-02-25 21:30:18 -08:00
parent 647eed32ef
commit 9b093cc1ee
4 changed files with 24 additions and 21 deletions

View File

@ -27,10 +27,9 @@ distribution.
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <ctype.h> #include <ctype.h>
#include <new.h> #include <new>
#include <stdarg.h> #include <stdarg.h>
//#pragma warning ( disable : 4291 )
using namespace tinyxml2; using namespace tinyxml2;
@ -403,8 +402,11 @@ char* XMLDocument::Identify( char* p, XMLNode** node )
static const int cdataHeaderLen = 9; static const int cdataHeaderLen = 9;
static const int elementHeaderLen = 1; static const int elementHeaderLen = 1;
#pragma warning ( push )
#pragma warning ( disable : 4127 )
TIXMLASSERT( sizeof( XMLComment ) == sizeof( XMLUnknown ) ); // use same memory pool TIXMLASSERT( sizeof( XMLComment ) == sizeof( XMLUnknown ) ); // use same memory pool
TIXMLASSERT( sizeof( XMLComment ) == sizeof( XMLDeclaration ) ); // use same memory pool TIXMLASSERT( sizeof( XMLComment ) == sizeof( XMLDeclaration ) ); // use same memory pool
#pragma warning (pop)
if ( XMLUtil::StringEqual( p, xmlHeader, xmlHeaderLen ) ) { if ( XMLUtil::StringEqual( p, xmlHeader, xmlHeaderLen ) ) {
returnNode = new (commentPool.Alloc()) XMLDeclaration( this ); returnNode = new (commentPool.Alloc()) XMLDeclaration( this );
@ -985,7 +987,7 @@ XMLAttribute* XMLElement::FindOrCreateAttribute( const char* name )
{ {
XMLAttribute* attrib = FindAttribute( name ); XMLAttribute* attrib = FindAttribute( name );
if ( !attrib ) { if ( !attrib ) {
attrib = new (document->attributePool.Alloc() ) XMLAttribute( this ); attrib = new (document->attributePool.Alloc() ) XMLAttribute();
attrib->memPool = &document->attributePool; attrib->memPool = &document->attributePool;
LinkAttribute( attrib ); LinkAttribute( attrib );
attrib->SetName( name ); attrib->SetName( name );
@ -1041,7 +1043,7 @@ char* XMLElement::ParseAttributes( char* p )
// attribute. // attribute.
if ( XMLUtil::IsAlpha( *p ) ) { if ( XMLUtil::IsAlpha( *p ) ) {
XMLAttribute* attrib = new (document->attributePool.Alloc() ) XMLAttribute( this ); XMLAttribute* attrib = new (document->attributePool.Alloc() ) XMLAttribute();
attrib->memPool = &document->attributePool; attrib->memPool = &document->attributePool;
p = attrib->ParseDeep( p ); p = attrib->ParseDeep( p );
@ -1080,7 +1082,6 @@ char* XMLElement::ParseDeep( char* p, StrPair* strPair )
// Read the element name. // Read the element name.
p = XMLUtil::SkipWhiteSpace( p ); p = XMLUtil::SkipWhiteSpace( p );
if ( !p ) return 0; if ( !p ) return 0;
const char* start = p;
// The closing element is the </element> form. It is // The closing element is the </element> form. It is
// parsed just like a regular element then deleted from // parsed just like a regular element then deleted from
@ -1093,7 +1094,6 @@ char* XMLElement::ParseDeep( char* p, StrPair* strPair )
p = value.ParseName( p ); p = value.ParseName( p );
if ( value.Empty() ) return 0; if ( value.Empty() ) return 0;
bool elementClosed=false;
p = ParseAttributes( p ); p = ParseAttributes( p );
if ( !p || !*p || closingType ) if ( !p || !*p || closingType )
return p; return p;
@ -1318,12 +1318,12 @@ XMLPrinter::XMLPrinter( FILE* file ) :
for( int i=0; i<NUM_ENTITIES; ++i ) { for( int i=0; i<NUM_ENTITIES; ++i ) {
TIXMLASSERT( entities[i].value < ENTITY_RANGE ); TIXMLASSERT( entities[i].value < ENTITY_RANGE );
if ( entities[i].value < ENTITY_RANGE ) { if ( entities[i].value < ENTITY_RANGE ) {
entityFlag[ entities[i].value ] = true; entityFlag[ (int)entities[i].value ] = true;
} }
} }
restrictedEntityFlag['&'] = true; restrictedEntityFlag[(int)'&'] = true;
restrictedEntityFlag['<'] = true; restrictedEntityFlag[(int)'<'] = true;
restrictedEntityFlag['>'] = true; // not required, but consistency is nice restrictedEntityFlag[(int)'>'] = true; // not required, but consistency is nice
buffer.Push( 0 ); buffer.Push( 0 );
} }
@ -1354,7 +1354,7 @@ void XMLPrinter::Print( const char* format, ... )
#else #else
int len = vsnprintf( 0, 0, format, va ); int len = vsnprintf( 0, 0, format, va );
char* p = buffer.PushArr( len ) - 1; char* p = buffer.PushArr( len ) - 1;
vsprintf_s( p, len+1, format, va ); vsnprintf( p, len+1, format, va );
#endif #endif
} }
va_end( va ); va_end( va );
@ -1556,7 +1556,7 @@ bool XMLPrinter::VisitEnter( const XMLElement& element, const XMLAttribute* attr
} }
bool XMLPrinter::VisitExit( const XMLElement& element ) bool XMLPrinter::VisitExit( const XMLElement& )
{ {
CloseElement(); CloseElement();
return true; return true;

View File

@ -33,6 +33,9 @@ distribution.
/* TODO: create main page description. /* TODO: create main page description.
TODO: add 'lastAttribute' for faster parsing. TODO: add 'lastAttribute' for faster parsing.
*/ */
/*
gcc: g++ -Wall tinyxml2.cpp xmltest.cpp -o gccxmltest.exe
*/
#if defined( _DEBUG ) || defined( DEBUG ) || defined (__DEBUG__) #if defined( _DEBUG ) || defined( DEBUG ) || defined (__DEBUG__)
#ifndef DEBUG #ifndef DEBUG
@ -720,15 +723,15 @@ public:
If the value isn't an integer, 0 will be returned. There is no error checking; If the value isn't an integer, 0 will be returned. There is no error checking;
use QueryIntAttribute() if you need error checking. use QueryIntAttribute() if you need error checking.
*/ */
int IntAttribute( const char* name ) const { int i=0; QueryIntAttribute( &i ); return i; } int IntAttribute() const { int i=0; QueryIntAttribute( &i ); return i; }
/// Query as an unsigned integer. See IntAttribute() /// Query as an unsigned integer. See IntAttribute()
unsigned UnsignedAttribute( const char* name ) const{ unsigned i=0; QueryUnsignedAttribute( &i ); return i; } unsigned UnsignedAttribute() const { unsigned i=0; QueryUnsignedAttribute( &i ); return i; }
/// Query as a boolean. See IntAttribute() /// Query as a boolean. See IntAttribute()
bool BoolAttribute( const char* name ) const { bool b=false; QueryBoolAttribute( &b ); return b; } bool BoolAttribute() const { bool b=false; QueryBoolAttribute( &b ); return b; }
/// Query as a double. See IntAttribute() /// Query as a double. See IntAttribute()
double DoubleAttribute( const char* name ) const { double d=0; QueryDoubleAttribute( &d ); return d; } double DoubleAttribute() const { double d=0; QueryDoubleAttribute( &d ); return d; }
/// Query as a float. See IntAttribute() /// Query as a float. See IntAttribute()
float FloatAttribute( const char* name ) const { float f=0; QueryFloatAttribute( &f ); return f; } float FloatAttribute() const { float f=0; QueryFloatAttribute( &f ); return f; }
/** QueryIntAttribute interprets the attribute as an integer, and returns the value /** QueryIntAttribute interprets the attribute as an integer, and returns the value
in the provided paremeter. The function will return XML_NO_ERROR on success, in the provided paremeter. The function will return XML_NO_ERROR on success,
@ -760,7 +763,7 @@ public:
private: private:
enum { BUF_SIZE = 200 }; enum { BUF_SIZE = 200 };
XMLAttribute( XMLElement* element ) : next( 0 ) {} XMLAttribute() : next( 0 ) {}
virtual ~XMLAttribute() {} virtual ~XMLAttribute() {}
XMLAttribute( const XMLAttribute& ); // not supported XMLAttribute( const XMLAttribute& ); // not supported
void operator=( const XMLAttribute& ); // not supported void operator=( const XMLAttribute& ); // not supported

View File

@ -47,7 +47,7 @@
<ClCompile> <ClCompile>
<PrecompiledHeader> <PrecompiledHeader>
</PrecompiledHeader> </PrecompiledHeader>
<WarningLevel>Level3</WarningLevel> <WarningLevel>Level4</WarningLevel>
<Optimization>Disabled</Optimization> <Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile> </ClCompile>

View File

@ -69,7 +69,7 @@ void NullLineEndings( char* p )
} }
int main( int argc, const char* argv ) int main( int /*argc*/, const char* /*argv*/ )
{ {
#if defined( _MSC_VER ) #if defined( _MSC_VER )
_CrtMemCheckpoint( &startMemState ); _CrtMemCheckpoint( &startMemState );