dbLoadRecords with subs=NULL fails to expand macros with defaults
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
EPICS Base |
Confirmed
|
Undecided
|
Unassigned |
Bug Description
A template file that only contains macros with default values can be loaded with `dbLoadRecords(
Using such a macro in a record name results in the error message:
ERROR: Bad character '$' in Record/Alias name "$(P=)Name"
Using macros with defaults in fields shows error messages like this:
ERRORName.PREC Has unexpanded macro
Can't set "Name.PREC" to "$(PREC=3)" : Bad Field value
ERRORERROR failed to load 'file.db'
(Unrelated: Someone please fix the missing blanks after ERROR and the ERRORERROR.)
The reason is that `dbReadCOM`, the function that does the real work, only creates a `macHandle` when `substitutions` is not `NULL`. Not having a `macHandle` prevents any macro substitution from working, even those which provide a default value.
In the old times, when macros could not have defaults, this was fine, but not any more. A macro handle should always be created, even if it stays empty when `substitutions` is `NULL`.
description: | updated |
Hi Dirk, I know we probably haven’t changed the instructions somewhere (feel free to point out where if you know), but other than the emails that Launchpad sends out we don’t often look at bug reports on Launchpad now, please file new bugs EPICS Base on GitHub instead of here.
I saw this exact same issue myself a few weeks ago so I agree that it’s a bug that has a fairly easy fix (remove the conditional check and always call the macLib expansion routine). If you’d like to post a PR on GitHub that would be great; I might get around to it at some point if/when I look at the bugs here, but it’s a lower priority for me than my APS Upgrade project work, so I’d welcome your help.
Thanks,
- Andrew