Fixed 'showdefaults' option for CLI 'dump' / 'diff'.

This commit is contained in:
mikeller 2017-04-07 00:19:51 +12:00
parent 411ffe06a8
commit 2afc011b16
1 changed files with 9 additions and 9 deletions

View File

@ -1407,26 +1407,26 @@ static void *getValuePointer(const clivalue_t *value)
static void dumpPgValue(const clivalue_t *value, uint8_t dumpMask) static void dumpPgValue(const clivalue_t *value, uint8_t dumpMask)
{ {
const char *format = "set %s = ";
const cliCurrentAndDefaultConfig_t *config = getCurrentAndDefaultConfigs(value->pgn); const cliCurrentAndDefaultConfig_t *config = getCurrentAndDefaultConfigs(value->pgn);
if (config->currentConfig == NULL || config->defaultConfig == NULL) { if (config->currentConfig == NULL || config->defaultConfig == NULL) {
// has not been set up properly // has not been set up properly
cliPrintf("VALUE %s ERROR\r\n", value->name); cliPrintf("VALUE %s ERROR\r\n", value->name);
return; return;
} }
const char *format = "set %s = ";
const char *defaultFormat = "#set %s = ";
const int valueOffset = getValueOffset(value); const int valueOffset = getValueOffset(value);
switch (dumpMask & (DO_DIFF | SHOW_DEFAULTS)) { const bool equalsDefault = valuePtrEqualsDefault(value->type, (uint8_t*)config->currentConfig + valueOffset, (uint8_t*)config->defaultConfig + valueOffset);
case DO_DIFF: if (((dumpMask & DO_DIFF) == 0) || !equalsDefault) {
if (valuePtrEqualsDefault(value->type, (uint8_t*)config->currentConfig + valueOffset, (uint8_t*)config->defaultConfig + valueOffset)) { if (dumpMask & SHOW_DEFAULTS && !equalsDefault) {
break; cliPrintf(defaultFormat, value->name);
printValuePointer(value, (uint8_t*)config->defaultConfig + valueOffset, 0);
cliPrint("\r\n");
} }
// drop through, since not equal to default
case 0:
case SHOW_DEFAULTS:
cliPrintf(format, value->name); cliPrintf(format, value->name);
printValuePointer(value, (uint8_t*)config->currentConfig + valueOffset, 0); printValuePointer(value, (uint8_t*)config->currentConfig + valueOffset, 0);
cliPrint("\r\n"); cliPrint("\r\n");
break;
} }
} }