Skip to content

Commit

Permalink
Ignore leading whitespace when setting values by name,
Browse files Browse the repository at this point in the history
Previously this didn't work:
`set blackbox_device = SPIFLASH`
Users had to type in:
`set blackbox_device =SPIFLASH`
  • Loading branch information
hydra committed Nov 14, 2015
1 parent 2d73a74 commit df7d4be
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/main/io/serial_cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit df7d4be

Please sign in to comment.