Browse Source

Merge pull request #3246 from thinkyhead/rc_fix_numeric_filenames

Fix: current_command_args skips digits at the front
pull/1/head
Scott Lahteine 9 years ago
parent
commit
26168676e7
  1. 30
      Marlin/Marlin_main.cpp

30
Marlin/Marlin_main.cpp

@ -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 ' '
char *cmd_ptr = current_command;
// Get the command code, which must be G, M, or T // Get the command code, which must be G, M, or T
char command_code = *current_command; char command_code = *cmd_ptr++;
// Skip the letter-code and spaces to get the numeric part // Skip spaces to get the numeric part
current_command_args = current_command + 1; while (*cmd_ptr == ' ') cmd_ptr++;
while (*current_command_args == ' ') ++current_command_args;
// 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 = 0; // define ahead of goto
int codenum; // 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);

Loading…
Cancel
Save