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