1
0
Fork 0
mirror of https://github.com/iNavFlight/inav.git synced 2025-07-23 00:05:28 +03:00

Ignore leading whitespace when setting values by name,

Previously this didn't work:
`set blackbox_device = SPIFLASH`
Users had to type in:
`set blackbox_device =SPIFLASH`
This commit is contained in:
Dominic Clifton 2015-11-14 16:35:42 +00:00
parent 2d73a74802
commit df7d4be263

View file

@ -2165,15 +2165,20 @@ static void cliSet(char *cmdline)
cliPrint("\r\n");
}
} else if ((eqptr = strstr(cmdline, "=")) != NULL) {
// has equal, set var
// has equals
char *lastNonSpaceCharacter = eqptr;
while (*(lastNonSpaceCharacter - 1) == ' ') {
lastNonSpaceCharacter--;
}
uint8_t variableNameLength = lastNonSpaceCharacter - cmdline;
// skip the '=' and any ' ' characters
eqptr++;
len--;
while (*(eqptr) == ' ') {
eqptr++;
}
for (i = 0; i < VALUE_COUNT; i++) {
val = &valueTable[i];
// ensure exact match when setting to prevent setting variables with shorter names