From 632344bd9b3df61230a26671720374fa692ffefb Mon Sep 17 00:00:00 2001 From: Mitch Bradley Date: Sat, 22 May 2021 14:56:46 -1000 Subject: [PATCH] Fixed parser name match bug "direction_delay_ms" matched "direction" --- Grbl_Esp32/src/Configuration/Parser.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Grbl_Esp32/src/Configuration/Parser.h b/Grbl_Esp32/src/Configuration/Parser.h index 8ae169e0..30061bfd 100644 --- a/Grbl_Esp32/src/Configuration/Parser.h +++ b/Grbl_Esp32/src/Configuration/Parser.h @@ -38,8 +38,15 @@ namespace Configuration { void enter(); void leave(); - inline bool is(const char* expected) const { - return current_.keyStart_ != nullptr && !strncmp(expected, current_.keyStart_, size_t(current_.keyEnd_ - current_.keyStart_)); + bool is(const char* expected) const { + if (current_.keyStart_ == nullptr) { + return false; + } + auto len = strlen(expected); + if (len != (current_.keyEnd_ - current_.keyStart_)) { + return false; + } + return !strncmp(expected, current_.keyStart_, len); } inline StringRange key() const { return StringRange(current_.keyStart_, current_.keyEnd_); }