util/perl/OpenSSL/Ordinals.pm: shift to dotted versions internally

Any version from an ordinals file will have '_' changed to '.' on
input, and changed back on output.

Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/7740)
This commit is contained in:
Richard Levitte 2018-12-02 13:46:35 +01:00
parent d6c3c1896c
commit 257ab867d0

View file

@ -528,7 +528,6 @@ sub set_version {
$version //= '*';
$version =~ s|-.*||g;
$version =~ s|\.|_|g;
$self->{currversion} = $version;
foreach ($self->items(filter => sub { $_[0] eq '*' })) {
$_->{version} = $self->{currversion};
@ -701,10 +700,13 @@ sub new {
if ($opts{name} && $opts{version} && defined $opts{exists} && $opts{type}
&& ref($opts{platforms} // {}) eq 'HASH'
&& ref($opts{features} // []) eq 'ARRAY') {
my $version = $opts{version};
$version =~ s|_|.|g;
$instance = { name => $opts{name},
type => $opts{type},
number => $opts{number},
version => $opts{version},
version => $version,
exists => !!$opts{exists},
platforms => { %{$opts{platforms} // {}} },
features => [ sort @{$opts{features} // []} ] };
@ -784,10 +786,12 @@ sub to_string {
croak "Too many arguments" if @_;
my %platforms = $self->platforms();
my @features = $self->features();
my $version = $self->version();
$version =~ s|\.|_|g;
return sprintf "%-39s %d\t%s\t%s:%s:%s:%s",
$self->name(),
$self->number(),
$self->version(),
$version,
$self->exists() ? 'EXIST' : 'NOEXIST',
join(',', (map { ($platforms{$_} ? '' : '!') . $_ }
sort keys %platforms)),
@ -847,7 +851,7 @@ sub by_version {
my $textversion = shift;
return $textversion if $textversion eq '*';
my ($major,$minor,$edit,$patch) =
$textversion =~ /^(\d+)_(\d+)_(\d+)([a-z]{0,2})$/;
$textversion =~ /^(\d+)\.(\d+)\.(\d+)([a-z]{0,2})$/;
return ($major,$minor,$edit,$patch);
}
@ -891,9 +895,8 @@ matching B<VERSION>.
sub f_version {
my $version = shift;
$version =~ s|\.|_|g if $version;
croak "No version specified"
unless $version && $version =~ /^\d+_\d+_\d+[a-z]{0,2}$/;
unless $version && $version =~ /^\d+\.\d+\.\d+[a-z]{0,2}$/;
return sub { $_[0]->version() eq $version };
}