From 30c45e948f706f650e79addb6bf6388330f88559 Mon Sep 17 00:00:00 2001 From: Jacob Alexander Date: Wed, 22 Jan 2014 01:10:32 -0800 Subject: [PATCH] Fixing CLI command processing bug. - Issue with the first space delimiter before the args --- Debug/cli/cli.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Debug/cli/cli.c b/Debug/cli/cli.c index b69bdf0..ce843d6 100644 --- a/Debug/cli/cli.c +++ b/Debug/cli/cli.c @@ -186,14 +186,13 @@ void commandLookup_cli() char* cmdPtr = CLILineBuffer - 1; while ( *++cmdPtr == ' ' ); // Skips leading spaces, and points to first character of cmd - // Locates first space delimiter, and points to first character of args or a NULL (no args) - char* argPtr = cmdPtr; - do { + // Locates first space delimiter + char* argPtr = cmdPtr + 1; + while ( *argPtr != ' ' && *argPtr != '\0' ) argPtr++; - } while ( *argPtr != ' ' && *argPtr != '\0' ); - // Set the space delimiter as a NULL - argPtr[-1] = '\0'; + // Point to the first character of args or a NULL (no args) and set the space delimiter as a NULL + (++argPtr)[-1] = '\0'; // Scan array of dictionaries for a valid command match for ( uint8_t dict = 0; dict < CLIDictionariesUsed; dict++ ) -- 2.39.2