OpenSSL::Ordinals: add a renumber() function, to assign unassigned symbols
authorRichard Levitte <levitte@openssl.org>
Mon, 4 Nov 2019 09:29:53 +0000 (10:29 +0100)
committerRichard Levitte <levitte@openssl.org>
Tue, 5 Nov 2019 21:44:21 +0000 (22:44 +0100)
This should be used when it's time to assign constant numbers to the
unassigned symbols.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/10348)

util/perl/OpenSSL/Ordinals.pm

index 55d5b2f..411cdc9 100644 (file)
@@ -169,7 +169,26 @@ sub load {
     return 1;
 }
 
-=item B<$ordinals-E<gt>rewrite>
+=item B<< $ordinals->renumber >>
+
+Renumber any item that doesn't have an assigned number yet.
+
+=cut
+
+sub renumber {
+    my $self = shift;
+
+    my $max_assigned = 0;
+    foreach ($self->items(by => by_number())) {
+        $_->number($_->intnum()) if $_->number() =~ m|^\?|;
+        if ($max_assigned < $_->number()) {
+            $max_assigned = $_->number();
+        }
+    }
+    $self->{maxassigned} = $max_assigned;
+}
+
+=item B<< $ordinals->rewrite >>
 
 If an ordinals file has been loaded, it gets rewritten with the data from
 the current work database.