mirror of
https://github.com/arendst/Tasmota.git
synced 2025-08-07 01:47:43 +00:00
Merge pull request #6503 from laurentdong/AcceptNegativeNumber
Accept negative number
This commit is contained in:
commit
0f0febef11
@ -919,6 +919,10 @@ bool findNextNumber(char * &pNumber, float &value)
|
|||||||
{
|
{
|
||||||
bool bSucceed = false;
|
bool bSucceed = false;
|
||||||
String sNumber = "";
|
String sNumber = "";
|
||||||
|
if (*pNumber == '-') {
|
||||||
|
sNumber = "-";
|
||||||
|
pNumber++;
|
||||||
|
}
|
||||||
while (*pNumber) {
|
while (*pNumber) {
|
||||||
if (isdigit(*pNumber) || (*pNumber == '.')) {
|
if (isdigit(*pNumber) || (*pNumber == '.')) {
|
||||||
sNumber += *pNumber;
|
sNumber += *pNumber;
|
||||||
@ -996,7 +1000,7 @@ bool findNextVariableValue(char * &pVarname, float &value)
|
|||||||
/*
|
/*
|
||||||
* Find next object in expression and evaluate it
|
* Find next object in expression and evaluate it
|
||||||
* An object could be:
|
* An object could be:
|
||||||
* - A float number start with a digit, like 0.787
|
* - A float number start with a digit or minus, like 0.787, -3
|
||||||
* - A variable name, like VAR1, MEM3
|
* - A variable name, like VAR1, MEM3
|
||||||
* - An expression enclosed with a pair of round brackets, (.....)
|
* - An expression enclosed with a pair of round brackets, (.....)
|
||||||
* Input:
|
* Input:
|
||||||
@ -1018,7 +1022,7 @@ bool findNextObjectValue(char * &pointer, float &value)
|
|||||||
pointer++;
|
pointer++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (isdigit(*pointer)) { //This object is a number
|
if (isdigit(*pointer) || (*pointer) == '-') { //This object is a number
|
||||||
bSucceed = findNextNumber(pointer, value);
|
bSucceed = findNextNumber(pointer, value);
|
||||||
break;
|
break;
|
||||||
} else if (isalpha(*pointer)) { //Should be a variable like VAR12, MEM1
|
} else if (isalpha(*pointer)) { //Should be a variable like VAR12, MEM1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user