Merge pull request #338 from jdduke/fast_atof_fix_final
Gracefully handle NaN/inf values in fast_atoreal_movepull/344/head
commit
fddae20cb7
|
@ -16,7 +16,9 @@
|
||||||
#define __FAST_A_TO_F_H_INCLUDED__
|
#define __FAST_A_TO_F_H_INCLUDED__
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <limits.h>
|
#include <limits>
|
||||||
|
|
||||||
|
#include "StringComparison.h"
|
||||||
|
|
||||||
namespace Assimp
|
namespace Assimp
|
||||||
{
|
{
|
||||||
|
@ -236,6 +238,24 @@ inline const char* fast_atoreal_move( const char* c, Real& out, bool check_comma
|
||||||
++c;
|
++c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((c[0] == 'N' || c[0] == 'n') && ASSIMP_strincmp(c, "nan", 3) == 0)
|
||||||
|
{
|
||||||
|
out = std::numeric_limits<Real>::quiet_NaN();
|
||||||
|
c += 3;
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((c[0] == 'I' || c[0] == 'i') && ASSIMP_strincmp(c, "inf", 3) == 0)
|
||||||
|
{
|
||||||
|
out = std::numeric_limits<Real>::infinity();
|
||||||
|
c += 3;
|
||||||
|
if ((c[0] == 'I' || c[0] == 'i') && ASSIMP_strincmp(c, "inity", 5) == 0)
|
||||||
|
{
|
||||||
|
c += 5;
|
||||||
|
}
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
if (!(c[0] >= '0' && c[0] <= '9') &&
|
if (!(c[0] >= '0' && c[0] <= '9') &&
|
||||||
!(c[0] == '.' && c[1] >= '0' && c[1] <= '9'))
|
!(c[0] == '.' && c[1] >= '0' && c[1] <= '9'))
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue