1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-15 20:35:33 +03:00

Ignore leading whitespace for cli command parameters

This commit is contained in:
Bruce Luckcuck 2018-05-17 15:48:14 -04:00
parent b5521b927d
commit 4423bf9018

View file

@ -2370,11 +2370,20 @@ static void cliMap(char *cmdline)
cliPrintLinef("map %s", buf); cliPrintLinef("map %s", buf);
} }
static char *skipSpace(char *buffer)
{
while (*(buffer) == ' ') {
buffer++;
}
return buffer;
}
static char *checkCommand(char *cmdLine, const char *command) static char *checkCommand(char *cmdLine, const char *command)
{ {
if (!strncasecmp(cmdLine, command, strlen(command)) // command names match if (!strncasecmp(cmdLine, command, strlen(command)) // command names match
&& (isspace((unsigned)cmdLine[strlen(command)]) || cmdLine[strlen(command)] == 0)) { && (isspace((unsigned)cmdLine[strlen(command)]) || cmdLine[strlen(command)] == 0)) {
return cmdLine + strlen(command) + 1; return skipSpace(cmdLine + strlen(command) + 1);
} else { } else {
return 0; return 0;
} }
@ -3029,15 +3038,6 @@ STATIC_UNIT_TESTED void cliGet(char *cmdline)
cliPrintLine("Invalid name"); cliPrintLine("Invalid name");
} }
static char *skipSpace(char *buffer)
{
while (*(buffer) == ' ') {
buffer++;
}
return buffer;
}
static uint8_t getWordLength(char *bufBegin, char *bufEnd) static uint8_t getWordLength(char *bufBegin, char *bufEnd)
{ {
while (*(bufEnd - 1) == ' ') { while (*(bufEnd - 1) == ' ') {