Merge pull request #5913 from etracer65/cli_whitespace_ignore

Ignore leading whitespace for cli command parameters
This commit is contained in:
Michael Keller 2018-05-20 00:31:24 +12:00 committed by GitHub
commit 155a71def7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 10 deletions

View File

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