- minor improvements

This commit is contained in:
zolliker
2009-11-10 10:38:48 +00:00
parent 7e10c5e296
commit 1c6c3c603e
4 changed files with 38 additions and 9 deletions

View File

@@ -1776,7 +1776,8 @@ int ProcessSICSHdbPar(pHdb root, SConnection * pCon,
pHdb parNode = NULL;
pDynString parData = NULL;
char error[512];
int i, status;
int i, status, firstValueArg;
float value;
assert(root != NULL && pCon != NULL);
@@ -1785,7 +1786,18 @@ int ProcessSICSHdbPar(pHdb root, SConnection * pCon,
return -1;
}
parNode = GetHipadabaNode(root, argv[0]);
/* if the single argument is a number and the type of the root is a number
then we want to set the root itself to this number */
if (argc == 1
&& (root->value.dataType == HIPINT || root->value.dataType == HIPFLOAT)
&& sscanf(argv[0], "%f", &value) == 1) {
parNode = root;
firstValueArg = 0;
} else {
parNode = GetHipadabaNode(root, argv[0]);
firstValueArg = 1;
}
if (parNode == NULL) {
/* no error reporting here, upper level code might wish to continue
* processing commands after having tested for parameters.
@@ -1793,7 +1805,7 @@ int ProcessSICSHdbPar(pHdb root, SConnection * pCon,
return -1;
}
if (argc > 1) {
if (argc > firstValueArg) {
/*
* setting the value is attempted.
*/
@@ -1805,8 +1817,8 @@ int ProcessSICSHdbPar(pHdb root, SConnection * pCon,
SCWrite(pCon, "ERROR: out of memory processing parameter", eError);
return 0;
}
DynStringConcat(parData, argv[1]);
for (i = 2; i < argc; i++) {
DynStringConcat(parData, argv[firstValueArg]);
for (i = firstValueArg + 1; i < argc; i++) {
DynStringConcat(parData, " ");
DynStringConcat(parData, argv[i]);
}