editable serial input line buffer

Dependents:   MAX5715BOB_Tester MAX11131BOB_Tester MAX5171BOB_Tester MAX11410BOB_Tester ... more

Revision:
11:e8a4162d4fd1
Parent:
10:3e2ff983be1c
Child:
12:447a747099e6
--- a/CmdLine.cpp	Wed Nov 13 16:04:28 2019 -0800
+++ b/CmdLine.cpp	Mon Nov 25 02:20:43 2019 -0800
@@ -328,9 +328,11 @@
             return false; /* no match */
         }
         if (match_is_case_sensitive) {
+            // case-sensitive string comparison
             if (buf[idxSearch] != key[0]) { continue; }
         }
         else {
+            // case-insensitive string comparison using toupper()
             if (toupper(buf[idxSearch]) != toupper(key[0])) { continue; }
         }
         // possible match; compare buf[idxSearch..] to key[0..]
@@ -339,7 +341,14 @@
         unsigned int idxSpace = idxSearch; // end of key=value word
         for (unsigned int offset = 0; offset < strlen(key); offset++)
         {
-            if (buf[idxKey + offset] != key[offset]) { idxKey = 0; break; }
+            if (match_is_case_sensitive) {
+                // case-sensitive string comparison
+                if (buf[idxKey + offset] != key[offset]) { idxKey = 0; break; }
+            }
+            else {
+                // case-insensitive string comparison using toupper()
+                if (toupper(buf[idxKey + offset]) != toupper(key[offset])) { idxKey = 0; break; }
+            }
             idxSpace = idxKey + offset + 1;  // assume next char is a word break
             idxSeparator = idxKey + offset + 1; // assume next char is a separator
             if ((buf[idxSeparator] != '=') && (buf[idxSeparator] != '?')) { idxSeparator = 0; }