Minor cleanup to command dispatcher

master
Scott Lahteine 9 years ago
parent f1ed310322
commit 5f8e52aefb

@ -6082,25 +6082,22 @@ void process_next_command() {
// Skip spaces to get the numeric part // Skip spaces to get the numeric part
while (*cmd_ptr == ' ') cmd_ptr++; while (*cmd_ptr == ' ') cmd_ptr++;
// The code must have a numeric value uint16_t codenum = 0; // define ahead of goto
bool code_is_good = false;
int codenum = 0; // define ahead of goto // Bail early if there's no code
bool code_is_good = NUMERIC(*cmd_ptr);
if (!code_is_good) goto ExitUnknownCommand;
// Get and skip the code number // Get and skip the code number
while (*cmd_ptr >= '0' && *cmd_ptr <= '9') { do {
code_is_good = true; codenum = (codenum * 10) + (*cmd_ptr - '0');
codenum = codenum * 10 + *cmd_ptr - '0';
cmd_ptr++; cmd_ptr++;
} } while (NUMERIC(*cmd_ptr));
// Bail early if there's no code
if (!code_is_good) goto ExitUnknownCommand;
// Skip all spaces to get to the first argument // Skip all spaces to get to the first argument, or nul
while (*cmd_ptr == ' ') cmd_ptr++; while (*cmd_ptr == ' ') cmd_ptr++;
// The command's arguments start here, for sure! // The command's arguments (if any) start here, for sure!
current_command_args = cmd_ptr; current_command_args = cmd_ptr;
KEEPALIVE_STATE(IN_HANDLER); KEEPALIVE_STATE(IN_HANDLER);

Loading…
Cancel
Save