From 257ab867d0f290fcfe5e1abe005086b8bd94d047 Mon Sep 17 00:00:00 2001 From: Richard Levitte Date: Sun, 2 Dec 2018 13:46:35 +0100 Subject: [PATCH] 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 (Merged from https://github.com/openssl/openssl/pull/7740) --- util/perl/OpenSSL/Ordinals.pm | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/util/perl/OpenSSL/Ordinals.pm b/util/perl/OpenSSL/Ordinals.pm index e2d206d708..35625a32c9 100644 --- a/util/perl/OpenSSL/Ordinals.pm +++ b/util/perl/OpenSSL/Ordinals.pm @@ -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. 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 }; } -- 2.25.1