浏览代码

Merge pull request #2987 from thinkyhead/gcode_allow_no_initial_space

Fix handling of spaces in GCode
Scott Lahteine 9 年前
父节点
当前提交
7f30f85602
共有 1 个文件被更改,包括 3 次插入2 次删除
  1. 3
    2
      Marlin/Marlin_main.cpp

+ 3
- 2
Marlin/Marlin_main.cpp 查看文件

973
 bool code_has_value() {
973
 bool code_has_value() {
974
   int i = 1;
974
   int i = 1;
975
   char c = seen_pointer[i];
975
   char c = seen_pointer[i];
976
+  while (c == ' ') c = seen_pointer[++i];
976
   if (c == '-' || c == '+') c = seen_pointer[++i];
977
   if (c == '-' || c == '+') c = seen_pointer[++i];
977
   if (c == '.') c = seen_pointer[++i];
978
   if (c == '.') c = seen_pointer[++i];
978
   return (c >= '0' && c <= '9');
979
   return (c >= '0' && c <= '9');
5691
 
5692
 
5692
   // Sanitize the current command:
5693
   // Sanitize the current command:
5693
   //  - Skip leading spaces
5694
   //  - Skip leading spaces
5694
-  //  - Bypass N[0-9][0-9]*[ ]*
5695
+  //  - Bypass N[-0-9][0-9]*[ ]*
5695
   //  - Overwrite * with nul to mark the end
5696
   //  - Overwrite * with nul to mark the end
5696
   while (*current_command == ' ') ++current_command;
5697
   while (*current_command == ' ') ++current_command;
5697
   if (*current_command == 'N' && ((current_command[1] >= '0' && current_command[1] <= '9') || current_command[1] == '-')) {
5698
   if (*current_command == 'N' && ((current_command[1] >= '0' && current_command[1] <= '9') || current_command[1] == '-')) {
5716
   // Args pointer optimizes code_seen, especially those taking XYZEF
5717
   // Args pointer optimizes code_seen, especially those taking XYZEF
5717
   // This wastes a little cpu on commands that expect no arguments.
5718
   // This wastes a little cpu on commands that expect no arguments.
5718
   current_command_args = current_command;
5719
   current_command_args = current_command;
5719
-  while (*current_command_args && *current_command_args != ' ') ++current_command_args;
5720
+  while (*current_command_args >= '0' && *current_command_args <= '9') ++current_command_args;
5720
   while (*current_command_args == ' ') ++current_command_args;
5721
   while (*current_command_args == ' ') ++current_command_args;
5721
 
5722
 
5722
   // Interpret the code int
5723
   // Interpret the code int

正在加载...
取消
保存