fix float detection in console, fixes stuff like !set type all 0.8C

This commit is contained in:
jacob1
2016-09-10 12:46:15 -04:00
parent 86fef64309
commit 797f9357ff

View File

@@ -80,48 +80,53 @@ ValueType TPTScriptInterface::testType(std::string word)
return TypeFunction; return TypeFunction;
else if (word == "quit") else if (word == "quit")
return TypeFunction; return TypeFunction;
//Basic type //Basic type
for (i = 0; i < word.length(); i++) for (i = 0; i < word.length(); i++)
{ {
if (!(rawWord[i] >= '0' && rawWord[i] <= '9') && !(rawWord[i] == '-' && !i)) if (!(rawWord[i] >= '0' && rawWord[i] <= '9') && !(rawWord[i] == '-' && !i))
{ {
if (rawWord[i] == '.' && rawWord[i+1]) if (rawWord[i] == '.' && rawWord[i+1])
goto parseFloat; goto parseFloat;
else if (rawWord[i] == ',' && rawWord[i+1] >= '0' && rawWord[i+1] <= '9') else if (rawWord[i] == ',' && rawWord[i+1] >= '0' && rawWord[i+1] <= '9')
goto parsePoint; goto parsePoint;
else if ((rawWord[i] == '#' || (i && rawWord[i-1] == '0' && rawWord[i] == 'x')) && else if ((rawWord[i] == '#' || (i && rawWord[i-1] == '0' && rawWord[i] == 'x')) &&
((rawWord[i+1] >= '0' && rawWord[i+1] <= '9') ((rawWord[i+1] >= '0' && rawWord[i+1] <= '9')
|| (rawWord[i+1] >= 'a' && rawWord[i+1] <= 'f') || (rawWord[i+1] >= 'a' && rawWord[i+1] <= 'f')
|| (rawWord[i+1] >= 'A' && rawWord[i+1] <= 'F'))) || (rawWord[i+1] >= 'A' && rawWord[i+1] <= 'F')))
goto parseNumberHex; goto parseNumberHex;
else else
goto parseString; goto parseString;
} }
} }
return TypeNumber; return TypeNumber;
parseFloat:
for (i++; i < word.length(); i++) parseFloat:
if (!((rawWord[i] >= '0' && rawWord[i] <= '9') || (rawWord[i] >= 'a' && rawWord[i] <= 'f') || (rawWord[i] >= 'A' && rawWord[i] <= 'F'))) for (i++; i < word.length(); i++)
{ if (!((rawWord[i] >= '0' && rawWord[i] <= '9')))
goto parseString; {
} goto parseString;
return TypeFloat; }
parseNumberHex: return TypeFloat;
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'))) parseNumberHex:
{ for (i++; i < word.length(); i++)
goto parseString; if (!((rawWord[i] >= '0' && rawWord[i] <= '9') || (rawWord[i] >= 'a' && rawWord[i] <= 'f') || (rawWord[i] >= 'A' && rawWord[i] <= 'F')))
} {
return TypeNumber; goto parseString;
parsePoint: }
for (i++; i < word.length(); i++) return TypeNumber;
if (!(rawWord[i] >= '0' && rawWord[i] <= '9'))
{ parsePoint:
goto parseString; for (i++; i < word.length(); i++)
} if (!(rawWord[i] >= '0' && rawWord[i] <= '9'))
return TypePoint; {
parseString: goto parseString;
return TypeString; }
return TypePoint;
parseString:
return TypeString;
} }
int TPTScriptInterface::parseNumber(char * stringData) int TPTScriptInterface::parseNumber(char * stringData)