diff --git a/App/tools/expandDBD.pl b/App/tools/expandDBD.pl index d95df85..05aafeb 100755 --- a/App/tools/expandDBD.pl +++ b/App/tools/expandDBD.pl @@ -7,7 +7,7 @@ use 5.010; use File::Basename qw/basename/; use File::Spec::Functions qw/catfile/; -my $epicsversion = 3.14; +my $epicsversion = 0x030E0000; # 3.14 my $quiet = 0; my @searchpath = (); my %filesDone = (); @@ -15,13 +15,30 @@ my @filesInput = (); while (@ARGV) { my $arg = shift @ARGV; - if ($arg =~ /^-\d/) { $epicsversion = substr($arg, 1); } + if ($arg =~ /^-(\d+(.\d+){0,3})$/) { $epicsversion = parseVersion($1); } elsif ($arg eq "-q") { $quiet = 1; } elsif ($arg =~ /^-I$/) { push @searchpath, shift @ARGV; } elsif ($arg =~ /^-I(.*)$/) { push @searchpath, $1; } else { push @filesInput, $arg; } } +## +## Convert version string of version.revision.modification.patch format +## to integer format 0Xvvrrmmpp (in hexadecimal) +## 3.14.12.8 -> 0x030E0C08 +## 7.0.3 -> 0x07000300 +## This requires all parts of version number are in range 0-255, +## which is true for EPICS base version number. +## +sub parseVersion { + my @vi = split(/\./, shift); # version integers list + my $vh = 0; # hexadecimal version + foreach my $i (0..$#vi) { + $vh |= $vi[$i] << (8 * (3-$i)); + } + return $vh; +} + ## ## Search given dbd file from @searchpath list. ## If it is not found, return the file name as it is. @@ -87,10 +104,10 @@ sub scanfile { return 0 unless scanfile($1, $name, $n); } elsif (/(registrar|variable|function)[ \t]*\([ \t]*"?([a-zA-Z0-9_]+)"?[ \t]*\)/) { - say "$1($2)" if $epicsversion gt 3.13; + say "$1($2)" if $epicsversion > 0x030D0000; # 3.13 } elsif (/variable[ \t]*\([ \t]*"?([a-zA-Z0-9_]+)"?[ \t]*,[ \t]*"?([a-zA-Z0-9_]+)"?[ \t]*\)/) { - say "variable($1,$2)" if $epicsversion gt 3.13; + say "variable($1,$2)" if $epicsversion > 0x030D0000; # 3.13 } else { say;