|
@@ -167,7 +167,7 @@ void GCodeParser::parse(char *p) {
|
167
|
167
|
* For 'M118' you must use 'E1' and 'A1' rather than just 'E' or 'A'
|
168
|
168
|
*/
|
169
|
169
|
string_arg = NULL;
|
170
|
|
- while (char code = *p++) { // Get the next parameter. A NUL ends the loop
|
|
170
|
+ while (const char code = *p++) { // Get the next parameter. A NUL ends the loop
|
171
|
171
|
|
172
|
172
|
// Special handling for M32 [P] !/path/to/file.g#
|
173
|
173
|
// The path must be the last parameter
|
|
@@ -188,12 +188,20 @@ void GCodeParser::parse(char *p) {
|
188
|
188
|
if (PARAM_TEST) {
|
189
|
189
|
|
190
|
190
|
while (*p == ' ') p++; // Skip spaces between parameters & values
|
191
|
|
- const bool has_num = DECIMAL_SIGNED(*p); // The parameter has a number [-+0-9.]
|
|
191
|
+
|
|
192
|
+ const bool has_num = NUMERIC(p[0]) // [0-9]
|
|
193
|
+ || (p[0] == '.' && NUMERIC(p[1])) // .[0-9]
|
|
194
|
+ || (
|
|
195
|
+ (p[0] == '-' || p[0] == '+') && ( // [-+]
|
|
196
|
+ NUMERIC(p[1]) // [0-9]
|
|
197
|
+ || (p[1] == '.' && NUMERIC(p[2])) // .[0-9]
|
|
198
|
+ )
|
|
199
|
+ );
|
192
|
200
|
|
193
|
201
|
#if ENABLED(DEBUG_GCODE_PARSER)
|
194
|
202
|
if (debug) {
|
195
|
|
- SERIAL_ECHOPAIR("Got letter ", code); // DEBUG
|
196
|
|
- SERIAL_ECHOPAIR(" at index ", (int)(p - command_ptr - 1)); // DEBUG
|
|
203
|
+ SERIAL_ECHOPAIR("Got letter ", code);
|
|
204
|
+ SERIAL_ECHOPAIR(" at index ", (int)(p - command_ptr - 1));
|
197
|
205
|
if (has_num) SERIAL_ECHOPGM(" (has_num)");
|
198
|
206
|
}
|
199
|
207
|
#endif
|
|
@@ -210,11 +218,13 @@ void GCodeParser::parse(char *p) {
|
210
|
218
|
#endif
|
211
|
219
|
|
212
|
220
|
#if ENABLED(FASTER_GCODE_PARSER)
|
|
221
|
+ {
|
213
|
222
|
set(code, has_num ? p : NULL // Set parameter exists and pointer (NULL for no number)
|
214
|
223
|
#if ENABLED(DEBUG_GCODE_PARSER)
|
215
|
224
|
, debug
|
216
|
225
|
#endif
|
217
|
226
|
);
|
|
227
|
+ }
|
218
|
228
|
#endif
|
219
|
229
|
}
|
220
|
230
|
else if (!string_arg) { // Not A-Z? First time, keep as the string_arg
|
|
@@ -224,8 +234,8 @@ void GCodeParser::parse(char *p) {
|
224
|
234
|
#endif
|
225
|
235
|
}
|
226
|
236
|
|
227
|
|
- if (!WITHIN(*p, 'A', 'Z')) {
|
228
|
|
- while (*p && NUMERIC(*p)) p++; // Skip over the value section of a parameter
|
|
237
|
+ if (!WITHIN(*p, 'A', 'Z')) { // Another parameter right away?
|
|
238
|
+ while (*p && DECIMAL_SIGNED(*p)) p++; // Skip over the value section of a parameter
|
229
|
239
|
while (*p == ' ') p++; // Skip over all spaces
|
230
|
240
|
}
|
231
|
241
|
}
|