OSDN Git Service

Correct some identified TinyXML issues.
authorKeith Marshall <keithmarshall@users.sourceforge.net>
Thu, 5 Nov 2009 21:53:19 +0000 (21:53 +0000)
committerKeith Marshall <keithmarshall@users.sourceforge.net>
Thu, 5 Nov 2009 21:53:19 +0000 (21:53 +0000)
ChangeLog
tinyxml/tinyxml.cpp
tinyxml/tinyxml.h
tinyxml/tinyxmlparser.cpp

index e2671f3..8706bb5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2009-11-05  Keith Marshall  <keithmarshall@users.sourceforge.net>
+
+       Correct some identified TinyXML issues.
+
+       * tinyxml/tinyxml.h (IsWhiteSpace): Add FIXME annotation to flag
+       probable redundancy of checks for '\n' and '\r'.
+       * tinyxml/tinyxmlparser.cpp: Revert John E's 2008-08-09 change; remove
+       all such redundancies in IsWhiteSpace() calls throughout.
+
+       * tinyxml/tinyxml.cpp (TiXmlAttribute::SetDoubleValue): Correct format
+       specification in sprintf()/snprintf() calls; "%lf" is invalid; replace
+       with "%f".
+
 2009-10-31  Keith Marshall  <keithmarshall@users.sourceforge.net>
 
        Add CLI loader stub.
index 5de21f6..93b69ca 100644 (file)
@@ -1266,9 +1266,9 @@ void TiXmlAttribute::SetDoubleValue( double _value )
 {
        char buf [256];
        #if defined(TIXML_SNPRINTF)             
-               TIXML_SNPRINTF( buf, sizeof(buf), "%lf", _value);
+               TIXML_SNPRINTF( buf, sizeof(buf), "%f", _value);
        #else
-               sprintf (buf, "%lf", _value);
+               sprintf (buf, "%f", _value);
        #endif
        SetValue (buf);
 }
index c6f40cc..6b23b25 100644 (file)
@@ -290,6 +290,11 @@ protected:
        static const char* SkipWhiteSpace( const char*, TiXmlEncoding encoding );
        inline static bool IsWhiteSpace( char c )               
        { 
+               // FIXME: Explicit tests for '\n' and '\r' seem redundant here;
+               // POSIX requires isspace() to match both of these characters as
+               // white space anyway; is there any know implementation which
+               // does not comply with this requirement?
+               //
                return ( isspace( (unsigned char) c ) || c == '\n' || c == '\r' ); 
        }
        inline static bool IsWhiteSpace( int c )
index 23f8eec..b4bec75 100644 (file)
@@ -22,10 +22,6 @@ must not be misrepresented as being the original software.
 distribution.
 */
 
-/* Modified: JohnE, 2008-08-09
- * Add parentheses to fix GCC -Wall warning
- */
-
 #include <ctype.h>
 #include <stddef.h>
 
@@ -350,7 +346,7 @@ const char* TiXmlBase::SkipWhiteSpace( const char* p, TiXmlEncoding encoding )
                                continue;
                        }
 
-                       if ( IsWhiteSpace( *p ) || *p == '\n' || *p =='\r' )            // Still using old rules for white space.
+                       if ( IsWhiteSpace( *p ) )
                                ++p;
                        else
                                break;
@@ -358,7 +354,7 @@ const char* TiXmlBase::SkipWhiteSpace( const char* p, TiXmlEncoding encoding )
        }
        else
        {
-               while ( ( *p && IsWhiteSpace( *p ) ) || *p == '\n' || *p =='\r' )
+               while ( *p && IsWhiteSpace( *p ) )
                        ++p;
        }
 
@@ -1450,7 +1446,7 @@ const char* TiXmlAttribute::Parse( const char* p, TiXmlParsingData* data, TiXmlE
                // its best, even without them.
                value = "";
                while (    p && *p                                                                                      // existence
-                               && !IsWhiteSpace( *p ) && *p != '\n' && *p != '\r'      // whitespace
+                               && !IsWhiteSpace( *p )          // whitespace
                                && *p != '/' && *p != '>' )                                                     // tag end
                {
                        if ( *p == SINGLE_QUOTE || *p == DOUBLE_QUOTE ) {