Fix issues on x86_64 where unsigned is not large enough to hold RString::npos and so the comparison is always false. Gcc would have been free to optimize that away. Not sure if it did or not.

This commit is contained in:
Steve Checkoway
2008-12-26 12:34:46 +00:00
parent a6b0a78d98
commit 45c642ec28
+11 -11
View File
@@ -20,7 +20,7 @@ bool XmlFileUtil::LoadFromFileShowErrors( XNode &xml, RageFileBasic &f )
return true; return true;
RString sWarning = ssprintf( "XML: LoadFromFile failed: %s", sError.c_str() ); RString sWarning = ssprintf( "XML: LoadFromFile failed: %s", sError.c_str() );
LOG->Warn( sWarning ); LOG->Warn( "%s", sWarning.c_str() );
Dialog::OK( sWarning, "XML_PARSE_ERROR" ); Dialog::OK( sWarning, "XML_PARSE_ERROR" );
return false; return false;
} }
@@ -39,7 +39,7 @@ bool XmlFileUtil::LoadFromFileShowErrors( XNode &xml, const RString &sFile )
if( !bSuccess ) if( !bSuccess )
{ {
RString sWarning = ssprintf( "XML: LoadFromFile failed for file: %s", sFile.c_str() ); RString sWarning = ssprintf( "XML: LoadFromFile failed for file: %s", sFile.c_str() );
LOG->Warn( sWarning ); LOG->Warn( "%s", sWarning.c_str() );
Dialog::OK( sWarning, "XML_PARSE_ERROR" ); Dialog::OK( sWarning, "XML_PARSE_ERROR" );
} }
return bSuccess; return bSuccess;
@@ -84,7 +84,7 @@ static void InitEntities()
// skip spaces // skip spaces
static void tcsskip( const RString &s, unsigned &i ) static void tcsskip( const RString &s, RString::size_type &i )
{ {
i = s.find_first_not_of( " \t\r\n", i ); i = s.find_first_not_of( " \t\r\n", i );
} }
@@ -116,7 +116,7 @@ static void SetString( const RString &s, int iStart, int iEnd, RString* ps, bool
// Return : advanced string pointer. (error return npos) // Return : advanced string pointer. (error return npos)
namespace namespace
{ {
unsigned LoadAttributes( XNode *pNode, const RString &xml, RString &sErrorOut, unsigned iOffset ) RString::size_type LoadAttributes( XNode *pNode, const RString &xml, RString &sErrorOut, RString::size_type iOffset )
{ {
while( iOffset < xml.size() ) while( iOffset < xml.size() )
{ {
@@ -130,7 +130,7 @@ unsigned LoadAttributes( XNode *pNode, const RString &xml, RString &sErrorOut, u
return iOffset; // well-formed tag return iOffset; // well-formed tag
// XML Attr Name // XML Attr Name
unsigned iEnd = xml.find_first_of( " =", iOffset ); RString::size_type iEnd = xml.find_first_of( " =", iOffset );
if( iEnd == xml.npos ) if( iEnd == xml.npos )
{ {
// error // error
@@ -207,7 +207,7 @@ unsigned LoadAttributes( XNode *pNode, const RString &xml, RString &sErrorOut, u
// Param : pszXml - plain xml text // Param : pszXml - plain xml text
// pi = parser information // pi = parser information
// Return : advanced string pointer (error return npos) // Return : advanced string pointer (error return npos)
unsigned LoadInternal( XNode *pNode, const RString &xml, RString &sErrorOut, unsigned iOffset ) RString::size_type LoadInternal( XNode *pNode, const RString &xml, RString &sErrorOut, RString::size_type iOffset )
{ {
pNode->Clear(); pNode->Clear();
@@ -226,7 +226,7 @@ unsigned LoadInternal( XNode *pNode, const RString &xml, RString &sErrorOut, uns
iOffset += 4; iOffset += 4;
/* Find the close tag. */ /* Find the close tag. */
unsigned iEnd = xml.find( "-->", iOffset ); RString::size_type iEnd = xml.find( "-->", iOffset );
if( iEnd == string::npos ) if( iEnd == string::npos )
{ {
if( sErrorOut.empty() ) if( sErrorOut.empty() )
@@ -243,7 +243,7 @@ unsigned LoadInternal( XNode *pNode, const RString &xml, RString &sErrorOut, uns
// XML Node Tag Name Open // XML Node Tag Name Open
iOffset++; iOffset++;
unsigned iTagEnd = xml.find_first_of( " \t\r\n/>", iOffset ); RString::size_type iTagEnd = xml.find_first_of( " \t\r\n/>", iOffset );
RString sName; RString sName;
SetString( xml, iOffset, iTagEnd, &sName ); SetString( xml, iOffset, iTagEnd, &sName );
pNode->SetName( sName ); pNode->SetName( sName );
@@ -293,7 +293,7 @@ unsigned LoadInternal( XNode *pNode, const RString &xml, RString &sErrorOut, uns
{ {
// Text Value // Text Value
++iOffset; ++iOffset;
unsigned iEnd = xml.find( chXMLTagOpen, iOffset ); RString::size_type iEnd = xml.find( chXMLTagOpen, iOffset );
if( iEnd == string::npos ) if( iEnd == string::npos )
{ {
if( sErrorOut.empty() ) if( sErrorOut.empty() )
@@ -345,7 +345,7 @@ unsigned LoadInternal( XNode *pNode, const RString &xml, RString &sErrorOut, uns
if( iOffset >= xml.size() ) if( iOffset >= xml.size() )
continue; continue;
unsigned iEnd = xml.find_first_of( " >", iOffset ); RString::size_type iEnd = xml.find_first_of( " >", iOffset );
if( iEnd == string::npos ) if( iEnd == string::npos )
{ {
if( sErrorOut.empty() ) if( sErrorOut.empty() )
@@ -376,7 +376,7 @@ unsigned LoadInternal( XNode *pNode, const RString &xml, RString &sErrorOut, uns
if( pNode->GetAttr(XNode::TEXT_ATTRIBUTE) == NULL && iOffset < xml.size() && xml[iOffset] != chXMLTagOpen ) if( pNode->GetAttr(XNode::TEXT_ATTRIBUTE) == NULL && iOffset < xml.size() && xml[iOffset] != chXMLTagOpen )
{ {
// Text Value // Text Value
unsigned iEnd = xml.find( chXMLTagOpen, iOffset ); RString::size_type iEnd = xml.find( chXMLTagOpen, iOffset );
if( iEnd == string::npos ) if( iEnd == string::npos )
{ {
// error cos not exist CloseTag </TAG> // error cos not exist CloseTag </TAG>