Skip to content

Commit

Permalink
Merge pull request #2987 from thinkyhead/gcode_allow_no_initial_space
Browse files Browse the repository at this point in the history
Fix handling of spaces in GCode
  • Loading branch information
thinkyhead committed Feb 17, 2016
2 parents f3f58bd + 711e5db commit 7f30f85
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Marlin/Marlin_main.cpp
Expand Up @@ -973,6 +973,7 @@ void get_command() {
bool code_has_value() {
int i = 1;
char c = seen_pointer[i];
while (c == ' ') c = seen_pointer[++i];
if (c == '-' || c == '+') c = seen_pointer[++i];
if (c == '.') c = seen_pointer[++i];
return (c >= '0' && c <= '9');
Expand Down Expand Up @@ -5691,7 +5692,7 @@ void process_next_command() {

// Sanitize the current command:
// - Skip leading spaces
// - Bypass N[0-9][0-9]*[ ]*
// - Bypass N[-0-9][0-9]*[ ]*
// - Overwrite * with nul to mark the end
while (*current_command == ' ') ++current_command;
if (*current_command == 'N' && ((current_command[1] >= '0' && current_command[1] <= '9') || current_command[1] == '-')) {
Expand All @@ -5716,7 +5717,7 @@ void process_next_command() {
// Args pointer optimizes code_seen, especially those taking XYZEF
// This wastes a little cpu on commands that expect no arguments.
current_command_args = current_command;
while (*current_command_args && *current_command_args != ' ') ++current_command_args;
while (*current_command_args >= '0' && *current_command_args <= '9') ++current_command_args;
while (*current_command_args == ' ') ++current_command_args;

// Interpret the code int
Expand Down

0 comments on commit 7f30f85

Please sign in to comment.