|
@@ -166,7 +166,6 @@ public:
|
166
|
166
|
#ifdef CPU_32_BIT
|
167
|
167
|
FORCE_INLINE static bool seen(const char * const str) { return !!(codebits & letter_bits(str)); }
|
168
|
168
|
#else
|
169
|
|
- // At least one of a list of code letters was seen
|
170
|
169
|
FORCE_INLINE static bool seen(const char * const str) {
|
171
|
170
|
const uint32_t letrbits = letter_bits(str);
|
172
|
171
|
const uint8_t * const cb = (uint8_t*)&codebits;
|
|
@@ -177,14 +176,27 @@ public:
|
177
|
176
|
|
178
|
177
|
static inline bool seen_any() { return !!codebits; }
|
179
|
178
|
|
180
|
|
- #define SEEN_TEST(L) TEST32(codebits, LETTER_BIT(L))
|
|
179
|
+ FORCE_INLINE static bool seen_test(const char c) { return TEST32(codebits, LETTER_BIT(c)); }
|
181
|
180
|
|
182
|
181
|
#else // !FASTER_GCODE_PARSER
|
183
|
182
|
|
|
183
|
+ #if ENABLED(GCODE_CASE_INSENSITIVE)
|
|
184
|
+ FORCE_INLINE static char* strgchr(char *p, char g) {
|
|
185
|
+ auto uppercase = [](char c) {
|
|
186
|
+ return c + (WITHIN(c, 'a', 'z') ? 'A' - 'a' : 0);
|
|
187
|
+ };
|
|
188
|
+ const char d = uppercase(g);
|
|
189
|
+ for (char cc; (cc = uppercase(*p)); p++) if (cc == d) return p;
|
|
190
|
+ return nullptr;
|
|
191
|
+ }
|
|
192
|
+ #else
|
|
193
|
+ #define strgchr strchr
|
|
194
|
+ #endif
|
|
195
|
+
|
184
|
196
|
// Code is found in the string. If not found, value_ptr is unchanged.
|
185
|
197
|
// This allows "if (seen('A')||seen('B'))" to use the last-found value.
|
186
|
198
|
static inline bool seen(const char c) {
|
187
|
|
- char *p = strchr(command_args, c);
|
|
199
|
+ char *p = strgchr(command_args, c);
|
188
|
200
|
const bool b = !!p;
|
189
|
201
|
if (b) value_ptr = valid_float(&p[1]) ? &p[1] : nullptr;
|
190
|
202
|
return b;
|
|
@@ -192,12 +204,12 @@ public:
|
192
|
204
|
|
193
|
205
|
static inline bool seen_any() { return *command_args == '\0'; }
|
194
|
206
|
|
195
|
|
- #define SEEN_TEST(L) !!strchr(command_args, L)
|
|
207
|
+ FORCE_INLINE static bool seen_test(const char c) { return (bool)strgchr(command_args, c); }
|
196
|
208
|
|
197
|
209
|
// At least one of a list of code letters was seen
|
198
|
210
|
static inline bool seen(const char * const str) {
|
199
|
211
|
for (uint8_t i = 0; const char c = str[i]; i++)
|
200
|
|
- if (SEEN_TEST(c)) return true;
|
|
212
|
+ if (seen_test(c)) return true;
|
201
|
213
|
return false;
|
202
|
214
|
}
|
203
|
215
|
|
|
@@ -205,7 +217,7 @@ public:
|
205
|
217
|
|
206
|
218
|
// Seen any axis parameter
|
207
|
219
|
static inline bool seen_axis() {
|
208
|
|
- return SEEN_TEST('X') || SEEN_TEST('Y') || SEEN_TEST('Z') || SEEN_TEST('E');
|
|
220
|
+ return seen_test('X') || seen_test('Y') || seen_test('Z') || seen_test('E');
|
209
|
221
|
}
|
210
|
222
|
|
211
|
223
|
#if ENABLED(GCODE_QUOTED_STRINGS)
|