]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Fix apps/progs.pl to be slightly less fragile
authorBob Beck <beck@openssl.org>
Thu, 21 Aug 2025 23:15:09 +0000 (17:15 -0600)
committerNeil Horman <nhorman@openssl.org>
Thu, 4 Dec 2025 16:35:06 +0000 (11:35 -0500)
In particular fix the regex magic to be tolerant of different ways
of formatting a main program.

My past life had forgotten this magic 14 years ago when we converted
it to just a table of commands in the forks.

https://www.youtube.com/watch?v=mWbbjvYmN8A

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/29257)

apps/progs.pl

index 4a1e4be47c692c7914c17fd478bfac1e86fd1e63..c2ef15c64ed47f55475410dfe6781ccdcd046e7b 100644 (file)
@@ -19,7 +19,10 @@ die "Unrecognised option, must be -C or -H\n"
     unless ($opt eq '-H' || $opt eq '-C');
 
 my %commands     = ();
-my $cmdre        = qr/^\s*int\s+([a-z_][a-z0-9_]*)_main\(\s*int\s+argc\s*,/;
+# XXX beck I think it is best reconsidered in favour of just a table
+# of commands instead of this fragile regex. There really are not that
+# many commands.
+my $cmdre        = qr/^\s*(int\s+|)\s*([a-z_][a-z0-9_]*)_main\s*\(\s*int\s+argc\s*,/;
 my $apps_openssl = shift @ARGV;
 my $YEAR         = [gmtime($ENV{SOURCE_DATE_EPOCH} || time())]->[5] + 1900;
 
@@ -36,7 +39,7 @@ foreach my $filename (@openssl_source) {
     open F, $filename or die "Couldn't open $filename: $!\n";
     foreach ( grep /$cmdre/, <F> ) {
         my @foo = /$cmdre/;
-        $commands{$1} = 1;
+        $commands{$2} = 1;
     }
     close F;
 }