From 843666ffdc0745e1aed5d665ec18d57263e32079 Mon Sep 17 00:00:00 2001 From: Rich Salz Date: Fri, 3 Jun 2016 14:49:20 -0400 Subject: More utils cleanup. Remove some unused files. Rename doc-nit-check to be consistent. Add check for multiple #include in synopsis. Reviewed-by: Richard Levitte --- util/copy-if-different.pl | 84 ----------------------------------- util/dirname.pl | 24 ---------- util/doc-nit-check.pl | 86 ------------------------------------ util/extract-names.pl | 33 -------------- util/extract-section.pl | 18 -------- util/find-doc-nits.pl | 109 ++++++++++++++++++++++++++++++++++++++++++++++ util/perlpath.pl | 40 ----------------- 7 files changed, 109 insertions(+), 285 deletions(-) delete mode 100755 util/copy-if-different.pl delete mode 100644 util/dirname.pl delete mode 100644 util/doc-nit-check.pl delete mode 100644 util/extract-names.pl delete mode 100644 util/extract-section.pl create mode 100644 util/find-doc-nits.pl delete mode 100755 util/perlpath.pl diff --git a/util/copy-if-different.pl b/util/copy-if-different.pl deleted file mode 100755 index 2bf7835827..0000000000 --- a/util/copy-if-different.pl +++ /dev/null @@ -1,84 +0,0 @@ -#! /usr/bin/env perl -# Copyright 2013-2016 The OpenSSL Project Authors. All Rights Reserved. -# -# Licensed under the OpenSSL license (the "License"). You may not use -# this file except in compliance with the License. You can obtain a copy -# in the file LICENSE in the source distribution or at -# https://www.openssl.org/source/license.html - -use strict; - -use Fcntl; - -# copy-if-different.pl - -# Copy to the destination if the source is not the same as it. - -my @filelist; - -foreach my $arg (@ARGV) { - $arg =~ s|\\|/|g; # compensate for bug/feature in cygwin glob... - foreach (glob qq("$arg")) - { - push @filelist, $_; - } -} - -my $fnum = @filelist; - -if ($fnum <= 1) - { - die "Need at least two filenames"; - } - -my $dest = pop @filelist; - -if ($fnum > 2 && ! -d $dest) - { - die "Destination must be a directory"; - } - -foreach (@filelist) - { - my $dfile; - if (-d $dest) - { - $dfile = $_; - $dfile =~ s|^.*[/\\]([^/\\]*)$|$1|; - $dfile = "$dest/$dfile"; - } - else - { - $dfile = $dest; - } - - my $buf; - if (-f $dfile) - { - sysopen(IN, $_, O_RDONLY|O_BINARY) || die "Can't Open $_"; - sysopen(OUT, $dfile, O_RDONLY|O_BINARY) - || die "Can't Open $dfile"; - while (sysread IN, $buf, 10240) - { - my $b2; - goto copy if !sysread(OUT, $b2, 10240) || $buf ne $b2; - } - goto copy if sysread(OUT, $buf, 1); - close(IN); - close(OUT); - print "NOT copying: $_ to $dfile\n"; - next; - } - copy: - sysopen(IN, $_, O_RDONLY|O_BINARY) || die "Can't Open $_"; - sysopen(OUT, $dfile, O_WRONLY|O_CREAT|O_TRUNC|O_BINARY) - || die "Can't Open $dfile"; - while (sysread IN, $buf, 10240) - { - syswrite(OUT, $buf, length($buf)); - } - close(IN); - close(OUT); - print "Copying: $_ to $dfile\n"; - } - diff --git a/util/dirname.pl b/util/dirname.pl deleted file mode 100644 index 9838e19906..0000000000 --- a/util/dirname.pl +++ /dev/null @@ -1,24 +0,0 @@ -#! /usr/bin/env perl -# Copyright 2002-2016 The OpenSSL Project Authors. All Rights Reserved. -# -# Licensed under the OpenSSL license (the "License"). You may not use -# this file except in compliance with the License. You can obtain a copy -# in the file LICENSE in the source distribution or at -# https://www.openssl.org/source/license.html - -if ($#ARGV < 0) { - die "dirname.pl: too few arguments\n"; -} elsif ($#ARGV > 0) { - die "dirname.pl: too many arguments\n"; -} - -my $d = $ARGV[0]; - -if ($d =~ m|.*/.*|) { - $d =~ s|/[^/]*$||; -} else { - $d = "."; -} - -print $d,"\n"; -exit(0); diff --git a/util/doc-nit-check.pl b/util/doc-nit-check.pl deleted file mode 100644 index 29599f3d11..0000000000 --- a/util/doc-nit-check.pl +++ /dev/null @@ -1,86 +0,0 @@ -#! /usr/bin/env perl -# Copyright 2002-2016 The OpenSSL Project Authors. All Rights Reserved. -# -# Licensed under the OpenSSL license (the "License"). You may not use -# this file except in compliance with the License. You can obtain a copy -# in the file LICENSE in the source distribution or at -# https://www.openssl.org/source/license.html - - -require 5.10.0; -use warnings; -use strict; -use Pod::Checker; -use File::Find; -use File::Basename; - -my $temp = '/tmp/docnits.txt'; -my $OUT; - -my %mandatory_sections = - ( '*' => [ 'NAME', 'DESCRIPTION', 'COPYRIGHT' ], - 1 => [ 'SYNOPSIS', '(COMMAND\s+)?OPTIONS' ], - 3 => [ 'SYNOPSIS', 'RETURN\s+VALUES' ], - 5 => [ ], - 7 => [ ] ); -my %default_sections = - ( apps => 1, - crypto => 3, - ssl => 3 ); - -sub check() -{ - my $filename = shift; - my $dirname = basename(dirname($filename)); - my $contents = ''; - { - local $/ = undef; - open POD, $filename or die "Couldn't open $filename, $!"; - $contents = ; - close POD; - } - print $OUT "$filename doesn't start with =pod\n" - if $contents !~ /^=pod/; - print $OUT "$filename doesn't end with =cut\n" - if $contents !~ /=cut\n$/; - print $OUT "$filename more than one cut line.\n" - if $contents =~ /=cut.*=cut/ms; - print $OUT "$filename missing copyright\n" - if $contents !~ /Copyright .* The OpenSSL Project Authors/; - print $OUT "$filename copyright not last\n" - if $contents =~ /head1 COPYRIGHT.*=head/ms; - print $OUT "$filename head2 in All uppercase\n" - if $contents =~ /head2.*[A-Z ]+\n/; - - my $section = $default_sections{$dirname}; - if ($contents =~ /^=for\s+comment\s+openssl_manual_section:\s*(\d+)\s*$/m) { - $section = $1; - } - - foreach ((@{$mandatory_sections{'*'}}, @{$mandatory_sections{$section}})) { - print $OUT "$filename doesn't have a head1 section matching $_\n" - if $contents !~ /^=head1\s+${_}\s*$/m; - } - - podchecker($filename, $OUT); -} - -open $OUT, '>', $temp - or die "Can't open $temp, $!"; -foreach (@ARGV ? @ARGV : glob('*/*.pod')) { - &check($_); -} -close $OUT; - -my $count = 0; -open $OUT, '<', $temp - or die "Can't read $temp, $!"; -while ( <$OUT> ) { - next if /\(section\) in.*deprecated/; - $count++; - print; -} -close $OUT; -unlink $temp || warn "Can't remove $temp, $!"; - -exit $count; diff --git a/util/extract-names.pl b/util/extract-names.pl deleted file mode 100644 index 2a24e1a99b..0000000000 --- a/util/extract-names.pl +++ /dev/null @@ -1,33 +0,0 @@ -#! /usr/bin/env perl -# Copyright 2002-2016 The OpenSSL Project Authors. All Rights Reserved. -# -# Licensed under the OpenSSL license (the "License"). You may not use -# this file except in compliance with the License. You can obtain a copy -# in the file LICENSE in the source distribution or at -# https://www.openssl.org/source/license.html - - -$/ = ""; # Eat a paragraph at once. -while() { - s|\R$||; - s/\n/ /gm; - if (/^=head1 /) { - $name = 0; - } elsif ($name) { - if (/ - /) { - s/ - .*//; - s/,\s+/,/g; - s/\s+,/,/g; - s/^\s+//g; - s/\s+$//g; - s/\s/_/g; - push @words, split ','; - } - } - if (/^=head1 *NAME *$/) { - $name = 1; - } -} - -print join("\n", @words),"\n"; - diff --git a/util/extract-section.pl b/util/extract-section.pl deleted file mode 100644 index 08b1a125b3..0000000000 --- a/util/extract-section.pl +++ /dev/null @@ -1,18 +0,0 @@ -#! /usr/bin/env perl -# Copyright 2004-2016 The OpenSSL Project Authors. All Rights Reserved. -# -# Licensed under the OpenSSL license (the "License"). You may not use -# this file except in compliance with the License. You can obtain a copy -# in the file LICENSE in the source distribution or at -# https://www.openssl.org/source/license.html - -while() { - if (/=for\s+comment\s+openssl_manual_section:(\S+)/) - { - print "$1\n"; - exit 0; - } -} - -print "$ARGV[0]\n"; - diff --git a/util/find-doc-nits.pl b/util/find-doc-nits.pl new file mode 100644 index 0000000000..26754d19b7 --- /dev/null +++ b/util/find-doc-nits.pl @@ -0,0 +1,109 @@ +#! /usr/bin/env perl +# Copyright 2002-2016 The OpenSSL Project Authors. All Rights Reserved. +# +# Licensed under the OpenSSL license (the "License"). You may not use +# this file except in compliance with the License. You can obtain a copy +# in the file LICENSE in the source distribution or at +# https://www.openssl.org/source/license.html + + +require 5.10.0; +use warnings; +use strict; +use Pod::Checker; +use File::Find; +use File::Basename; + +my $temp = '/tmp/docnits.txt'; +my $OUT; + +my %mandatory_sections = + ( '*' => [ 'NAME', 'DESCRIPTION', 'COPYRIGHT' ], + 1 => [ 'SYNOPSIS', '(COMMAND\s+)?OPTIONS' ], + 3 => [ 'SYNOPSIS', 'RETURN\s+VALUES' ], + 5 => [ ], + 7 => [ ] ); +my %default_sections = + ( apps => 1, + crypto => 3, + ssl => 3 ); + +sub check() +{ + my $filename = shift; + my $dirname = basename(dirname($filename)); + + my $contents = ''; + { + local $/ = undef; + open POD, $filename or die "Couldn't open $filename, $!"; + $contents = ; + close POD; + } + + my $id = "${filename}:1:"; + print $OUT "$id doesn't start with =pod\n" + if $contents !~ /^=pod/; + print $OUT "$id doesn't end with =cut\n" + if $contents !~ /=cut\n$/; + print $OUT "$id more than one cut line.\n" + if $contents =~ /=cut.*=cut/ms; + print $OUT "$id missing copyright\n" + if $contents !~ /Copyright .* The OpenSSL Project Authors/; + print $OUT "$id copyright not last\n" + if $contents =~ /head1 COPYRIGHT.*=head/ms; + print $OUT "$id head2 in All uppercase\n" + if $contents =~ /head2\s+[A-Z ]+\n/; + + # Look for multiple consecutive openssl #include lines. + # Consecutive because of files like md5.pod. Sometimes it's okay + # or necessary, as in ssl/SSL_set1_host.pod + if ( $contents !~ /=for comment multiple includes/ ) { + if ( $contents =~ /=head1 SYNOPSIS(.*)=head1 DESCRIPTION/ms ) { + my $count = 0; + foreach my $line ( split /\n+/, $1 ) { + if ( $line =~ m@include ', $temp + or die "Can't open $temp, $!"; +foreach (@ARGV ? @ARGV : glob('*/*.pod')) { + &check($_); +} +close $OUT; + +my $count = 0; +open $OUT, '<', $temp + or die "Can't read $temp, $!"; +while ( <$OUT> ) { + next if /\(section\) in.*deprecated/; + $count++; + print; +} +close $OUT; +unlink $temp || warn "Can't remove $temp, $!"; + +exit $count; diff --git a/util/perlpath.pl b/util/perlpath.pl deleted file mode 100755 index 80388e2946..0000000000 --- a/util/perlpath.pl +++ /dev/null @@ -1,40 +0,0 @@ -#! /usr/bin/env perl -# Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. -# -# Licensed under the OpenSSL license (the "License"). You may not use -# this file except in compliance with the License. You can obtain a copy -# in the file LICENSE in the source distribution or at -# https://www.openssl.org/source/license.html - -# modify the '#!/usr/local/bin/perl' -# line in all scripts that rely on perl. - -require "find.pl"; - -$#ARGV == 0 || print STDERR "usage: perlpath newpath (eg /usr/bin)\n"; -&find("."); - -sub wanted - { - return unless /\.pl$/ || /^[Cc]onfigur/; - - open(IN,"<$_") || die "unable to open $dir/$_:$!\n"; - @a=; - close(IN); - - if (-d $ARGV[0]) { - $a[0]="#!$ARGV[0]/perl\n"; - } - else { - $a[0]="#!$ARGV[0]\n"; - } - - # Playing it safe... - $new="$_.new"; - open(OUT,">$new") || die "unable to open $dir/$new:$!\n"; - print OUT @a; - close(OUT); - - rename($new,$_) || die "unable to rename $dir/$new:$!\n"; - chmod(0755,$_) || die "unable to chmod $dir/$new:$!\n"; - } -- cgit v1.2.3