EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  <2024 Index 2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  <2024
<== Date ==> <== Thread ==>

Subject: [Bug 2052814] [NEW] dbLoadRecords with subs=NULL fails to expand macros with defaults
From: Dirk Zimoch via Core-talk <core-talk at aps.anl.gov>
To: core-talk at aps.anl.gov
Date: Fri, 09 Feb 2024 15:07:36 -0000
Public bug reported:

A template file that only contains macros with default values can be
loaded with `dbLoadRecords("file.db","")` but not with
`dbLoadRecords("file.db",NULL)`. In particular, in the startup script,
it cannot be loaded with `dbLoadRecords "file.db"` but only with
`dbLoadRecords "file.db",""`. (VxWorks shell as well as iocsh.)

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`.

** Affects: epics-base
     Importance: Undecided
         Status: New

** Description changed:

  A template file that only contains macros with default values can be
  loaded with `dbLoadRecords("file.db","")` but not with
  `dbLoadRecords("file.db",NULL)`. In particular, in the startup script,
  it cannot be loaded with `dbLoadRecords "file.db"` but only with
  `dbLoadRecords "file.db",""`. (VxWorks shell as well as iocsh.)
  
  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 it it
+ but not any more. A macro handle should always be created, even if it
  stays empty when `substitutions` is `NULL`.

-- 
You received this bug notification because you are a member of EPICS
Core Developers, which is subscribed to EPICS Base.
Matching subscriptions: epics-core-list-subscription
https://bugs.launchpad.net/bugs/2052814

Title:
  dbLoadRecords with subs=NULL fails to expand macros with defaults

Status in EPICS Base:
  New

Bug description:
  A template file that only contains macros with default values can be
  loaded with `dbLoadRecords("file.db","")` but not with
  `dbLoadRecords("file.db",NULL)`. In particular, in the startup script,
  it cannot be loaded with `dbLoadRecords "file.db"` but only with
  `dbLoadRecords "file.db",""`. (VxWorks shell as well as iocsh.)

  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`.

To manage notifications about this bug go to:
https://bugs.launchpad.net/epics-base/+bug/2052814/+subscriptions


Replies:
[Bug 2052814] Re: dbLoadRecords with subs=NULL fails to expand macros with defaults Andrew Johnson via Core-talk
[Bug 2052814] Re: dbLoadRecords with subs=NULL fails to expand macros with defaults Dirk Zimoch via Core-talk
[Bug 2052814] Re: dbLoadRecords with subs=NULL fails to expand macros with defaults Dirk Zimoch via Core-talk

Navigate by Date:
Prev: Re: pvget -M json is JSON5 Zimoch Dirk via Core-talk
Next: [Bug 2052814] Re: dbLoadRecords with subs=NULL fails to expand macros with defaults Andrew Johnson via Core-talk
Index: 2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  <2024
Navigate by Thread:
Prev: Re: pvget -M json is JSON5 Zimoch Dirk via Core-talk
Next: [Bug 2052814] Re: dbLoadRecords with subs=NULL fails to expand macros with defaults Andrew Johnson via Core-talk
Index: 2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  <2024
ANJ, 19 Feb 2024 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·