From 5a0f7a0e7246ae8b69a8a0d59937026094322a08 Mon Sep 17 00:00:00 2001 From: Markus Hitter Date: Fri, 3 Jul 2015 01:19:17 +0200 Subject: [PATCH] G-code parser: anything but a number ends a field. This should make the parser a bit more robust and also saves 6 bytes binary size. --- gcode_parse.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/gcode_parse.c b/gcode_parse.c index 81588cd..0ea6c2d 100644 --- a/gcode_parse.c +++ b/gcode_parse.c @@ -124,8 +124,7 @@ void gcode_parse_char(uint8_t c) { next_target.read_string == 0 ) { // Check if the field has ended. Either by a new field, space or EOL. - if (last_field && ((c >= 'A' && c <= 'Z') || c == '*' || c == ' ' || - c == '\r' || c == '\n')) { + if (last_field && (c < '0' || c > '9') && c != '.') { switch (last_field) { case 'G': next_target.G = read_digit.mantissa;