Merge pull request #3246 from thinkyhead/rc_fix_numeric_filenames

Fix: current_command_args skips digits at the front
This commit is contained in:
Scott Lahteine 2016-03-25 16:38:36 -07:00
commit 26168676e7

View File

@ -5978,28 +5978,34 @@ void process_next_command() {
char* starpos = strchr(current_command, '*'); // * should always be the last parameter char* starpos = strchr(current_command, '*'); // * should always be the last parameter
if (starpos) while (*starpos == ' ' || *starpos == '*') *starpos-- = '\0'; // nullify '*' and ' ' if (starpos) while (*starpos == ' ' || *starpos == '*') *starpos-- = '\0'; // nullify '*' and ' '
// Get the command code, which must be G, M, or T char *cmd_ptr = current_command;
char command_code = *current_command;
// Skip the letter-code and spaces to get the numeric part // Get the command code, which must be G, M, or T
current_command_args = current_command + 1; char command_code = *cmd_ptr++;
while (*current_command_args == ' ') ++current_command_args;
// Skip spaces to get the numeric part
while (*cmd_ptr == ' ') cmd_ptr++;
// The code must have a numeric value // The code must have a numeric value
bool code_is_good = (*current_command_args >= '0' && *current_command_args <= '9'); bool code_is_good = false;
int codenum; // define ahead of goto int codenum = 0; // define ahead of goto
// Get and skip the code number
while (*cmd_ptr >= '0' && *cmd_ptr <= '9') {
code_is_good = true;
codenum = codenum * 10 + *cmd_ptr - '0';
cmd_ptr++;
}
// Bail early if there's no code // Bail early if there's no code
if (!code_is_good) goto ExitUnknownCommand; if (!code_is_good) goto ExitUnknownCommand;
// Args pointer optimizes code_seen, especially those taking XYZEF // Skip all spaces to get to the first argument
// This wastes a little cpu on commands that expect no arguments. while (*cmd_ptr == ' ') cmd_ptr++;
while (*current_command_args == ' ' || (*current_command_args >= '0' && *current_command_args <= '9')) ++current_command_args;
// Interpret the code int // The command's arguments start here, for sure!
seen_pointer = current_command; current_command_args = cmd_ptr;
codenum = code_value_short();
KEEPALIVE_STATE(IN_HANDLER); KEEPALIVE_STATE(IN_HANDLER);