From f5722273aa1208c80d05207e71631a96e2c13dee Mon Sep 17 00:00:00 2001 From: Bruce Luckcuck Date: Tue, 7 May 2019 16:01:50 -0400 Subject: [PATCH] Fix MODE_STRING blank value output and improve validation messages Emptry MODE_STRING paramaters would produce CLI output that would then generate errors if reapplied using a `diff` or `dump`. Fixed the output for blank values to be compatible with setting an empty string (clearing a previous value). Also improve the length validation to report the allowed character range. --- src/main/cli/cli.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/cli/cli.c b/src/main/cli/cli.c index ad365711e1..112e69c661 100644 --- a/src/main/cli/cli.c +++ b/src/main/cli/cli.c @@ -542,7 +542,7 @@ static void printValuePointer(const clivalue_t *var, const void *valuePointer, b } break; case MODE_STRING: - cliPrintf("%s", (char *)valuePointer); + cliPrintf("%s", (strlen((char *)valuePointer) == 0) ? "-" : (char *)valuePointer); break; } @@ -4162,6 +4162,8 @@ STATIC_UNIT_TESTED void cliSet(char *cmdline) strncpy((char *)cliGetValuePointer(val), valPtr, len); } valueChanged = true; + } else { + cliPrintErrorLinef("STRING MUST BE 1-%d CHARACTERS OR '-' FOR EMPTY", max); } } break;