mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-15 04:15:44 +03:00
Allow the use of NULL values in CLI lookup tables. (#5489)
This commit is contained in:
parent
3a917a3755
commit
09f52d420d
1 changed files with 8 additions and 5 deletions
|
@ -489,10 +489,13 @@ static void cliPrintVarRange(const clivalue_t *var)
|
||||||
case (MODE_LOOKUP): {
|
case (MODE_LOOKUP): {
|
||||||
const lookupTableEntry_t *tableEntry = &lookupTables[var->config.lookup.tableIndex];
|
const lookupTableEntry_t *tableEntry = &lookupTables[var->config.lookup.tableIndex];
|
||||||
cliPrint("Allowed values:");
|
cliPrint("Allowed values:");
|
||||||
for (uint32_t i = 0; i < tableEntry->valueCount ; i++) {
|
for (uint32_t i = 0; i < tableEntry->valueCount; i++) {
|
||||||
if (i > 0)
|
if (tableEntry->values[i]) {
|
||||||
cliPrint(",");
|
cliPrintf(" %s", tableEntry->values[i]);
|
||||||
cliPrintf(" %s", tableEntry->values[i]);
|
if (i + 1 < tableEntry->valueCount) {
|
||||||
|
cliPrint(",");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
cliPrintLinefeed();
|
cliPrintLinefeed();
|
||||||
}
|
}
|
||||||
|
@ -2965,7 +2968,7 @@ STATIC_UNIT_TESTED void cliSet(char *cmdline)
|
||||||
const lookupTableEntry_t *tableEntry = &lookupTables[val->config.lookup.tableIndex];
|
const lookupTableEntry_t *tableEntry = &lookupTables[val->config.lookup.tableIndex];
|
||||||
bool matched = false;
|
bool matched = false;
|
||||||
for (uint32_t tableValueIndex = 0; tableValueIndex < tableEntry->valueCount && !matched; tableValueIndex++) {
|
for (uint32_t tableValueIndex = 0; tableValueIndex < tableEntry->valueCount && !matched; tableValueIndex++) {
|
||||||
matched = strcasecmp(tableEntry->values[tableValueIndex], eqptr) == 0;
|
matched = tableEntry->values[tableValueIndex] && strcasecmp(tableEntry->values[tableValueIndex], eqptr) == 0;
|
||||||
|
|
||||||
if (matched) {
|
if (matched) {
|
||||||
value = tableValueIndex;
|
value = tableValueIndex;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue