diff options
author | Richard Levitte <levitte@openssl.org> | 2020-10-08 06:27:51 +0200 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2020-10-09 10:19:47 +0200 |
commit | 0c12ca7294ac887d3d07a3294d1ee7c35a2be7e4 (patch) | |
tree | bc7792b850b6d384aee3cdc5d0ee984708ce528e /util/perl | |
parent | cad809592579e62c7d38407bdcb11b942571d535 (diff) |
OpenSSL::Ordinals: Add options for the writing functions
OpenSSL::Ordinals::rewrite() and OpenSSL::Ordinals::write() now take
options, that are simply passed to OpenSSL::Ordinals::items(). The
'sort' option is forbidden, though, since write() already uses it, but
that means it's possible to filter the output.
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/13092)
Diffstat (limited to 'util/perl')
-rw-r--r-- | util/perl/OpenSSL/Ordinals.pm | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/util/perl/OpenSSL/Ordinals.pm b/util/perl/OpenSSL/Ordinals.pm index 0b1db48dd3..7008ebf536 100644 --- a/util/perl/OpenSSL/Ordinals.pm +++ b/util/perl/OpenSSL/Ordinals.pm @@ -179,7 +179,7 @@ sub renumber { my $self = shift; my $max_assigned = 0; - foreach ($self->items(by => by_number())) { + foreach ($self->items(sort => by_number())) { $_->number($_->intnum()) if $_->number() =~ m|^\?|; if ($max_assigned < $_->number()) { $max_assigned = $_->number(); @@ -190,34 +190,49 @@ sub renumber { =item B<< $ordinals->rewrite >> +=item B<< $ordinals->rewrite >>, I<%options> + If an ordinals file has been loaded, it gets rewritten with the data from the current work database. +If there are more arguments, they are used as I<%options> with the +same semantics as for B<< $ordinals->items >> described below, apart +from B<sort>, which is forbidden here. + =cut sub rewrite { my $self = shift; + my %opts = @_; - $self->write($self->{filename}); + $self->write($self->{filename}, %opts); } =item B<< $ordinals->write FILENAME >> +=item B<< $ordinals->write FILENAME >>, I<%options> + Writes the current work database data to the ordinals file FILENAME. This also validates the data, see B<< $ordinals->validate >> below. +If there are more arguments, they are used as I<%options> with the +same semantics as for B<< $ordinals->items >> described next, apart +from B<sort>, which is forbidden here. + =cut sub write { my $self = shift; my $filename = shift; + my %opts = @_; croak "Undefined filename" unless defined($filename); + croak "The 'sort' option is not allowed" if $opts{sort}; $self->validate(); open F, '>', $filename or croak "Unable to open $filename"; - foreach ($self->items(by => by_number())) { + foreach ($self->items(%opts, sort => by_number())) { print F $_->to_string(),"\n"; } close F; |