mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-14 20:10:18 +03:00
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
This commit is contained in:
parent
6056ee1740
commit
0e051bebb2
2 changed files with 3 additions and 11 deletions
|
@ -208,16 +208,6 @@ static const char * const *sensorHardwareNames[] = {
|
||||||
};
|
};
|
||||||
#endif // USE_SENSOR_NAMES
|
#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)
|
static void cliPrint(const char *str)
|
||||||
{
|
{
|
||||||
while (*str) {
|
while (*str) {
|
||||||
|
@ -2838,7 +2828,7 @@ STATIC_UNIT_TESTED void cliGet(char *cmdline)
|
||||||
int matchedCommands = 0;
|
int matchedCommands = 0;
|
||||||
|
|
||||||
for (uint32_t i = 0; i < valueTableEntryCount; i++) {
|
for (uint32_t i = 0; i < valueTableEntryCount; i++) {
|
||||||
if (strstr(valueTable[i].name, cliStringToLowercase(cmdline))) {
|
if (strcasestr(valueTable[i].name, cmdline)) {
|
||||||
val = &valueTable[i];
|
val = &valueTable[i];
|
||||||
cliPrintf("%s = ", valueTable[i].name);
|
cliPrintf("%s = ", valueTable[i].name);
|
||||||
cliPrintVar(val, 0);
|
cliPrintVar(val, 0);
|
||||||
|
|
|
@ -350,6 +350,8 @@ COVERAGE_FLAGS := --coverage
|
||||||
C_FLAGS += $(COVERAGE_FLAGS)
|
C_FLAGS += $(COVERAGE_FLAGS)
|
||||||
CXX_FLAGS += $(COVERAGE_FLAGS)
|
CXX_FLAGS += $(COVERAGE_FLAGS)
|
||||||
|
|
||||||
|
C_FLAGS += -D_GNU_SOURCE
|
||||||
|
|
||||||
# Set up the parameter group linker flags according to OS
|
# Set up the parameter group linker flags according to OS
|
||||||
ifdef MACOSX
|
ifdef MACOSX
|
||||||
LDFLAGS += -Wl,-map,$(OBJECT_DIR)/$@.map
|
LDFLAGS += -Wl,-map,$(OBJECT_DIR)/$@.map
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue