Skip to content
Snippets Groups Projects
Commit 7f84cfd5 authored by benjamin.franksen's avatar benjamin.franksen
Browse files

seq: pvAssign now does macro substitution, like assign syntax

parent f4d4b832
No related branches found
No related tags found
No related merge requests found
......@@ -531,10 +531,11 @@ epicsShareFunc pvStat epicsShareAPI seq_pvAssign(SS_ID ss, VAR_ID varId, const c
CHAN *ch = sp->chan + varId;
pvStat status = pvStatOK;
DBCHAN *dbch = ch->dbch;
char new_pv_name[100];
if (!pvName) pvName = "";
seqMacEval(sp, pvName, new_pv_name, sizeof(new_pv_name));
DEBUG("Assign %s to \"%s\"\n", ch->varName, pvName);
DEBUG("Assign %s to \"%s\"\n", ch->varName, new_pv_name);
epicsMutexMustLock(sp->programLock);
......@@ -564,7 +565,7 @@ epicsShareFunc pvStat epicsShareAPI seq_pvAssign(SS_ID ss, VAR_ID varId, const c
free(dbch->dbName);
}
if (pvName == NULL || pvName[0] == 0) /* new name is empty -> free resources */
if (new_pv_name[0] == 0) /* new name is empty -> free resources */
{
if (dbch) {
free(ch->dbch->ssMetaData);
......@@ -582,7 +583,7 @@ epicsShareFunc pvStat epicsShareAPI seq_pvAssign(SS_ID ss, VAR_ID varId, const c
return pvStatERROR;
}
}
dbch->dbName = epicsStrDup(pvName);
dbch->dbName = epicsStrDup(new_pv_name);
if (!dbch->dbName)
{
errlogSevPrintf(errlogFatal, "pvAssign: epicsStrDup failed\n");
......
......@@ -37,8 +37,17 @@ void seqMacEval(SPROG *sp, const char *inStr, char *outStr, size_t maxChar)
char name[50], *value, *tmp;
size_t valLth, nameLth;
assert(outStr);
assert(maxChar > 0);
DEBUG("seqMacEval: InStr=%s, ", inStr);
if (!inStr)
{
*outStr = 0;
return;
}
tmp = outStr;
while (*inStr != 0 && maxChar > 0)
{
......@@ -56,7 +65,7 @@ void seqMacEval(SPROG *sp, const char *inStr, char *outStr, size_t maxChar)
name[nameLth] = 0;
if (*inStr != 0)
inStr++;
DEBUG("Macro name=%s, ", name);
/* Find macro value from macro name */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment