Revert "Hide depend headers better, upgraded tinyxml"

This reverts commit 54a580ac68.

Conflicts:

	CMakeLists.txt
	library/CMakeLists.txt

Signed-off-by: Petr Mrázek <peterix@gmail.com>
develop
Petr Mrázek 2011-03-31 01:12:50 +02:00
parent e61a907da1
commit d6bd4d47fb
6 changed files with 279 additions and 223 deletions

@ -161,7 +161,7 @@ IF( CMAKE_SIZEOF_VOID_P MATCHES 8 )
ENDIF() ENDIF()
ADD_DEFINITIONS(-DMEMXML_DATA_PATH="${MEMXML_DATA_PATH}") ADD_DEFINITIONS(-DMEMXML_DATA_PATH="${MEMXML_DATA_PATH}")
ADD_DEFINITIONS(-DBUILD_DFHACK_LIB -DTIXML_USE_STL) ADD_DEFINITIONS(-DBUILD_DFHACK_LIB)
IF(UNIX) IF(UNIX)
add_definitions(-DLINUX_BUILD) add_definitions(-DLINUX_BUILD)

@ -263,7 +263,7 @@ void VersionInfoFactory::ParseOffsets(TiXmlElement * parent, VersionInfo* target
} }
// skip non-elements // skip non-elements
if (currentElem->Type() != TiXmlNode::TINYXML_ELEMENT) if (currentElem->Type() != TiXmlNode::ELEMENT)
{ {
groupTriple & gp = breadcrumbs.back(); groupTriple & gp = breadcrumbs.back();
gp.first = gp.first->NextSiblingElement(); gp.first = gp.first->NextSiblingElement();

@ -31,7 +31,6 @@ distribution.
#include "tinyxml.h" #include "tinyxml.h"
FILE* TiXmlFOpen( const char* filename, const char* mode );
bool TiXmlBase::condenseWhiteSpace = true; bool TiXmlBase::condenseWhiteSpace = true;
@ -162,7 +161,6 @@ void TiXmlNode::CopyTo( TiXmlNode* target ) const
{ {
target->SetValue (value.c_str() ); target->SetValue (value.c_str() );
target->userData = userData; target->userData = userData;
target->location = location;
} }
@ -188,7 +186,7 @@ TiXmlNode* TiXmlNode::LinkEndChild( TiXmlNode* node )
assert( node->parent == 0 || node->parent == this ); assert( node->parent == 0 || node->parent == this );
assert( node->GetDocument() == 0 || node->GetDocument() == this->GetDocument() ); assert( node->GetDocument() == 0 || node->GetDocument() == this->GetDocument() );
if ( node->Type() == TiXmlNode::TINYXML_DOCUMENT ) if ( node->Type() == TiXmlNode::DOCUMENT )
{ {
delete node; delete node;
if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN );
@ -212,7 +210,7 @@ TiXmlNode* TiXmlNode::LinkEndChild( TiXmlNode* node )
TiXmlNode* TiXmlNode::InsertEndChild( const TiXmlNode& addThis ) TiXmlNode* TiXmlNode::InsertEndChild( const TiXmlNode& addThis )
{ {
if ( addThis.Type() == TiXmlNode::TINYXML_DOCUMENT ) if ( addThis.Type() == TiXmlNode::DOCUMENT )
{ {
if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN );
return 0; return 0;
@ -230,7 +228,7 @@ TiXmlNode* TiXmlNode::InsertBeforeChild( TiXmlNode* beforeThis, const TiXmlNode&
if ( !beforeThis || beforeThis->parent != this ) { if ( !beforeThis || beforeThis->parent != this ) {
return 0; return 0;
} }
if ( addThis.Type() == TiXmlNode::TINYXML_DOCUMENT ) if ( addThis.Type() == TiXmlNode::DOCUMENT )
{ {
if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN );
return 0; return 0;
@ -262,7 +260,7 @@ TiXmlNode* TiXmlNode::InsertAfterChild( TiXmlNode* afterThis, const TiXmlNode& a
if ( !afterThis || afterThis->parent != this ) { if ( !afterThis || afterThis->parent != this ) {
return 0; return 0;
} }
if ( addThis.Type() == TiXmlNode::TINYXML_DOCUMENT ) if ( addThis.Type() == TiXmlNode::DOCUMENT )
{ {
if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN );
return 0; return 0;
@ -291,20 +289,9 @@ TiXmlNode* TiXmlNode::InsertAfterChild( TiXmlNode* afterThis, const TiXmlNode& a
TiXmlNode* TiXmlNode::ReplaceChild( TiXmlNode* replaceThis, const TiXmlNode& withThis ) TiXmlNode* TiXmlNode::ReplaceChild( TiXmlNode* replaceThis, const TiXmlNode& withThis )
{ {
if ( !replaceThis )
return 0;
if ( replaceThis->parent != this ) if ( replaceThis->parent != this )
return 0; return 0;
if ( withThis.ToDocument() ) {
// A document can never be a child. Thanks to Noam.
TiXmlDocument* document = GetDocument();
if ( document )
document->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN );
return 0;
}
TiXmlNode* node = withThis.Clone(); TiXmlNode* node = withThis.Clone();
if ( !node ) if ( !node )
return 0; return 0;
@ -330,10 +317,6 @@ TiXmlNode* TiXmlNode::ReplaceChild( TiXmlNode* replaceThis, const TiXmlNode& wit
bool TiXmlNode::RemoveChild( TiXmlNode* removeThis ) bool TiXmlNode::RemoveChild( TiXmlNode* removeThis )
{ {
if ( !removeThis ) {
return false;
}
if ( removeThis->parent != this ) if ( removeThis->parent != this )
{ {
assert( 0 ); assert( 0 );
@ -519,7 +502,7 @@ const TiXmlDocument* TiXmlNode::GetDocument() const
TiXmlElement::TiXmlElement (const char * _value) TiXmlElement::TiXmlElement (const char * _value)
: TiXmlNode( TiXmlNode::TINYXML_ELEMENT ) : TiXmlNode( TiXmlNode::ELEMENT )
{ {
firstChild = lastChild = 0; firstChild = lastChild = 0;
value = _value; value = _value;
@ -528,7 +511,7 @@ TiXmlElement::TiXmlElement (const char * _value)
#ifdef TIXML_USE_STL #ifdef TIXML_USE_STL
TiXmlElement::TiXmlElement( const std::string& _value ) TiXmlElement::TiXmlElement( const std::string& _value )
: TiXmlNode( TiXmlNode::TINYXML_ELEMENT ) : TiXmlNode( TiXmlNode::ELEMENT )
{ {
firstChild = lastChild = 0; firstChild = lastChild = 0;
value = _value; value = _value;
@ -537,7 +520,7 @@ TiXmlElement::TiXmlElement( const std::string& _value )
TiXmlElement::TiXmlElement( const TiXmlElement& copy) TiXmlElement::TiXmlElement( const TiXmlElement& copy)
: TiXmlNode( TiXmlNode::TINYXML_ELEMENT ) : TiXmlNode( TiXmlNode::ELEMENT )
{ {
firstChild = lastChild = 0; firstChild = lastChild = 0;
copy.CopyTo( this ); copy.CopyTo( this );
@ -581,9 +564,9 @@ const char* TiXmlElement::Attribute( const char* name ) const
#ifdef TIXML_USE_STL #ifdef TIXML_USE_STL
const std::string* TiXmlElement::Attribute( const std::string& name ) const const std::string* TiXmlElement::Attribute( const std::string& name ) const
{ {
const TiXmlAttribute* attrib = attributeSet.Find( name ); const TiXmlAttribute* node = attributeSet.Find( name );
if ( attrib ) if ( node )
return &attrib->ValueStr(); return &node->ValueStr();
return 0; return 0;
} }
#endif #endif
@ -591,163 +574,195 @@ const std::string* TiXmlElement::Attribute( const std::string& name ) const
const char* TiXmlElement::Attribute( const char* name, int* i ) const const char* TiXmlElement::Attribute( const char* name, int* i ) const
{ {
const TiXmlAttribute* attrib = attributeSet.Find( name ); const char* s = Attribute( name );
const char* result = 0; if ( i )
{
if ( attrib ) { if ( s ) {
result = attrib->Value(); *i = atoi( s );
if ( i ) {
attrib->QueryIntValue( i );
} }
else {
*i = 0;
} }
return result; }
return s;
} }
#ifdef TIXML_USE_STL #ifdef TIXML_USE_STL
const std::string* TiXmlElement::Attribute( const std::string& name, int* i ) const const std::string* TiXmlElement::Attribute( const std::string& name, int* i ) const
{ {
const TiXmlAttribute* attrib = attributeSet.Find( name ); const std::string* s = Attribute( name );
const std::string* result = 0; if ( i )
{
if ( attrib ) { if ( s ) {
result = &attrib->ValueStr(); *i = atoi( s->c_str() );
if ( i ) {
attrib->QueryIntValue( i );
} }
else {
*i = 0;
} }
return result; }
return s;
} }
#endif #endif
const char* TiXmlElement::Attribute( const char* name, double* d ) const const char* TiXmlElement::Attribute( const char* name, double* d ) const
{ {
const TiXmlAttribute* attrib = attributeSet.Find( name ); const char* s = Attribute( name );
const char* result = 0; if ( d )
{
if ( attrib ) { if ( s ) {
result = attrib->Value(); *d = atof( s );
if ( d ) {
attrib->QueryDoubleValue( d );
} }
else {
*d = 0;
} }
return result; }
return s;
} }
#ifdef TIXML_USE_STL #ifdef TIXML_USE_STL
const std::string* TiXmlElement::Attribute( const std::string& name, double* d ) const const std::string* TiXmlElement::Attribute( const std::string& name, double* d ) const
{ {
const TiXmlAttribute* attrib = attributeSet.Find( name ); const std::string* s = Attribute( name );
const std::string* result = 0; if ( d )
{
if ( attrib ) { if ( s ) {
result = &attrib->ValueStr(); *d = atof( s->c_str() );
if ( d ) { }
attrib->QueryDoubleValue( d ); else {
*d = 0;
} }
} }
return result; return s;
} }
#endif #endif
int TiXmlElement::QueryIntAttribute( const char* name, int* ival ) const int TiXmlElement::QueryIntAttribute( const char* name, int* ival ) const
{ {
const TiXmlAttribute* attrib = attributeSet.Find( name ); const TiXmlAttribute* node = attributeSet.Find( name );
if ( !attrib ) if ( !node )
return TIXML_NO_ATTRIBUTE; return TIXML_NO_ATTRIBUTE;
return attrib->QueryIntValue( ival ); return node->QueryIntValue( ival );
} }
#ifdef TIXML_USE_STL #ifdef TIXML_USE_STL
int TiXmlElement::QueryIntAttribute( const std::string& name, int* ival ) const int TiXmlElement::QueryIntAttribute( const std::string& name, int* ival ) const
{ {
const TiXmlAttribute* attrib = attributeSet.Find( name ); const TiXmlAttribute* node = attributeSet.Find( name );
if ( !attrib ) if ( !node )
return TIXML_NO_ATTRIBUTE; return TIXML_NO_ATTRIBUTE;
return attrib->QueryIntValue( ival ); return node->QueryIntValue( ival );
} }
#endif #endif
int TiXmlElement::QueryDoubleAttribute( const char* name, double* dval ) const int TiXmlElement::QueryDoubleAttribute( const char* name, double* dval ) const
{ {
const TiXmlAttribute* attrib = attributeSet.Find( name ); const TiXmlAttribute* node = attributeSet.Find( name );
if ( !attrib ) if ( !node )
return TIXML_NO_ATTRIBUTE; return TIXML_NO_ATTRIBUTE;
return attrib->QueryDoubleValue( dval ); return node->QueryDoubleValue( dval );
} }
#ifdef TIXML_USE_STL #ifdef TIXML_USE_STL
int TiXmlElement::QueryDoubleAttribute( const std::string& name, double* dval ) const int TiXmlElement::QueryDoubleAttribute( const std::string& name, double* dval ) const
{ {
const TiXmlAttribute* attrib = attributeSet.Find( name ); const TiXmlAttribute* node = attributeSet.Find( name );
if ( !attrib ) if ( !node )
return TIXML_NO_ATTRIBUTE; return TIXML_NO_ATTRIBUTE;
return attrib->QueryDoubleValue( dval ); return node->QueryDoubleValue( dval );
} }
#endif #endif
void TiXmlElement::SetAttribute( const char * name, int val ) void TiXmlElement::SetAttribute( const char * name, int val )
{ {
TiXmlAttribute* attrib = attributeSet.FindOrCreate( name ); char buf[64];
if ( attrib ) { #if defined(TIXML_SNPRINTF)
attrib->SetIntValue( val ); TIXML_SNPRINTF( buf, sizeof(buf), "%d", val );
} #else
sprintf( buf, "%d", val );
#endif
SetAttribute( name, buf );
} }
#ifdef TIXML_USE_STL #ifdef TIXML_USE_STL
void TiXmlElement::SetAttribute( const std::string& name, int val ) void TiXmlElement::SetAttribute( const std::string& name, int val )
{ {
TiXmlAttribute* attrib = attributeSet.FindOrCreate( name ); std::ostringstream oss;
if ( attrib ) { oss << val;
attrib->SetIntValue( val ); SetAttribute( name, oss.str() );
}
} }
#endif #endif
void TiXmlElement::SetDoubleAttribute( const char * name, double val ) void TiXmlElement::SetDoubleAttribute( const char * name, double val )
{ {
TiXmlAttribute* attrib = attributeSet.FindOrCreate( name ); char buf[256];
if ( attrib ) { #if defined(TIXML_SNPRINTF)
attrib->SetDoubleValue( val ); TIXML_SNPRINTF( buf, sizeof(buf), "%f", val );
} #else
sprintf( buf, "%f", val );
#endif
SetAttribute( name, buf );
} }
#ifdef TIXML_USE_STL void TiXmlElement::SetAttribute( const char * cname, const char * cvalue )
void TiXmlElement::SetDoubleAttribute( const std::string& name, double val )
{ {
TiXmlAttribute* attrib = attributeSet.FindOrCreate( name ); #ifdef TIXML_USE_STL
if ( attrib ) { TIXML_STRING _name( cname );
attrib->SetDoubleValue( val ); TIXML_STRING _value( cvalue );
} #else
} const char* _name = cname;
#endif const char* _value = cvalue;
#endif
TiXmlAttribute* node = attributeSet.Find( _name );
if ( node )
{
node->SetValue( _value );
return;
}
void TiXmlElement::SetAttribute( const char * cname, const char * cvalue ) TiXmlAttribute* attrib = new TiXmlAttribute( cname, cvalue );
{ if ( attrib )
TiXmlAttribute* attrib = attributeSet.FindOrCreate( cname ); {
if ( attrib ) { attributeSet.Add( attrib );
attrib->SetValue( cvalue ); }
else
{
TiXmlDocument* document = GetDocument();
if ( document ) document->SetError( TIXML_ERROR_OUT_OF_MEMORY, 0, 0, TIXML_ENCODING_UNKNOWN );
} }
} }
#ifdef TIXML_USE_STL #ifdef TIXML_USE_STL
void TiXmlElement::SetAttribute( const std::string& _name, const std::string& _value ) void TiXmlElement::SetAttribute( const std::string& name, const std::string& _value )
{ {
TiXmlAttribute* attrib = attributeSet.FindOrCreate( _name ); TiXmlAttribute* node = attributeSet.Find( name );
if ( attrib ) { if ( node )
attrib->SetValue( _value ); {
node->SetValue( _value );
return;
}
TiXmlAttribute* attrib = new TiXmlAttribute( name, _value );
if ( attrib )
{
attributeSet.Add( attrib );
}
else
{
TiXmlDocument* document = GetDocument();
if ( document ) document->SetError( TIXML_ERROR_OUT_OF_MEMORY, 0, 0, TIXML_ENCODING_UNKNOWN );
} }
} }
#endif #endif
@ -866,14 +881,14 @@ const char* TiXmlElement::GetText() const
} }
TiXmlDocument::TiXmlDocument() : TiXmlNode( TiXmlNode::TINYXML_DOCUMENT ) TiXmlDocument::TiXmlDocument() : TiXmlNode( TiXmlNode::DOCUMENT )
{ {
tabsize = 4; tabsize = 4;
useMicrosoftBOM = false; useMicrosoftBOM = false;
ClearError(); ClearError();
} }
TiXmlDocument::TiXmlDocument( const char * documentName ) : TiXmlNode( TiXmlNode::TINYXML_DOCUMENT ) TiXmlDocument::TiXmlDocument( const char * documentName ) : TiXmlNode( TiXmlNode::DOCUMENT )
{ {
tabsize = 4; tabsize = 4;
useMicrosoftBOM = false; useMicrosoftBOM = false;
@ -883,7 +898,7 @@ TiXmlDocument::TiXmlDocument( const char * documentName ) : TiXmlNode( TiXmlNode
#ifdef TIXML_USE_STL #ifdef TIXML_USE_STL
TiXmlDocument::TiXmlDocument( const std::string& documentName ) : TiXmlNode( TiXmlNode::TINYXML_DOCUMENT ) TiXmlDocument::TiXmlDocument( const std::string& documentName ) : TiXmlNode( TiXmlNode::DOCUMENT )
{ {
tabsize = 4; tabsize = 4;
useMicrosoftBOM = false; useMicrosoftBOM = false;
@ -893,7 +908,7 @@ TiXmlDocument::TiXmlDocument( const std::string& documentName ) : TiXmlNode( TiX
#endif #endif
TiXmlDocument::TiXmlDocument( const TiXmlDocument& copy ) : TiXmlNode( TiXmlNode::TINYXML_DOCUMENT ) TiXmlDocument::TiXmlDocument( const TiXmlDocument& copy ) : TiXmlNode( TiXmlNode::DOCUMENT )
{ {
copy.CopyTo( this ); copy.CopyTo( this );
} }
@ -908,17 +923,34 @@ void TiXmlDocument::operator=( const TiXmlDocument& copy )
bool TiXmlDocument::LoadFile( TiXmlEncoding encoding ) bool TiXmlDocument::LoadFile( TiXmlEncoding encoding )
{ {
// See STL_STRING_BUG below.
//StringToBuffer buf( value );
return LoadFile( Value(), encoding ); return LoadFile( Value(), encoding );
} }
bool TiXmlDocument::SaveFile() const bool TiXmlDocument::SaveFile() const
{ {
// See STL_STRING_BUG below.
// StringToBuffer buf( value );
//
// if ( buf.buffer && SaveFile( buf.buffer ) )
// return true;
//
// return false;
return SaveFile( Value() ); return SaveFile( Value() );
} }
bool TiXmlDocument::LoadFile( const char* _filename, TiXmlEncoding encoding ) bool TiXmlDocument::LoadFile( const char* _filename, TiXmlEncoding encoding )
{ {
// There was a really terrifying little bug here. The code:
// value = filename
// in the STL case, cause the assignment method of the std::string to
// be called. What is strange, is that the std::string had the same
// address as it's c_str() method, and so bad things happen. Looks
// like a bug in the Microsoft STL implementation.
// Add an extra string to avoid the crash.
TIXML_STRING filename( _filename ); TIXML_STRING filename( _filename );
value = filename; value = filename;
@ -963,6 +995,11 @@ bool TiXmlDocument::LoadFile( FILE* file, TiXmlEncoding encoding )
return false; return false;
} }
// If we have a file, assume it is all one big XML file, and read it in.
// The document parser may decide the document ends sooner than the entire file, however.
TIXML_STRING data;
data.reserve( length );
// Subtle bug here. TinyXml did use fgets. But from the XML spec: // Subtle bug here. TinyXml did use fgets. But from the XML spec:
// 2.11 End-of-Line Handling // 2.11 End-of-Line Handling
// <snip> // <snip>
@ -993,46 +1030,58 @@ bool TiXmlDocument::LoadFile( FILE* file, TiXmlEncoding encoding )
return false; return false;
} }
// Process the buffer in place to normalize new lines. (See comment above.) const char* lastPos = buf;
// Copies from the 'p' to 'q' pointer, where p can advance faster if const char* p = buf;
// a newline-carriage return is hit.
//
// Wikipedia:
// Systems based on ASCII or a compatible character set use either LF (Line feed, '\n', 0x0A, 10 in decimal) or
// CR (Carriage return, '\r', 0x0D, 13 in decimal) individually, or CR followed by LF (CR+LF, 0x0D 0x0A)...
// * LF: Multics, Unix and Unix-like systems (GNU/Linux, AIX, Xenix, Mac OS X, FreeBSD, etc.), BeOS, Amiga, RISC OS, and others
// * CR+LF: DEC RT-11 and most other early non-Unix, non-IBM OSes, CP/M, MP/M, DOS, OS/2, Microsoft Windows, Symbian OS
// * CR: Commodore 8-bit machines, Apple II family, Mac OS up to version 9 and OS-9
const char* p = buf; // the read head
char* q = buf; // the write head
const char CR = 0x0d;
const char LF = 0x0a;
buf[length] = 0; buf[length] = 0;
while( *p ) { while( *p ) {
assert( p < (buf+length) ); assert( p < (buf+length) );
assert( q <= (buf+length) ); if ( *p == 0xa ) {
assert( q <= p ); // Newline character. No special rules for this. Append all the characters
// since the last string, and include the newline.
if ( *p == CR ) { data.append( lastPos, (p-lastPos+1) ); // append, include the newline
*q++ = LF; ++p; // move past the newline
p++; lastPos = p; // and point to the new buffer (may be 0)
if ( *p == LF ) { // check for CR+LF (and skip LF) assert( p <= (buf+length) );
p++; }
else if ( *p == 0xd ) {
// Carriage return. Append what we have so far, then
// handle moving forward in the buffer.
if ( (p-lastPos) > 0 ) {
data.append( lastPos, p-lastPos ); // do not add the CR
}
data += (char)0xa; // a proper newline
if ( *(p+1) == 0xa ) {
// Carriage return - new line sequence
p += 2;
lastPos = p;
assert( p <= (buf+length) );
}
else {
// it was followed by something else...that is presumably characters again.
++p;
lastPos = p;
assert( p <= (buf+length) );
} }
} }
else { else {
*q++ = *p++; ++p;
}
} }
// Handle any left over characters.
if ( p-lastPos ) {
data.append( lastPos, p-lastPos );
} }
assert( q <= (buf+length) ); delete [] buf;
*q = 0; buf = 0;
Parse( buf, 0, encoding ); Parse( data.c_str(), 0, encoding );
delete [] buf; if ( Error() )
return !Error(); return false;
else
return true;
} }
@ -1217,9 +1266,9 @@ void TiXmlAttribute::SetDoubleValue( double _value )
{ {
char buf [256]; char buf [256];
#if defined(TIXML_SNPRINTF) #if defined(TIXML_SNPRINTF)
TIXML_SNPRINTF( buf, sizeof(buf), "%g", _value); TIXML_SNPRINTF( buf, sizeof(buf), "%lf", _value);
#else #else
sprintf (buf, "%g", _value); sprintf (buf, "%lf", _value);
#endif #endif
SetValue (buf); SetValue (buf);
} }
@ -1235,7 +1284,7 @@ double TiXmlAttribute::DoubleValue() const
} }
TiXmlComment::TiXmlComment( const TiXmlComment& copy ) : TiXmlNode( TiXmlNode::TINYXML_COMMENT ) TiXmlComment::TiXmlComment( const TiXmlComment& copy ) : TiXmlNode( TiXmlNode::COMMENT )
{ {
copy.CopyTo( this ); copy.CopyTo( this );
} }
@ -1333,7 +1382,7 @@ TiXmlNode* TiXmlText::Clone() const
TiXmlDeclaration::TiXmlDeclaration( const char * _version, TiXmlDeclaration::TiXmlDeclaration( const char * _version,
const char * _encoding, const char * _encoding,
const char * _standalone ) const char * _standalone )
: TiXmlNode( TiXmlNode::TINYXML_DECLARATION ) : TiXmlNode( TiXmlNode::DECLARATION )
{ {
version = _version; version = _version;
encoding = _encoding; encoding = _encoding;
@ -1345,7 +1394,7 @@ TiXmlDeclaration::TiXmlDeclaration( const char * _version,
TiXmlDeclaration::TiXmlDeclaration( const std::string& _version, TiXmlDeclaration::TiXmlDeclaration( const std::string& _version,
const std::string& _encoding, const std::string& _encoding,
const std::string& _standalone ) const std::string& _standalone )
: TiXmlNode( TiXmlNode::TINYXML_DECLARATION ) : TiXmlNode( TiXmlNode::DECLARATION )
{ {
version = _version; version = _version;
encoding = _encoding; encoding = _encoding;
@ -1355,7 +1404,7 @@ TiXmlDeclaration::TiXmlDeclaration( const std::string& _version,
TiXmlDeclaration::TiXmlDeclaration( const TiXmlDeclaration& copy ) TiXmlDeclaration::TiXmlDeclaration( const TiXmlDeclaration& copy )
: TiXmlNode( TiXmlNode::TINYXML_DECLARATION ) : TiXmlNode( TiXmlNode::DECLARATION )
{ {
copy.CopyTo( this ); copy.CopyTo( this );
} }
@ -1499,9 +1548,9 @@ void TiXmlAttributeSet::Remove( TiXmlAttribute* removeMe )
#ifdef TIXML_USE_STL #ifdef TIXML_USE_STL
TiXmlAttribute* TiXmlAttributeSet::Find( const std::string& name ) const const TiXmlAttribute* TiXmlAttributeSet::Find( const std::string& name ) const
{ {
for( TiXmlAttribute* node = sentinel.next; node != &sentinel; node = node->next ) for( const TiXmlAttribute* node = sentinel.next; node != &sentinel; node = node->next )
{ {
if ( node->name == name ) if ( node->name == name )
return node; return node;
@ -1509,22 +1558,23 @@ TiXmlAttribute* TiXmlAttributeSet::Find( const std::string& name ) const
return 0; return 0;
} }
TiXmlAttribute* TiXmlAttributeSet::FindOrCreate( const std::string& _name ) /*
TiXmlAttribute* TiXmlAttributeSet::Find( const std::string& name )
{ {
TiXmlAttribute* attrib = Find( _name ); for( TiXmlAttribute* node = sentinel.next; node != &sentinel; node = node->next )
if ( !attrib ) { {
attrib = new TiXmlAttribute(); if ( node->name == name )
Add( attrib ); return node;
attrib->SetName( _name );
} }
return attrib; return 0;
} }
*/
#endif #endif
TiXmlAttribute* TiXmlAttributeSet::Find( const char* name ) const const TiXmlAttribute* TiXmlAttributeSet::Find( const char* name ) const
{ {
for( TiXmlAttribute* node = sentinel.next; node != &sentinel; node = node->next ) for( const TiXmlAttribute* node = sentinel.next; node != &sentinel; node = node->next )
{ {
if ( strcmp( node->name.c_str(), name ) == 0 ) if ( strcmp( node->name.c_str(), name ) == 0 )
return node; return node;
@ -1532,18 +1582,17 @@ TiXmlAttribute* TiXmlAttributeSet::Find( const char* name ) const
return 0; return 0;
} }
/*
TiXmlAttribute* TiXmlAttributeSet::FindOrCreate( const char* _name ) TiXmlAttribute* TiXmlAttributeSet::Find( const char* name )
{ {
TiXmlAttribute* attrib = Find( _name ); for( TiXmlAttribute* node = sentinel.next; node != &sentinel; node = node->next )
if ( !attrib ) { {
attrib = new TiXmlAttribute(); if ( strcmp( node->name.c_str(), name ) == 0 )
Add( attrib ); return node;
attrib->SetName( _name );
} }
return attrib; return 0;
} }
*/
#ifdef TIXML_USE_STL #ifdef TIXML_USE_STL
std::istream& operator>> (std::istream & in, TiXmlNode & base) std::istream& operator>> (std::istream & in, TiXmlNode & base)

@ -63,19 +63,21 @@ distribution.
#if defined(_MSC_VER) && (_MSC_VER >= 1400 ) #if defined(_MSC_VER) && (_MSC_VER >= 1400 )
// Microsoft visual studio, version 2005 and higher. // Microsoft visual studio, version 2005 and higher.
#define TIXML_SNPRINTF _snprintf_s #define TIXML_SNPRINTF _snprintf_s
#define TIXML_SNSCANF _snscanf_s
#define TIXML_SSCANF sscanf_s #define TIXML_SSCANF sscanf_s
#elif defined(_MSC_VER) && (_MSC_VER >= 1200 ) #elif defined(_MSC_VER) && (_MSC_VER >= 1200 )
// Microsoft visual studio, version 6 and higher. // Microsoft visual studio, version 6 and higher.
//#pragma message( "Using _sn* functions." ) //#pragma message( "Using _sn* functions." )
#define TIXML_SNPRINTF _snprintf #define TIXML_SNPRINTF _snprintf
#define TIXML_SNSCANF _snscanf
#define TIXML_SSCANF sscanf #define TIXML_SSCANF sscanf
#elif defined(__GNUC__) && (__GNUC__ >= 3 ) #elif defined(__GNUC__) && (__GNUC__ >= 3 )
// GCC version 3 and higher.s // GCC version 3 and higher.s
//#warning( "Using sn* functions." ) //#warning( "Using sn* functions." )
#define TIXML_SNPRINTF snprintf #define TIXML_SNPRINTF snprintf
#define TIXML_SNSCANF snscanf
#define TIXML_SSCANF sscanf #define TIXML_SSCANF sscanf
#else #else
#define TIXML_SNPRINTF snprintf
#define TIXML_SSCANF sscanf #define TIXML_SSCANF sscanf
#endif #endif
#endif #endif
@ -90,8 +92,8 @@ class TiXmlDeclaration;
class TiXmlParsingData; class TiXmlParsingData;
const int TIXML_MAJOR_VERSION = 2; const int TIXML_MAJOR_VERSION = 2;
const int TIXML_MINOR_VERSION = 6; const int TIXML_MINOR_VERSION = 5;
const int TIXML_PATCH_VERSION = 1; const int TIXML_PATCH_VERSION = 3;
/* Internal structure for tracking location of items /* Internal structure for tracking location of items
in the XML file. in the XML file.
@ -107,11 +109,10 @@ struct TiXmlCursor
/** /**
Implements the interface to the "Visitor pattern" (see the Accept() method.)
If you call the Accept() method, it requires being passed a TiXmlVisitor If you call the Accept() method, it requires being passed a TiXmlVisitor
class to handle callbacks. For nodes that contain other nodes (Document, Element) class to handle callbacks. For nodes that contain other nodes (Document, Element)
you will get called with a VisitEnter/VisitExit pair. Nodes that are always leaves you will get called with a VisitEnter/VisitExit pair. Nodes that are always leaves
are simply called with Visit(). are simple called with Visit().
If you return 'true' from a Visit method, recursive parsing will continue. If you return If you return 'true' from a Visit method, recursive parsing will continue. If you return
false, <b>no children of this node or its sibilings</b> will be Visited. false, <b>no children of this node or its sibilings</b> will be Visited.
@ -266,6 +267,7 @@ public:
TIXML_NO_ERROR = 0, TIXML_NO_ERROR = 0,
TIXML_ERROR, TIXML_ERROR,
TIXML_ERROR_OPENING_FILE, TIXML_ERROR_OPENING_FILE,
TIXML_ERROR_OUT_OF_MEMORY,
TIXML_ERROR_PARSING_ELEMENT, TIXML_ERROR_PARSING_ELEMENT,
TIXML_ERROR_FAILED_TO_READ_ELEMENT_NAME, TIXML_ERROR_FAILED_TO_READ_ELEMENT_NAME,
TIXML_ERROR_READING_ELEMENT_VALUE, TIXML_ERROR_READING_ELEMENT_VALUE,
@ -286,7 +288,6 @@ public:
protected: protected:
static const char* SkipWhiteSpace( const char*, TiXmlEncoding encoding ); static const char* SkipWhiteSpace( const char*, TiXmlEncoding encoding );
inline static bool IsWhiteSpace( char c ) inline static bool IsWhiteSpace( char c )
{ {
return ( isspace( (unsigned char) c ) || c == '\n' || c == '\r' ); return ( isspace( (unsigned char) c ) || c == '\n' || c == '\r' );
@ -461,13 +462,13 @@ public:
*/ */
enum NodeType enum NodeType
{ {
TINYXML_DOCUMENT, DOCUMENT,
TINYXML_ELEMENT, ELEMENT,
TINYXML_COMMENT, COMMENT,
TINYXML_UNKNOWN, UNKNOWN,
TINYXML_TEXT, TEXT,
TINYXML_DECLARATION, DECLARATION,
TINYXML_TYPECOUNT TYPECOUNT
}; };
virtual ~TiXmlNode(); virtual ~TiXmlNode();
@ -914,14 +915,17 @@ public:
const TiXmlAttribute* Last() const { return ( sentinel.prev == &sentinel ) ? 0 : sentinel.prev; } const TiXmlAttribute* Last() const { return ( sentinel.prev == &sentinel ) ? 0 : sentinel.prev; }
TiXmlAttribute* Last() { return ( sentinel.prev == &sentinel ) ? 0 : sentinel.prev; } TiXmlAttribute* Last() { return ( sentinel.prev == &sentinel ) ? 0 : sentinel.prev; }
TiXmlAttribute* Find( const char* _name ) const; const TiXmlAttribute* Find( const char* _name ) const;
TiXmlAttribute* FindOrCreate( const char* _name ); TiXmlAttribute* Find( const char* _name ) {
return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttributeSet* >(this))->Find( _name ) );
# ifdef TIXML_USE_STL }
TiXmlAttribute* Find( const std::string& _name ) const; #ifdef TIXML_USE_STL
TiXmlAttribute* FindOrCreate( const std::string& _name ); const TiXmlAttribute* Find( const std::string& _name ) const;
# endif TiXmlAttribute* Find( const std::string& _name ) {
return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttributeSet* >(this))->Find( _name ) );
}
#endif
private: private:
//*ME: Because of hidden/disabled copy-construktor in TiXmlAttribute (sentinel-element), //*ME: Because of hidden/disabled copy-construktor in TiXmlAttribute (sentinel-element),
@ -996,21 +1000,11 @@ public:
} }
#ifdef TIXML_USE_STL #ifdef TIXML_USE_STL
/// QueryStringAttribute examines the attribute - see QueryIntAttribute().
int QueryStringAttribute( const char* name, std::string* _value ) const {
const char* cstr = Attribute( name );
if ( cstr ) {
*_value = std::string( cstr );
return TIXML_SUCCESS;
}
return TIXML_NO_ATTRIBUTE;
}
/** Template form of the attribute query which will try to read the /** Template form of the attribute query which will try to read the
attribute into the specified type. Very easy, very powerful, but attribute into the specified type. Very easy, very powerful, but
be careful to make sure to call this with the correct type. be careful to make sure to call this with the correct type.
NOTE: This method doesn't work correctly for 'string' types that contain spaces. NOTE: This method doesn't work correctly for 'string' types.
@return TIXML_SUCCESS, TIXML_WRONG_TYPE, or TIXML_NO_ATTRIBUTE @return TIXML_SUCCESS, TIXML_WRONG_TYPE, or TIXML_NO_ATTRIBUTE
*/ */
@ -1026,8 +1020,13 @@ public:
return TIXML_SUCCESS; return TIXML_SUCCESS;
return TIXML_WRONG_TYPE; return TIXML_WRONG_TYPE;
} }
/*
This is - in theory - a bug fix for "QueryValueAtribute returns truncated std::string"
but template specialization is hard to get working cross-compiler. Leaving the bug for now.
int QueryValueAttribute( const std::string& name, std::string* outValue ) const // The above will fail for std::string because the space character is used as a seperator.
// Specialize for strings. Bug [ 1695429 ] QueryValueAtribute returns truncated std::string
template<> int QueryValueAttribute( const std::string& name, std::string* outValue ) const
{ {
const TiXmlAttribute* node = attributeSet.Find( name ); const TiXmlAttribute* node = attributeSet.Find( name );
if ( !node ) if ( !node )
@ -1035,6 +1034,7 @@ public:
*outValue = node->ValueStr(); *outValue = node->ValueStr();
return TIXML_SUCCESS; return TIXML_SUCCESS;
} }
*/
#endif #endif
/** Sets an attribute of name to a given value. The attribute /** Sets an attribute of name to a given value. The attribute
@ -1053,8 +1053,6 @@ public:
void SetAttribute( const std::string& name, const std::string& _value ); void SetAttribute( const std::string& name, const std::string& _value );
///< STL std::string form. ///< STL std::string form.
void SetAttribute( const std::string& name, int _value ); void SetAttribute( const std::string& name, int _value );
///< STL std::string form.
void SetDoubleAttribute( const std::string& name, double value );
#endif #endif
/** Sets an attribute of name to a given value. The attribute /** Sets an attribute of name to a given value. The attribute
@ -1146,6 +1144,7 @@ protected:
const char* ReadValue( const char* in, TiXmlParsingData* prevData, TiXmlEncoding encoding ); const char* ReadValue( const char* in, TiXmlParsingData* prevData, TiXmlEncoding encoding );
private: private:
TiXmlAttributeSet attributeSet; TiXmlAttributeSet attributeSet;
}; };
@ -1156,9 +1155,9 @@ class TiXmlComment : public TiXmlNode
{ {
public: public:
/// Constructs an empty comment. /// Constructs an empty comment.
TiXmlComment() : TiXmlNode( TiXmlNode::TINYXML_COMMENT ) {} TiXmlComment() : TiXmlNode( TiXmlNode::COMMENT ) {}
/// Construct a comment from text. /// Construct a comment from text.
TiXmlComment( const char* _value ) : TiXmlNode( TiXmlNode::TINYXML_COMMENT ) { TiXmlComment( const char* _value ) : TiXmlNode( TiXmlNode::COMMENT ) {
SetValue( _value ); SetValue( _value );
} }
TiXmlComment( const TiXmlComment& ); TiXmlComment( const TiXmlComment& );
@ -1210,7 +1209,7 @@ public:
normal, encoded text. If you want it be output as a CDATA text normal, encoded text. If you want it be output as a CDATA text
element, set the parameter _cdata to 'true' element, set the parameter _cdata to 'true'
*/ */
TiXmlText (const char * initValue ) : TiXmlNode (TiXmlNode::TINYXML_TEXT) TiXmlText (const char * initValue ) : TiXmlNode (TiXmlNode::TEXT)
{ {
SetValue( initValue ); SetValue( initValue );
cdata = false; cdata = false;
@ -1219,14 +1218,14 @@ public:
#ifdef TIXML_USE_STL #ifdef TIXML_USE_STL
/// Constructor. /// Constructor.
TiXmlText( const std::string& initValue ) : TiXmlNode (TiXmlNode::TINYXML_TEXT) TiXmlText( const std::string& initValue ) : TiXmlNode (TiXmlNode::TEXT)
{ {
SetValue( initValue ); SetValue( initValue );
cdata = false; cdata = false;
} }
#endif #endif
TiXmlText( const TiXmlText& copy ) : TiXmlNode( TiXmlNode::TINYXML_TEXT ) { copy.CopyTo( this ); } TiXmlText( const TiXmlText& copy ) : TiXmlNode( TiXmlNode::TEXT ) { copy.CopyTo( this ); }
void operator=( const TiXmlText& base ) { base.CopyTo( this ); } void operator=( const TiXmlText& base ) { base.CopyTo( this ); }
// Write this text object to a FILE stream. // Write this text object to a FILE stream.
@ -1279,7 +1278,7 @@ class TiXmlDeclaration : public TiXmlNode
{ {
public: public:
/// Construct an empty declaration. /// Construct an empty declaration.
TiXmlDeclaration() : TiXmlNode( TiXmlNode::TINYXML_DECLARATION ) {} TiXmlDeclaration() : TiXmlNode( TiXmlNode::DECLARATION ) {}
#ifdef TIXML_USE_STL #ifdef TIXML_USE_STL
/// Constructor. /// Constructor.
@ -1347,10 +1346,10 @@ private:
class TiXmlUnknown : public TiXmlNode class TiXmlUnknown : public TiXmlNode
{ {
public: public:
TiXmlUnknown() : TiXmlNode( TiXmlNode::TINYXML_UNKNOWN ) {} TiXmlUnknown() : TiXmlNode( TiXmlNode::UNKNOWN ) {}
virtual ~TiXmlUnknown() {} virtual ~TiXmlUnknown() {}
TiXmlUnknown( const TiXmlUnknown& copy ) : TiXmlNode( TiXmlNode::TINYXML_UNKNOWN ) { copy.CopyTo( this ); } TiXmlUnknown( const TiXmlUnknown& copy ) : TiXmlNode( TiXmlNode::UNKNOWN ) { copy.CopyTo( this ); }
void operator=( const TiXmlUnknown& copy ) { copy.CopyTo( this ); } void operator=( const TiXmlUnknown& copy ) { copy.CopyTo( this ); }
/// Creates a copy of this Unknown and returns it. /// Creates a copy of this Unknown and returns it.
@ -1424,10 +1423,14 @@ public:
#ifdef TIXML_USE_STL #ifdef TIXML_USE_STL
bool LoadFile( const std::string& filename, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING ) ///< STL std::string version. bool LoadFile( const std::string& filename, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING ) ///< STL std::string version.
{ {
// StringToBuffer f( filename );
// return ( f.buffer && LoadFile( f.buffer, encoding ));
return LoadFile( filename.c_str(), encoding ); return LoadFile( filename.c_str(), encoding );
} }
bool SaveFile( const std::string& filename ) const ///< STL std::string version. bool SaveFile( const std::string& filename ) const ///< STL std::string version.
{ {
// StringToBuffer f( filename );
// return ( f.buffer && SaveFile( f.buffer ));
return SaveFile( filename.c_str() ); return SaveFile( filename.c_str() );
} }
#endif #endif

@ -36,6 +36,7 @@ const char* TiXmlBase::errorString[ TIXML_ERROR_STRING_COUNT ] =
"No error", "No error",
"Error", "Error",
"Failed to open file", "Failed to open file",
"Memory allocation failed.",
"Error parsing Element.", "Error parsing Element.",
"Failed to read Element name", "Failed to read Element name",
"Error reading Element value.", "Error reading Element value.",

@ -346,7 +346,7 @@ const char* TiXmlBase::SkipWhiteSpace( const char* p, TiXmlEncoding encoding )
continue; continue;
} }
if ( IsWhiteSpace( *p ) ) // Still using old rules for white space. if ( IsWhiteSpace( *p ) || *p == '\n' || *p =='\r' ) // Still using old rules for white space.
++p; ++p;
else else
break; break;
@ -354,7 +354,7 @@ const char* TiXmlBase::SkipWhiteSpace( const char* p, TiXmlEncoding encoding )
} }
else else
{ {
while ( *p && IsWhiteSpace( *p ) ) while ( (*p && IsWhiteSpace( *p )) || *p == '\n' || *p =='\r' )
++p; ++p;
} }
@ -631,7 +631,7 @@ const char* TiXmlBase::ReadText( const char* p,
} }
} }
} }
if ( p && *p ) if ( p )
p += strlen( endTag ); p += strlen( endTag );
return p; return p;
} }
@ -825,6 +825,7 @@ TiXmlNode* TiXmlNode::Identify( const char* p, TiXmlEncoding encoding )
return 0; return 0;
} }
TiXmlDocument* doc = GetDocument();
p = SkipWhiteSpace( p, encoding ); p = SkipWhiteSpace( p, encoding );
if ( !p || !*p ) if ( !p || !*p )
@ -895,6 +896,11 @@ TiXmlNode* TiXmlNode::Identify( const char* p, TiXmlEncoding encoding )
// Set the parent, so it can report errors // Set the parent, so it can report errors
returnNode->parent = this; returnNode->parent = this;
} }
else
{
if ( doc )
doc->SetError( TIXML_ERROR_OUT_OF_MEMORY, 0, 0, TIXML_ENCODING_UNKNOWN );
}
return returnNode; return returnNode;
} }
@ -1077,6 +1083,7 @@ const char* TiXmlElement::Parse( const char* p, TiXmlParsingData* data, TiXmlEnc
TIXML_STRING endTag ("</"); TIXML_STRING endTag ("</");
endTag += value; endTag += value;
endTag += ">";
// Check for and read attributes. Also look for an empty // Check for and read attributes. Also look for an empty
// tag or an end tag. // tag or an end tag.
@ -1115,21 +1122,11 @@ const char* TiXmlElement::Parse( const char* p, TiXmlParsingData* data, TiXmlEnc
} }
// We should find the end tag now // We should find the end tag now
// note that:
// </foo > and
// </foo>
// are both valid end tags.
if ( StringEqual( p, endTag.c_str(), false, encoding ) ) if ( StringEqual( p, endTag.c_str(), false, encoding ) )
{ {
p += endTag.length(); p += endTag.length();
p = SkipWhiteSpace( p, encoding );
if ( p && *p && *p == '>' ) {
++p;
return p; return p;
} }
if ( document ) document->SetError( TIXML_ERROR_READING_END_TAG, p, data, encoding );
return 0;
}
else else
{ {
if ( document ) document->SetError( TIXML_ERROR_READING_END_TAG, p, data, encoding ); if ( document ) document->SetError( TIXML_ERROR_READING_END_TAG, p, data, encoding );
@ -1142,6 +1139,7 @@ const char* TiXmlElement::Parse( const char* p, TiXmlParsingData* data, TiXmlEnc
TiXmlAttribute* attrib = new TiXmlAttribute(); TiXmlAttribute* attrib = new TiXmlAttribute();
if ( !attrib ) if ( !attrib )
{ {
if ( document ) document->SetError( TIXML_ERROR_OUT_OF_MEMORY, pErr, data, encoding );
return 0; return 0;
} }
@ -1164,7 +1162,7 @@ const char* TiXmlElement::Parse( const char* p, TiXmlParsingData* data, TiXmlEnc
#endif #endif
if ( node ) if ( node )
{ {
if ( document ) document->SetError( TIXML_ERROR_PARSING_ELEMENT, pErr, data, encoding ); node->SetValue( attrib->Value() );
delete attrib; delete attrib;
return 0; return 0;
} }
@ -1193,6 +1191,7 @@ const char* TiXmlElement::ReadValue( const char* p, TiXmlParsingData* data, TiXm
if ( !textNode ) if ( !textNode )
{ {
if ( document ) document->SetError( TIXML_ERROR_OUT_OF_MEMORY, 0, 0, encoding );
return 0; return 0;
} }
@ -1380,7 +1379,7 @@ const char* TiXmlComment::Parse( const char* p, TiXmlParsingData* data, TiXmlEnc
value.append( p, 1 ); value.append( p, 1 );
++p; ++p;
} }
if ( p && *p ) if ( p )
p += strlen( endTag ); p += strlen( endTag );
return p; return p;
@ -1392,6 +1391,10 @@ const char* TiXmlAttribute::Parse( const char* p, TiXmlParsingData* data, TiXmlE
p = SkipWhiteSpace( p, encoding ); p = SkipWhiteSpace( p, encoding );
if ( !p || !*p ) return 0; if ( !p || !*p ) return 0;
// int tabsize = 4;
// if ( document )
// tabsize = document->TabSize();
if ( data ) if ( data )
{ {
data->Stamp( p, encoding ); data->Stamp( p, encoding );
@ -1443,7 +1446,7 @@ const char* TiXmlAttribute::Parse( const char* p, TiXmlParsingData* data, TiXmlE
// its best, even without them. // its best, even without them.
value = ""; value = "";
while ( p && *p // existence while ( p && *p // existence
&& !IsWhiteSpace( *p ) // whitespace && !IsWhiteSpace( *p ) && *p != '\n' && *p != '\r' // whitespace
&& *p != '/' && *p != '>' ) // tag end && *p != '/' && *p != '>' ) // tag end
{ {
if ( *p == SINGLE_QUOTE || *p == DOUBLE_QUOTE ) { if ( *p == SINGLE_QUOTE || *p == DOUBLE_QUOTE ) {