Updated iocshBody to keep track of macro context to allow scoping of macro variables from iocshRun/Load
This commit is contained in:
+13
-16
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user