Updated iocshBody to keep track of macro context to allow scoping of macro variables from iocshRun/Load

This commit is contained in:
Keenan Lang
2014-08-27 11:33:14 -05:00
parent 00bb3d1e67
commit 2d3db2036b
3 changed files with 69 additions and 26 deletions
+13 -16
View File
@@ -25,29 +25,23 @@ macEnvExpand(const char *str)
}
char * epicsShareAPI
macDefExpand(const char *str, const char *macros)
macDefExpand(const char *str, MAC_HANDLE *macros)
{
MAC_HANDLE *handle;
static char *pairs[] = { "", "environ", NULL, NULL };
char** defines;
long destCapacity = 128;
char *dest = NULL;
int n;
if (macCreateHandle(&handle, pairs)){
errlogMessage("macDefExpand: macCreateHandle failed.");
return NULL;
}
if (macros) {
if (macParseDefns(handle, macros, &defines) < 0) {
cantProceed("macDefExpand: invalid macro string");
}
else {
macInstallMacros(handle, defines);
handle = macros;
} else {
if (macCreateHandle(&handle, pairs)){
errlogMessage("macDefExpand: macCreateHandle failed.");
return NULL;
}
}
do {
destCapacity *= 2;
/*
@@ -73,7 +67,10 @@ macDefExpand(const char *str, const char *macros)
}
done:
if (macDeleteHandle(handle))
errlogMessage("macDefExpand: macDeleteHandle failed.");
if (macros == NULL) {
if (macDeleteHandle(handle)) {
errlogMessage("macDefExpand: macDeleteHandle failed.");
}
}
return dest;
}
+2 -1
View File
@@ -154,7 +154,8 @@ epicsShareAPI macEnvExpand(
epicsShareFunc char * /* expanded string; NULL if any undefined macros */
epicsShareAPI macDefExpand(
const char *str, /* string to be expanded */
const char *macros /* macro definitions in "a=xxx, b=yyy" */
MAC_HANDLE *macros /* opaque handle; can be NULL if default */
/* special characters are to be used */
);
#ifdef __cplusplus