Fix CLI bug where incorrect variables would be set when similarly named
variables are used. Previously the following was broken: set option = 1 set option_extra = 2 Instead of setting 'option_extra' to two 'option' was set to 2 if 'option' appeared before 'option_extra' in the list of settings.
This commit is contained in:
parent
e867af8c4b
commit
f8bdc79a9f
|
@ -888,13 +888,20 @@ static void cliSet(char *cmdline)
|
|||
}
|
||||
} else if ((eqptr = strstr(cmdline, "=")) != NULL) {
|
||||
// has equal, set var
|
||||
char *lastNonSpaceCharacter = eqptr;
|
||||
while (*(lastNonSpaceCharacter - 1) == ' ') {
|
||||
lastNonSpaceCharacter--;
|
||||
}
|
||||
uint8_t variableNameLength = lastNonSpaceCharacter - cmdline;
|
||||
|
||||
eqptr++;
|
||||
len--;
|
||||
value = atoi(eqptr);
|
||||
valuef = fastA2F(eqptr);
|
||||
for (i = 0; i < VALUE_COUNT; i++) {
|
||||
val = &valueTable[i];
|
||||
if (strncasecmp(cmdline, valueTable[i].name, strlen(valueTable[i].name)) == 0) {
|
||||
// ensure exact match when setting to prevent setting variables with shorter names
|
||||
if (strncasecmp(cmdline, valueTable[i].name, strlen(valueTable[i].name)) == 0 && variableNameLength == strlen(valueTable[i].name)) {
|
||||
if (valuef >= valueTable[i].min && valuef <= valueTable[i].max) { // here we compare the float value since... it should work, RIGHT?
|
||||
int_float_value_t tmp;
|
||||
if (valueTable[i].type == VAR_FLOAT)
|
||||
|
|
Loading…
Reference in New Issue