Wrap strtof. Return 0 on nonfinite values.

This commit is contained in:
Steve Checkoway
2006-06-12 06:36:36 +00:00
parent e0d0cb0c3a
commit a45880281a
2 changed files with 12 additions and 2 deletions
+11 -2
View File
@@ -122,7 +122,7 @@ float HHMMSSToSeconds( const RString &sHHMMSS )
float fSeconds = 0;
fSeconds += atoi( arrayBits[0] ) * 60 * 60;
fSeconds += atoi( arrayBits[1] ) * 60;
fSeconds += strtof( arrayBits[2], NULL );
fSeconds += StringToFloat( arrayBits[2] );
return fSeconds;
}
@@ -1472,6 +1472,15 @@ void MakeLower( wchar_t *p, size_t iLen )
UnicodeUpperLower( p, iLen, g_LowerCase );
}
float StringToFloat( const RString &sString )
{
float ret = strtof( sString, NULL );
if( !isfinite(ret) )
ret = 0.0f;
return ret;
}
const wchar_t INVALID_CHAR = 0xFFFD; /* U+FFFD REPLACEMENT CHARACTER */
wstring RStringToWstring( const RString &s )
@@ -1964,7 +1973,7 @@ bool FileRead( RageFileBasic& f, float& fOut )
RString s;
if( !FileRead(f, s) )
return false;
fOut = strtof( s, NULL );
fOut = StringToFloat( s );
return true;
}
+1
View File
@@ -292,6 +292,7 @@ void MakeUpper( char *p, size_t iLen );
void MakeLower( char *p, size_t iLen );
void MakeUpper( wchar_t *p, size_t iLen );
void MakeLower( wchar_t *p, size_t iLen );
float StringToFloat( const RString &sString );
RString WStringToRString( const wstring &sString );
RString WcharToUTF8( wchar_t c );