Have dbExpand.pl sort records by name, unless -s used

This commit is contained in:
Andrew Johnson
2022-05-13 15:09:08 -07:00
committed by Michael Davidsaver
parent 4d3a27fdb0
commit ce420588db
2 changed files with 11 additions and 3 deletions

View File

@@ -128,6 +128,11 @@ sub add_record {
sub record_names {
return @{shift->{RECORDS}};
}
sub sort_records {
my $this = shift;
my @sorted = sort @{$this->{RECORDS}};
$this->{RECORDS} = \@sorted;
}
sub registrars {
return shift->{'DBD::Registrar'};

View File

@@ -22,10 +22,10 @@ use EPICS::Getopts;
use EPICS::Readfile;
use EPICS::macLib;
our ($opt_D, @opt_I, @opt_S, $opt_o, $opt_V);
our ($opt_D, @opt_I, @opt_S, $opt_o, $opt_s, $opt_V);
getopts('DI@S@o:V') or
die "Usage: dbExpand [-D] [-I dir] [-S macro=val] [-o out.db] in.dbd in.db ...";
getopts('DI@S@so:V') or
die "Usage: dbExpand [-D] [-I dir] [-S macro=val] [-s] [-o out.db] in.dbd in.db ...";
my @path = map { split /[:;]/ } @opt_I; # FIXME: Broken on Win32?
my $macros = EPICS::macLib->new(@opt_S);
@@ -74,6 +74,9 @@ if ($opt_D) { # Output dependencies only, ignore errors
die "dbExpand.pl: Exiting due to errors\n" if $errors;
$dbd->sort_records
unless $opt_s;
my $out;
if ($opt_o) {
open $out, '>', $opt_o or die "Can't create $opt_o: $!\n";