- use Tcl library for splitting and merging argument lists

This commit is contained in:
zolliker
2011-08-29 14:41:23 +00:00
parent 1e23f3c7b4
commit 56523419b2
5 changed files with 85 additions and 125 deletions

View File

@ -293,7 +293,6 @@ int InterpExecute(SicsInterp * self, SConnection * pCon, char *pText)
commandContext comCon;
Statistics *old;
assert(self);
assert(pCon);
@ -312,9 +311,12 @@ int InterpExecute(SicsInterp * self, SConnection * pCon, char *pText)
}
/* convert to argc, argv */
argc = 0;
argv = NULL;
Text2Arg(pText, &argc, &argv);
/* use Tcl_SplitList instead of Text2Arg, is needed for complicated Tcl syntax. M.Z. 8.2011 */
iRet = Tcl_SplitList(self->pTcl, pText, &argc, (const char ***)&argv);
if (iRet != TCL_OK) {
SCWrite(pCon, "ERROR: illegal tcl syntax", eError);
return -1;
}
/* the first one must be the target object. If not given an empty
command string was given which will be silently ignored */
@ -364,15 +366,7 @@ int InterpExecute(SicsInterp * self, SConnection * pCon, char *pText)
deleteArgv:
if (argv) {
/* delete argv */
for (i = 0; i < argc; i++) {
if (argv[i] != NULL) {
free(argv[i]);
}
}
free(argv);
}
Tcl_Free((char *)argv);
return iRet;
}