Skip to content

Commit

Permalink
better float detection in old console
Browse files Browse the repository at this point in the history
  • Loading branch information
jacob1 committed Aug 9, 2014
1 parent 734368d commit e388a4b
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/lua/TPTScriptInterface.cpp
Expand Up @@ -86,8 +86,8 @@ ValueType TPTScriptInterface::testType(std::string word)
{
if (!(rawWord[i] >= '0' && rawWord[i] <= '9') && !(rawWord[i] == '-' && !i))
{
if (rawWord[i] == '.' && i)
return TypeFloat;
if (rawWord[i] == '.' && rawWord[i+1])
goto parseFloat;
else if (rawWord[i] == ',' && rawWord[i+1] >= '0' && rawWord[i+1] <= '9')
goto parsePoint;
else if ((rawWord[i] == '#' || rawWord[i] == 'x') &&
Expand All @@ -99,17 +99,23 @@ ValueType TPTScriptInterface::testType(std::string word)
goto parseString;
}
}
return TypeNumber;
parseFloat:
for (i++; i < word.length(); i++)
if(!((rawWord[i] >= '0' && rawWord[i] <= '9') || (rawWord[i] >= 'a' && rawWord[i] <= 'f') || (rawWord[i] >= 'A' && rawWord[i] <= 'F')))
{
goto parseString;
}
return TypeFloat;
parseNumberHex:
i++;
for (; i < word.length(); i++)
for (i++; i < word.length(); i++)
if(!((rawWord[i] >= '0' && rawWord[i] <= '9') || (rawWord[i] >= 'a' && rawWord[i] <= 'f') || (rawWord[i] >= 'A' && rawWord[i] <= 'F')))
{
goto parseString;
}
return TypeNumber;
parsePoint:
i++;
for (; i < word.length(); i++)
for (i++; i < word.length(); i++)
if(!(rawWord[i] >= '0' && rawWord[i] <= '9'))
{
goto parseString;
Expand Down

0 comments on commit e388a4b

Please sign in to comment.