From 1d6fcd46d653934da0e28c0df98a083e7620feb2 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Thu, 26 Mar 2020 16:31:10 -0500 Subject: [PATCH] Adjust RELEASE file variable name recognition I was asked to support the use of hyphens `-` in names. --- documentation/RELEASE_NOTES.md | 24 +++++++++++++++++++++-- src/tools/EPICS/Release.pm | 35 ++++++++++++++++++---------------- 2 files changed, 41 insertions(+), 18 deletions(-) diff --git a/documentation/RELEASE_NOTES.md b/documentation/RELEASE_NOTES.md index bdd246857..781cce4db 100644 --- a/documentation/RELEASE_NOTES.md +++ b/documentation/RELEASE_NOTES.md @@ -12,12 +12,32 @@ The external PVA submodules each have their own separate set of release notes which should also be read to understand what has changed since an earlier release. -## EPICS Release 7.x.y.z +## EPICS Release 7.0.3.2 + +### Variable names in RELEASE files + +`configure/RELEASE` files are parsed by both GNUmake and the `convertRelease.pl` +script. While GNUmake is quite relaxed about what characters may be used in a +RELEASE variable name, the `convertRelease.pl` script parser has only recognized +variable names that match the Perl regular expression `\w+`, i.e. upper and +lower-case letters, digits and underscore characters. + +The script has been modified so now RELEASE variable names must start with a +letter or underscore, and be followed by any number of letters, digits, +underscore or hyphen characters, matching the regular expression +`[A-Za-z_][A-Za-z_0-9-]*`. The hyphen character `-` was not previously allowed +and if used would have prevented a build from finding include files and +libraries in any module using that in its RELEASE variable name. + +This change does disallow names that start with a digit which used to be +allowed, but hopefully nobody has been relying on that ability. The regular +expression used for names can be found in the file `src/tools/EPICS/Release.pm` +and can be adjusted locally if necessary. ### caRepeater /dev/null On *NIX targets caRepeater will now partially daemonize by redirecting -stdin/out/err with /dev/null. This prevents caRepeater from inheriting +stdin/out/err to /dev/null. This prevents caRepeater from inheriting the stdin/out of a process, like caget, which has spawned it in the background. This has been known to cause problems in some cases when caget is itself being run from a shell script. diff --git a/src/tools/EPICS/Release.pm b/src/tools/EPICS/Release.pm index 6ae0dbd9a..b7135b20c 100644 --- a/src/tools/EPICS/Release.pm +++ b/src/tools/EPICS/Release.pm @@ -5,6 +5,9 @@ # in file LICENSE that is included with this distribution. #************************************************************************* +# Regex to recognize variable names allowed in a RELEASE file +my $MVAR = qr/[A-Za-z_] [A-Za-z_0-9-]*/x; + # # Parse all relevent configure/RELEASE* files and includes # @@ -58,17 +61,17 @@ sub readRelease { s/ \s+ $//x; # Remove trailing whitespace next if m/^ \s* $/x; # Skip blank lines - # Handle " = " plus the := and ?= variants - my ($macro, $op, $val) = m/^ \s* (\w+) \s* ([?:]?=) \s* (.*) /x; - if ($macro ne '') { - $macro = 'TOP' if $macro =~ m/^ INSTALL_LOCATION /x; - if (exists $Rmacros->{$macro}) { + # Handle " = " plus the := and ?= variants + my ($var, $op, $val) = m/^ \s* ($MVAR) \s* ([?:]?=) \s* (.*) /x; + if ($var ne '') { + $var = 'TOP' if $var =~ m/^ INSTALL_LOCATION /x; + if (exists $Rmacros->{$var}) { next if $op eq '?='; } else { - push @$Rapps, $macro; + push @$Rapps, $var; } $val = expandMacros($val, $Rmacros) if $op eq ':='; - $Rmacros->{$macro} = $val; + $Rmacros->{$var} = $val; next; } # Handle "include " and "-include " syntax @@ -85,13 +88,13 @@ sub readRelease { } # -# Expand all (possibly nested) macros in a string +# Expand all (possibly nested) variables in a string # sub expandMacros { my ($str, $Rmacros) = @_; # $Rmacros is a reference to a hash - while (my ($pre, $var, $post) = $str =~ m/ (.*) \$\( (\w+) \) (.*) /x) { + while (my ($pre, $var, $post) = $str =~ m/ (.*) \$\( ($MVAR) \) (.*) /x) { last unless exists $Rmacros->{$var}; $str = $pre . $Rmacros->{$var} . $post; } @@ -99,21 +102,21 @@ sub expandMacros { } # -# Expand all (possibly nested) macros in a dictionary +# Expand all (possibly nested) variables in a dictionary # sub expandRelease { my ($Rmacros, $warn) = @_; # $Rmacros is a reference to a hash $warn = '' unless defined $warn; - while (my ($macro, $val) = each %$Rmacros) { - while (my ($pre,$var,$post) = $val =~ m/ (.*) \$\( (\w+) \) (.*) /x) { - warn "EPICS/Release.pm: Undefined macro \$($var) used $warn\n" + while (my ($relvar, $val) = each %$Rmacros) { + while (my ($pre,$var,$post) = $val =~ m/ (.*) \$\( ($MVAR) \) (.*) /x) { + warn "EPICS/Release.pm: Undefined variable \$($var) used $warn\n" unless exists $Rmacros->{$var}; - die "EPICS/Release.pm: Circular definition of macro $var $warn\n" - if $macro eq $var; + die "EPICS/Release.pm: Circular definition of variable $var $warn\n" + if $relvar eq $var; $val = $pre . $Rmacros->{$var} . $post; - $Rmacros->{$macro} = $val; + $Rmacros->{$relvar} = $val; } } }