Ver código fonte

Merge pull request #3246 from thinkyhead/rc_fix_numeric_filenames

Fix: current_command_args skips digits at the front
Scott Lahteine 9 anos atrás
pai
commit
26168676e7
1 arquivos alterados com 18 adições e 12 exclusões
  1. 18
    12
      Marlin/Marlin_main.cpp

+ 18
- 12
Marlin/Marlin_main.cpp Ver arquivo

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

Carregando…
Cancelar
Salvar