From 0e051bebb29716a3723e81c69dca4f687eb99a5c Mon Sep 17 00:00:00 2001 From: etracer65 Date: Thu, 15 Mar 2018 14:41:00 -0400 Subject: [PATCH] Simplify CLI case-insensitive by using new strcasestr() (#5449) Remove string lowercase function from cli.c and use the new strcasestr() added to string_light.c --- src/main/interface/cli.c | 12 +----------- src/test/Makefile | 2 ++ 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/src/main/interface/cli.c b/src/main/interface/cli.c index 80162d7bd4..5e18f0e091 100644 --- a/src/main/interface/cli.c +++ b/src/main/interface/cli.c @@ -208,16 +208,6 @@ static const char * const *sensorHardwareNames[] = { }; #endif // USE_SENSOR_NAMES -static char *cliStringToLowercase(char *str) -{ - char *s = str; - while (*s) { - *s = tolower((unsigned char)*s); - s++; - } - return str; -} - static void cliPrint(const char *str) { while (*str) { @@ -2838,7 +2828,7 @@ STATIC_UNIT_TESTED void cliGet(char *cmdline) int matchedCommands = 0; for (uint32_t i = 0; i < valueTableEntryCount; i++) { - if (strstr(valueTable[i].name, cliStringToLowercase(cmdline))) { + if (strcasestr(valueTable[i].name, cmdline)) { val = &valueTable[i]; cliPrintf("%s = ", valueTable[i].name); cliPrintVar(val, 0); diff --git a/src/test/Makefile b/src/test/Makefile index 34409ac110..6566b7244b 100644 --- a/src/test/Makefile +++ b/src/test/Makefile @@ -350,6 +350,8 @@ COVERAGE_FLAGS := --coverage C_FLAGS += $(COVERAGE_FLAGS) CXX_FLAGS += $(COVERAGE_FLAGS) +C_FLAGS += -D_GNU_SOURCE + # Set up the parameter group linker flags according to OS ifdef MACOSX LDFLAGS += -Wl,-map,$(OBJECT_DIR)/$@.map