|
@@ -5965,28 +5965,34 @@ void process_next_command() {
|
5965
|
5965
|
char* starpos = strchr(current_command, '*'); // * should always be the last parameter
|
5966
|
5966
|
if (starpos) while (*starpos == ' ' || *starpos == '*') *starpos-- = '\0'; // nullify '*' and ' '
|
5967
|
5967
|
|
|
5968
|
+ char *cmd_ptr = current_command;
|
|
5969
|
+
|
5968
|
5970
|
// Get the command code, which must be G, M, or T
|
5969
|
|
- char command_code = *current_command;
|
|
5971
|
+ char command_code = *cmd_ptr++;
|
5970
|
5972
|
|
5971
|
|
- // Skip the letter-code and spaces to get the numeric part
|
5972
|
|
- current_command_args = current_command + 1;
|
5973
|
|
- while (*current_command_args == ' ') ++current_command_args;
|
|
5973
|
+ // Skip spaces to get the numeric part
|
|
5974
|
+ while (*cmd_ptr == ' ') cmd_ptr++;
|
5974
|
5975
|
|
5975
|
5976
|
// The code must have a numeric value
|
5976
|
|
- bool code_is_good = (*current_command_args >= '0' && *current_command_args <= '9');
|
|
5977
|
+ bool code_is_good = false;
|
|
5978
|
+
|
|
5979
|
+ int codenum = 0; // define ahead of goto
|
5977
|
5980
|
|
5978
|
|
- int codenum; // define ahead of goto
|
|
5981
|
+ // Get and skip the code number
|
|
5982
|
+ while (*cmd_ptr >= '0' && *cmd_ptr <= '9') {
|
|
5983
|
+ code_is_good = true;
|
|
5984
|
+ codenum = codenum * 10 + *cmd_ptr - '0';
|
|
5985
|
+ cmd_ptr++;
|
|
5986
|
+ }
|
5979
|
5987
|
|
5980
|
5988
|
// Bail early if there's no code
|
5981
|
5989
|
if (!code_is_good) goto ExitUnknownCommand;
|
5982
|
5990
|
|
5983
|
|
- // Args pointer optimizes code_seen, especially those taking XYZEF
|
5984
|
|
- // This wastes a little cpu on commands that expect no arguments.
|
5985
|
|
- while (*current_command_args == ' ' || (*current_command_args >= '0' && *current_command_args <= '9')) ++current_command_args;
|
|
5991
|
+ // Skip all spaces to get to the first argument
|
|
5992
|
+ while (*cmd_ptr == ' ') cmd_ptr++;
|
5986
|
5993
|
|
5987
|
|
- // Interpret the code int
|
5988
|
|
- seen_pointer = current_command;
|
5989
|
|
- codenum = code_value_short();
|
|
5994
|
+ // The command's arguments start here, for sure!
|
|
5995
|
+ current_command_args = cmd_ptr;
|
5990
|
5996
|
|
5991
|
5997
|
KEEPALIVE_STATE(IN_HANDLER);
|
5992
|
5998
|
|