From be78b3357018cdab58869bb83d0221ed17e4398b Mon Sep 17 00:00:00 2001 From: Dirk Zimoch Date: Fri, 16 Apr 2021 19:17:50 +0200 Subject: [PATCH] code streamlined --- modules/libcom/src/iocsh/iocsh.cpp | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/modules/libcom/src/iocsh/iocsh.cpp b/modules/libcom/src/iocsh/iocsh.cpp index 753dd2c23..69313bd5e 100644 --- a/modules/libcom/src/iocsh/iocsh.cpp +++ b/modules/libcom/src/iocsh/iocsh.cpp @@ -1126,27 +1126,26 @@ static void varHandler(const iocshVarDef *v, const char *setString) static void varCallFunc(const iocshArgBuf *args) { struct iocshVariable *v; - if(args[0].sval == NULL) { - for (v = iocshVariableHead ; v != NULL ; v = v->next) - varHandler(v->pVarDef, args[1].sval); - } - else if(args[1].sval == NULL) { + const char *name = args[0].sval; + const char *value = args[1].sval; + + if (!value) { int found = 0; for (v = iocshVariableHead ; v != NULL ; v = v->next) - if (epicsStrGlobMatch(v->pVarDef->name, args[0].sval) != 0) { + if (!name || epicsStrGlobMatch(v->pVarDef->name, name) != 0) { varHandler(v->pVarDef, NULL); found = 1; } - if (!found) - fprintf(epicsGetStderr(), "No var matching %s found.\n", args[0].sval); + if (!found && name != NULL) + fprintf(epicsGetStderr(), "No var matching %s found.\n", name); } else { v = (iocshVariable *)registryFind(iocshVarID, args[0].sval); if (v == NULL) { - fprintf(epicsGetStderr(), "Var %s not found.\n", args[0].sval); + fprintf(epicsGetStderr(), "Var %s not found.\n", name); } else { - varHandler(v->pVarDef, args[1].sval); + varHandler(v->pVarDef, value); } } }