find-doc-nits: Make -c option (cmd-nits) independent of app build and execution
authorDr. David von Oheimb <David.von.Oheimb@siemens.com>
Sun, 16 May 2021 17:03:50 +0000 (19:03 +0200)
committerDr. David von Oheimb <dev@ddvo.net>
Tue, 18 May 2021 11:02:23 +0000 (13:02 +0200)
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15298)

Configurations/unix-Makefile.tmpl
apps/asn1parse.c [moved from apps/asn1pars.c with 100% similarity]
apps/build.info
apps/crl2pkcs7.c [moved from apps/crl2p7.c with 100% similarity]
doc/man1/openssl.pod
util/find-doc-nits

index a80e78e86f4c0f439137ebd0dea43d8856e94729..f729416d1d9f31e757e0d89a6048099cb0fceede 100644 (file)
@@ -1066,7 +1066,7 @@ generate_buildinfo: generate_doc_buildinfo
 doc-nits: build_generated_pods
        $(PERL) $(SRCDIR)/util/find-doc-nits -n -l -e
 
-cmd-nits: build_generated apps/openssl build_generated_pods
+cmd-nits: build_generated_pods
        $(PERL) $(SRCDIR)/util/find-doc-nits -c
 
 # This uses "mdl", the markdownlint application, which is written in ruby.
similarity index 100%
rename from apps/asn1pars.c
rename to apps/asn1parse.c
index cba9803c65266ebe50c0f12aaa326b997cfb17ec..b2ecdf2e3a004da4b7beb3b25f2dc8050e1471a6 100644 (file)
@@ -12,7 +12,7 @@ ENDIF
 # Source for the 'openssl' program
 $OPENSSLSRC=\
         openssl.c progs.c \
-        asn1pars.c ca.c ciphers.c crl.c crl2p7.c dgst.c \
+        asn1parse.c ca.c ciphers.c crl.c crl2pkcs7.c dgst.c \
         enc.c errstr.c \
         genpkey.c kdf.c mac.c nseq.c passwd.c pkcs7.c \
         pkcs8.c pkey.c pkeyparam.c pkeyutl.c prime.c rand.c req.c \
similarity index 100%
rename from apps/crl2p7.c
rename to apps/crl2pkcs7.c
index 78b98ab7a6b0ebd8eb62850e757474426deb46d6..3b47ae97298006f7c998cb451666e92ab766fcf2 100644 (file)
@@ -13,13 +13,13 @@ I<command>
 
 B<openssl>
 B<list>
-B<-standard-commands> |
-B<-digest-commands> |
-B<-cipher-commands> |
-B<-cipher-algorithms> |
-B<-digest-algorithms> |
-B<-mac-algorithms> |
-B<-public-key-algorithms>
+B<standard-commands> |
+B<digest-commands> |
+B<cipher-commands> |
+B<cipher-algorithms> |
+B<digest-algorithms> |
+B<mac-algorithms> |
+B<public-key-algorithms>
 
 B<openssl> B<no->I<XXX> [ I<options> ]
 
index a5ea78706de55baec253deb6c99654b402d5ba9f..f4cc771e5a855d42da7dec121abb65f2f9da3251 100755 (executable)
@@ -28,9 +28,6 @@ use configdata;
 # Set to 1 for debug output
 my $debug = 0;
 
-# Where to find openssl command
-my $openssl = "./util/opensslwrap.sh";
-
 # Options.
 our($opt_d);
 our($opt_e);
@@ -1029,21 +1026,40 @@ my %skips = (
     'digest' => 1,
 );
 
+my %genopts; # generic options parsed from apps/include/opt.h
+
 # Check the flags of a command and see if everything is in the manpage
 sub checkflags {
     my $cmd = shift;
     my $doc = shift;
-    my %cmdopts;
+    my @cmdopts;
     my %docopts;
     my %localskips;
 
-    # Get the list of options in the command.
-    open CFH, "$openssl list --options $cmd|"
-        or die "Can list options for $cmd, $!";
+    # Get the list of options in the command source file.
+    my $active = 0;
+    my $expect_helpstr = "";
+    open CFH, "apps/$cmd.c"
+        or die "Can't open apps/$cmd.c to list options for $cmd, $!";
     while ( <CFH> ) {
         chop;
-        s/ .$//;
-        $cmdopts{$_} = 1;
+        if ($active) {
+            last if m/^\s*};/;
+            if ($expect_helpstr ne "") {
+                next if m/^\s*#\s*if/;
+                err("$cmd does not implement help for -$expect_helpstr") unless m/^\s*"/;
+                $expect_helpstr = "";
+            } elsif (m/\{\s*"([^"]+)"\s*,\s*OPT_[A-Z0-9_]+\s*,\s*('[-\/:<>cEfFlMnNpsuU]'|0)\s*,(.*)$/
+                       && !($cmd eq "s_client" && $1 eq "wdebug")) {
+                push @cmdopts, $1;
+                $expect_helpstr = $1;
+                $expect_helpstr = "" if $3 =~ m/^\s*"/;
+            } elsif (m/[\s,](OPT_[A-Z]+_OPTIONS?)\s*(,|$)/) {
+                push @cmdopts, @{ $genopts{$1} };
+            }
+        } elsif (m/^const\s+OPTIONS\s*/) {
+            $active = 1;
+        }
     }
     close CFH;
 
@@ -1073,15 +1089,16 @@ sub checkflags {
     close CFH;
 
     # See what's in the command not the manpage.
-    my @undocced = sort grep { !defined $docopts{$_} } keys %cmdopts;
+    my @undocced = sort grep { !defined $docopts{$_} } @cmdopts;
     foreach ( @undocced ) {
-        next if /-/; # Skip the -- end-of-flags marker
+        next if $cmd eq "openssl" && $_ eq "help";
         err("$doc: undocumented option -$_");
     }
 
     # See what's in the command not the manpage.
-    my @unimpl = sort grep { !defined $cmdopts{$_} } keys %docopts;
+    my @unimpl = sort grep { my $e = $_; !(grep /^\Q$e\E$/, @cmdopts) } keys %docopts;
     foreach ( @unimpl ) {
+        next if $_ eq "-"; # Skip the -- end-of-flags marker
         next if defined $skips{$_} || defined $localskips{$_};
         err("$doc: $cmd does not implement -$_");
     }
@@ -1097,18 +1114,27 @@ sub checkflags {
 if ( $opt_c ) {
     my @commands = ();
 
-    # Get list of commands.
-    open FH, "$openssl list -1 -commands|"
-        or die "Can't list commands, $!";
-    while ( <FH> ) {
+    # Get the lists of generic options.
+    my $active = "";
+    open OFH, "apps/include/opt.h"
+        or die "Can't open apps/include/opt.h to list generic options, $!";
+    while ( <OFH> ) {
         chop;
-        push @commands, $_;
+        push @{ $genopts{$active} }, $1 if $active ne "" && m/^\s+\{\s*"([^"]+)"\s*,\s*OPT_/;
+        $active = $1 if m/^\s*#\s*define\s+(OPT_[A-Z]+_OPTIONS?)\s*\\\s*$/;
+        $active = "" if m/^\s*$/;
     }
-    close FH;
+    close OFH;
+
+    # Get list of commands.
+    opendir(DIR, "apps");
+    @commands = grep(/\.c$/, readdir(DIR));
+    closedir(DIR);
 
     # See if each has a manpage.
     foreach my $cmd ( @commands ) {
-        next if $cmd eq 'help' || $cmd eq 'exit';
+        $cmd =~ s/\.c$//;
+        next if $cmd eq 'progs' || $cmd eq 'cmp_mock_srv' || $cmd eq 'vms_decc_init';
         my @doc = ( grep { basename($_) eq "openssl-$cmd.pod"
                            # For "tsget" and "CA.pl" pod pages
                            || basename($_) eq "$cmd.pod" }
@@ -1123,16 +1149,6 @@ if ( $opt_c ) {
         }
     }
 
-    # See what help is missing.
-    open FH, "$openssl list --missing-help |"
-        or die "Can't list missing help, $!";
-    while ( <FH> ) {
-        chop;
-        my ($cmd, $flag) = split;
-        err("$cmd has no help for -$flag");
-    }
-    close FH;
-
     exit $status;
 }