From e4f336de9401e617fad1913408808ea698bf9465 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Tue, 21 Apr 2015 15:09:24 -0500 Subject: [PATCH] Perl style fixes, document more Perl programs --- src/libCom/env/bldEnvData.pl | 4 +- src/libCom/misc/makeEpicsVersion.pl | 4 +- src/template/base/makeBaseApp.pl | 26 ++++----- src/template/ext/makeBaseExt.pl | 22 ++++---- src/tools/DBD/Output.pm | 14 ++--- src/tools/DBD/Parser.pm | 2 +- src/tools/EPICS/Readfile.pm | 14 ++--- src/tools/EPICS/Release.pm | 12 ++--- src/tools/Makefile | 3 ++ src/tools/convertRelease.pl | 30 ++++++----- src/tools/dbdExpand.pl | 4 +- src/tools/dbdReport.pl | 2 +- src/tools/dbdToHtml.pl | 2 +- src/tools/dbdToMenuH.pl | 2 +- src/tools/dbdToRecordtypeH.pl | 6 +-- src/tools/expandVars.pl | 4 +- src/tools/fullPathName.pl | 56 +++++++++++++++++--- src/tools/munch.pl | 70 +++++++++++++++++++++---- src/tools/podRemove.pl | 60 ++++++++++++++++++--- src/tools/podToHtml.pl | 32 ++++++----- src/tools/registerRecordDeviceDriver.pl | 2 +- 21 files changed, 259 insertions(+), 112 deletions(-) diff --git a/src/libCom/env/bldEnvData.pl b/src/libCom/env/bldEnvData.pl index 993c36cee..08d65467e 100644 --- a/src/libCom/env/bldEnvData.pl +++ b/src/libCom/env/bldEnvData.pl @@ -32,8 +32,8 @@ our $opt_o = 'envData.c'; $Getopt::Std::OUTPUT_HELP_VERSION = 1; $Text::Wrap::columns = 75; -&HELP_MESSAGE unless getopts('ho:q') && @ARGV == 1; -&HELP_MESSAGE if $opt_h; +HELP_MESSAGE() unless getopts('ho:q') && @ARGV == 1; +HELP_MESSAGE() if $opt_h; my $config = AbsPath(shift); my $env_defs = AbsPath('../env/envDefs.h'); diff --git a/src/libCom/misc/makeEpicsVersion.pl b/src/libCom/misc/makeEpicsVersion.pl index 2a720e86d..08f5aa3c0 100644 --- a/src/libCom/misc/makeEpicsVersion.pl +++ b/src/libCom/misc/makeEpicsVersion.pl @@ -20,8 +20,8 @@ our $opt_o = 'epicsVersion.h'; $Getopt::Std::OUTPUT_HELP_VERSION = 1; -&HELP_MESSAGE unless getopts('ho:qv:') && @ARGV == 1; -&HELP_MESSAGE if $opt_h; +HELP_MESSAGE() unless getopts('ho:qv:') && @ARGV == 1; +HELP_MESSAGE() if $opt_h; my ($infile) = @ARGV; diff --git a/src/template/base/makeBaseApp.pl b/src/template/base/makeBaseApp.pl index cf65d290f..65091a0fb 100644 --- a/src/template/base/makeBaseApp.pl +++ b/src/template/base/makeBaseApp.pl @@ -20,10 +20,10 @@ $app_top = cwd(); $bad_ident_chars = '[^0-9A-Za-z_]'; -&readReleaseFiles("configure/RELEASE", \%release, \@apps); -&expandRelease(\%release); -&get_commandline_opts; # Check command-line options -&GetUser; # Ensure we know who's in charge +readReleaseFiles("configure/RELEASE", \%release, \@apps); +expandRelease(\%release); +get_commandline_opts(); # Check command-line options +GetUser(); # Ensure we know who's in charge # # Declare two default callback routines for file copy plus two @@ -86,7 +86,7 @@ sub ReplaceFilename { # (filename) $file =~ s|_APPTYPE_|$apptype|; my $qmtop = quotemeta($top); $file =~ s|$qmtop/||; # Change to the target location - $file = &ReplaceFilenameHook($file); # Call the apptype's hook + $file = ReplaceFilenameHook($file); # Call the apptype's hook return $file; } @@ -104,7 +104,7 @@ sub ReplaceLine { # (line) $line =~ s/_CSAFEAPPNAME_/$csafeappname/g; $line =~ s/_APPTYPE_/$apptype/go; $line =~ s/_ARCH_/$arch/go if ($opt_i); - $line = &ReplaceLineHook($line); # Call the apptype's hook + $line = ReplaceLineHook($line); # Call the apptype's hook return $line; } @@ -202,7 +202,7 @@ sub get_commandline_opts { #no args # Print application type list? if ($opt_l) { - &ListAppTypes; + ListAppTypes(); exit 0; # finished for -l command } @@ -325,7 +325,7 @@ sub ListAppTypes { # no args # sub CopyFile { # (source) $source = $_[0]; - $target = &ReplaceFilename($source); + $target = ReplaceFilename($source); if ($target and !-e $target) { open(INP, "<$source") and open(OUT, ">$target") @@ -333,7 +333,7 @@ sub CopyFile { # (source) print "Copying file $source -> $target\n" if $opt_d; while () { - print OUT &ReplaceLine($_); + print OUT ReplaceLine($_); } close INP; close OUT; } @@ -345,11 +345,11 @@ sub CopyFile { # (source) sub FCopyTree { chdir $app_top; # Sigh if (-d "$File::Find::name" - and ($dir = &ReplaceFilename($File::Find::name))) { + and ($dir = ReplaceFilename($File::Find::name))) { print "Creating directory $dir\n" if $opt_d; - &mkpath($dir) unless (-d "$dir"); + mkpath($dir) unless (-d "$dir"); } else { - &CopyFile($File::Find::name); + CopyFile($File::Find::name); } chdir $File::Find::dir; } @@ -363,7 +363,7 @@ sub Cleanup { # (return-code [ messsage-line1, line 2, ... ]) if (@message) { print join("\n", @message), "\n"; } else { - &Usage; + Usage(); } exit $rtncode; } diff --git a/src/template/ext/makeBaseExt.pl b/src/template/ext/makeBaseExt.pl index 307764823..c4185ad53 100644 --- a/src/template/ext/makeBaseExt.pl +++ b/src/template/ext/makeBaseExt.pl @@ -15,7 +15,7 @@ $eEXTTYPE = $ENV{EPICS_MBE_DEF_EXT_TYPE}; $eTOP = $ENV{EPICS_MBE_TEMPLATE_TOP}; $eBASE = $ENV{EPICS_MBE_BASE}; -&get_commandline_opts; # Read and check options +get_commandline_opts(); # Read and check options $extname = "@ARGV"; @@ -43,7 +43,7 @@ sub ReplaceFilename { # (filename) $file =~ s|_EXTTYPE_|$exttype|; # We don't want the Replace overrides $file =~ s|.*/$extdir/Replace.pl$||; - $file = &ReplaceFilenameHook($file); # Call the user-defineable hook + $file = ReplaceFilenameHook($file); # Call the user-defineable hook return $file; } @@ -58,7 +58,7 @@ sub ReplaceLine { # (line) $line =~ s/_EXTNAME_/$extname/o; $line =~ s/_EXTTYPE_/$exttype/o; $line =~ s/_TEMPLATE_TOP_/$top/o; - $line = &ReplaceLineHook($line); # Call the user-defineable hook + $line = ReplaceLineHook($line); # Call the user-defineable hook return $line; } @@ -73,7 +73,7 @@ if (-r "$top/$exttypename/Replace.pl") { opendir TOPDIR, "$top" or die "Can't open $top: $!"; foreach $f ( grep !/^\.\.?$|^[^\/]*(Ext)/, readdir TOPDIR ) { if (-f "$f") { - &CopyFile("$top/$f") unless (-e "$f"); + CopyFile("$top/$f") unless (-e "$f"); } else { $note = yes if ("$f" eq "src" && -e "$f"); find(\&FCopyTree, "$top/$f") unless (-e "$f"); @@ -154,7 +154,7 @@ sub get_commandline_opts { #no args # Print extension type list? if ($opt_l) { - &ListExtTypes; + ListExtTypes(); exit 0; # finished for -l command } @@ -175,7 +175,7 @@ sub get_commandline_opts { #no args # Valid $exttypename? unless (-r "$top/$exttypename") { print "Template for extension type '$exttype' is unreadable or does not exist.\n"; - &ListExtTypes; + ListExtTypes(); exit 1; } @@ -204,7 +204,7 @@ sub ListExtTypes { # no args # sub CopyFile { # (source) $source = $_[0]; - $target = &ReplaceFilename($source); + $target = ReplaceFilename($source); if ($target) { $target =~ s|$top/||; @@ -213,7 +213,7 @@ sub CopyFile { # (source) print "Copying file $source -> $target\n" if $Debug; while () { - print OUT &ReplaceLine($_); + print OUT ReplaceLine($_); } close INP; close OUT; } @@ -225,12 +225,12 @@ sub CopyFile { # (source) sub FCopyTree { chdir $cwd; # Sigh if (-d $File::Find::name - and ($dir = &ReplaceFilename($File::Find::name))) { + and ($dir = ReplaceFilename($File::Find::name))) { $dir =~ s|$top/||; print "Creating directory $dir\n" if $Debug; - &mkpath($dir); + mkpath($dir); } else { - &CopyFile($File::Find::name); + CopyFile($File::Find::name); } chdir $File::Find::dir; } diff --git a/src/tools/DBD/Output.pm b/src/tools/DBD/Output.pm index b82ff98c9..a338358b3 100644 --- a/src/tools/DBD/Output.pm +++ b/src/tools/DBD/Output.pm @@ -19,13 +19,13 @@ use DBD::Variable; sub OutputDBD { my ($out, $dbd) = @_; - &OutputMenus($out, $dbd->menus); - &OutputRecordtypes($out, $dbd->recordtypes); - &OutputDrivers($out, $dbd->drivers); - &OutputRegistrars($out, $dbd->registrars); - &OutputFunctions($out, $dbd->functions); - &OutputVariables($out, $dbd->variables); - &OutputBreaktables($out, $dbd->breaktables); + OutputMenus($out, $dbd->menus); + OutputRecordtypes($out, $dbd->recordtypes); + OutputDrivers($out, $dbd->drivers); + OutputRegistrars($out, $dbd->registrars); + OutputFunctions($out, $dbd->functions); + OutputVariables($out, $dbd->variables); + OutputBreaktables($out, $dbd->breaktables); } sub OutputMenus { diff --git a/src/tools/DBD/Parser.pm b/src/tools/DBD/Parser.pm index 901420685..3fbf2f99d 100644 --- a/src/tools/DBD/Parser.pm +++ b/src/tools/DBD/Parser.pm @@ -79,7 +79,7 @@ sub parseCommon { # Extract POD if (m/\G ( = [a-zA-Z] .* ) \n/oxgc) { - $obj->add_pod($1, &parsePod); + $obj->add_pod($1, parsePod()); } elsif (m/\G \# /oxgc) { if (m/\G \# ! BEGIN \{ ( [^}]* ) \} ! \# \# \n/oxgc) { diff --git a/src/tools/EPICS/Readfile.pm b/src/tools/EPICS/Readfile.pm index 325efb17b..1b6cab21d 100644 --- a/src/tools/EPICS/Readfile.pm +++ b/src/tools/EPICS/Readfile.pm @@ -145,25 +145,25 @@ complete set of dependencies for the input file. sub Readfile { my ($file, $macros, $Rpath) = @_; print "Readfile($file)\n" if $debug; - my $input = &expandMacros($macros, &slurp($file, $Rpath)); + my $input = expandMacros($macros, slurp($file, $Rpath)); my @input = split /\n/, $input; my @output; foreach (@input) { if (m/^ \s* include \s+ $string /ox) { - $arg = &unquote($1); + $arg = unquote($1); print " include $arg\n" if $debug; push @output, "##! include \"$arg\""; - push @output, &Readfile($arg, $macros, $Rpath); + push @output, Readfile($arg, $macros, $Rpath); } elsif (m/^ \s* addpath \s+ $string /ox) { - $arg = &unquote($1); + $arg = unquote($1); print " addpath $arg\n" if $debug; push @output, "##! addpath \"$arg\""; - push @{$Rpath}, &splitPath($arg); + push @{$Rpath}, splitPath($arg); } elsif (m/^ \s* path \s+ $string /ox) { - $arg = &unquote($1); + $arg = unquote($1); print " path $arg\n" if $debug; push @output, "##! path \"$arg\""; - @{$Rpath} = &splitPath($arg); + @{$Rpath} = splitPath($arg); } else { push @output, $_; } diff --git a/src/tools/EPICS/Release.pm b/src/tools/EPICS/Release.pm index 09381dfc8..577444dc4 100644 --- a/src/tools/EPICS/Release.pm +++ b/src/tools/EPICS/Release.pm @@ -19,22 +19,22 @@ sub readReleaseFiles { $Rmacros->{'EPICS_HOST_ARCH'} = $hostarch if $hostarch; return unless (-e $relfile); - &readRelease($relfile, $Rmacros, $Rapps); + readRelease($relfile, $Rmacros, $Rapps); if ($hostarch) { my $hrelfile = "$relfile.$hostarch"; - &readRelease($hrelfile, $Rmacros, $Rapps) if (-e $hrelfile); + readRelease($hrelfile, $Rmacros, $Rapps) if (-e $hrelfile); $hrelfile .= '.Common'; - &readRelease($hrelfile, $Rmacros, $Rapps) if (-e $hrelfile); + readRelease($hrelfile, $Rmacros, $Rapps) if (-e $hrelfile); } if ($arch) { my $crelfile = "$relfile.Common.$arch"; - &readRelease($crelfile, $Rmacros, $Rapps) if (-e $crelfile); + readRelease($crelfile, $Rmacros, $Rapps) if (-e $crelfile); if ($hostarch) { my $arelfile = "$relfile.$hostarch.$arch"; - &readRelease($arelfile, $Rmacros, $Rapps) if (-e $arelfile); + readRelease($arelfile, $Rmacros, $Rapps) if (-e $arelfile); } } } @@ -71,7 +71,7 @@ sub readRelease { my ($op, $path) = m/^ \s* (-? include) \s+ (.*)/x; $path = expandMacros($path, $Rmacros); if (-e $path) { - &readRelease($path, $Rmacros, $Rapps); + readRelease($path, $Rmacros, $Rapps); } elsif ($op eq "include") { carp "EPICS/Release.pm: Include file '$path' not found\n"; } diff --git a/src/tools/Makefile b/src/tools/Makefile index 4b7162b6e..26da8f550 100644 --- a/src/tools/Makefile +++ b/src/tools/Makefile @@ -58,7 +58,10 @@ HTMLS = style.css HTMLS += EPICS/Getopts.html HTMLS += EPICS/Path.html HTMLS += EPICS/Readfile.html +HTMLS += fullPathName.html HTMLS += podToHtml.html +HTMLS += podRemove.html +HTMLS += munch.html # Build Package Config Files diff --git a/src/tools/convertRelease.pl b/src/tools/convertRelease.pl index abf63c3ec..9a425c954 100644 --- a/src/tools/convertRelease.pl +++ b/src/tools/convertRelease.pl @@ -14,12 +14,15 @@ # use strict; +use warnings; + +use Cwd qw(cwd); +use Getopt::Std; +$Getopt::Std::STANDARD_HELP_VERSION = 1; use FindBin qw($Bin); use lib ("$Bin/../../lib/perl", $Bin); -use Cwd qw(cwd); -use Getopt::Std; use EPICS::Path; use EPICS::Release; @@ -27,8 +30,7 @@ use vars qw($arch $top $iocroot $root); our ($opt_a, $opt_t, $opt_T); -$Getopt::Std::OUTPUT_HELP_VERSION = 1; -getopts('a:t:T:') or &HELP_MESSAGE; +getopts('a:t:T:') or HELP_MESSAGE(); my $cwd = UnixPath(cwd()); @@ -63,7 +65,7 @@ if ($opt_t) { } } -&HELP_MESSAGE unless @ARGV == 1; +HELP_MESSAGE() unless @ARGV == 1; my $outfile = $ARGV[0]; @@ -80,12 +82,12 @@ expandRelease(\%macros, \@apps); # This is a perl switch statement: for ($outfile) { - m/releaseTops/ and do { &releaseTops; last; }; - m/dllPath\.bat/ and do { &dllPath; last; }; - m/relPaths\.sh/ and do { &relPaths; last; }; - m/cdCommands/ and do { &cdCommands; last; }; - m/envPaths/ and do { &envPaths; last; }; - m/checkRelease/ and do { &checkRelease; last; }; + m/releaseTops/ and do { releaseTops(); last; }; + m/dllPath\.bat/ and do { dllPath(); last; }; + m/relPaths\.sh/ and do { relPaths(); last; }; + m/cdCommands/ and do { cdCommands(); last; }; + m/envPaths/ and do { envPaths(); last; }; + m/checkRelease/ and do { checkRelease(); last; }; die "Output file type \'$outfile\' not supported"; } @@ -158,7 +160,7 @@ sub cdCommands { my $startup = $cwd; $startup =~ s/^$root/$iocroot/o if ($opt_t); - $startup =~ s/([\\"])/\\\1/g; # escape back-slashes and double-quotes + $startup =~ s/([\\"])/\\$1/g; # escape back-slashes and double-quotes print OUT "startup = \"$startup\"\n"; @@ -171,7 +173,7 @@ sub cdCommands { foreach my $app (@includes) { my $iocpath = my $path = $macros{$app}; $iocpath =~ s/^$root/$iocroot/o if ($opt_t); - $iocpath =~ s/([\\"])/\\\1/g; # escape back-slashes and double-quotes + $iocpath =~ s/([\\"])/\\$1/g; # escape back-slashes and double-quotes my $app_lc = lc($app); print OUT "$app_lc = \"$iocpath\"\n" if (-d $path); @@ -203,7 +205,7 @@ sub envPaths { foreach my $app (@includes) { my $iocpath = my $path = $macros{$app}; $iocpath =~ s/^$root/$iocroot/o if ($opt_t); - $iocpath =~ s/([\\"])/\\\1/g; # escape back-slashes and double-quotes + $iocpath =~ s/([\\"])/\\$1/g; # escape back-slashes and double-quotes print OUT "epicsEnvSet(\"$app\",\"$iocpath\")\n" if (-d $path); } close OUT; diff --git a/src/tools/dbdExpand.pl b/src/tools/dbdExpand.pl index 32b38bf1e..96398e703 100755 --- a/src/tools/dbdExpand.pl +++ b/src/tools/dbdExpand.pl @@ -43,7 +43,7 @@ my $errors = 0; while (@ARGV) { my $file = shift @ARGV; eval { - &ParseDBD($dbd, &Readfile($file, $macros, \@opt_I)); + ParseDBD($dbd, Readfile($file, $macros, \@opt_I)); }; if ($@) { warn "dbdExpand.pl: $@"; @@ -72,7 +72,7 @@ if ($opt_o) { $out = STDOUT; } -&OutputDBD($out, $dbd); +OutputDBD($out, $dbd); if ($opt_o) { close $out or die "Closing $opt_o failed: $!\n"; diff --git a/src/tools/dbdReport.pl b/src/tools/dbdReport.pl index 303782879..9d1bd068e 100755 --- a/src/tools/dbdReport.pl +++ b/src/tools/dbdReport.pl @@ -32,7 +32,7 @@ my @path = map { split /[:;]/ } @opt_I; # FIXME: Broken on Win32? my $macros = EPICS::macLib->new(@opt_S); my $dbd = DBD->new(); -&ParseDBD($dbd, &Readfile(shift @ARGV, $macros, \@opt_I)); +ParseDBD($dbd, Readfile(shift @ARGV, $macros, \@opt_I)); $Text::Wrap::columns = 75; diff --git a/src/tools/dbdToHtml.pl b/src/tools/dbdToHtml.pl index bf162fefc..44f03fdbd 100644 --- a/src/tools/dbdToHtml.pl +++ b/src/tools/dbdToHtml.pl @@ -55,7 +55,7 @@ my $infile = shift @ARGV; $infile =~ m/\.dbd.pod$/ or die "$tool: Input file '$infile' must have '.dbd.pod' extension\n"; -&ParseDBD($dbd, &Readfile($infile, 0, \@opt_I)); +ParseDBD($dbd, Readfile($infile, 0, \@opt_I)); if (!$opt_o) { ($opt_o = $infile) =~ s/\.dbd\.pod$/.html/; diff --git a/src/tools/dbdToMenuH.pl b/src/tools/dbdToMenuH.pl index 1e5f35fb2..e1d640c16 100755 --- a/src/tools/dbdToMenuH.pl +++ b/src/tools/dbdToMenuH.pl @@ -49,7 +49,7 @@ my $guard_name = "INC_$outbase"; $guard_name =~ tr/a-zA-Z0-9_/_/cs; $guard_name =~ s/(_[hH])?$/_H/; -&ParseDBD($dbd, &Readfile($infile, 0, \@opt_I)); +ParseDBD($dbd, Readfile($infile, 0, \@opt_I)); if ($opt_D) { my %filecount; diff --git a/src/tools/dbdToRecordtypeH.pl b/src/tools/dbdToRecordtypeH.pl index 06c3b565e..0516a58bf 100755 --- a/src/tools/dbdToRecordtypeH.pl +++ b/src/tools/dbdToRecordtypeH.pl @@ -50,7 +50,7 @@ my $guard_name = "INC_$outbase"; $guard_name =~ tr/a-zA-Z0-9_/_/cs; $guard_name =~ s/(_[hH])?$/_H/; -&ParseDBD($dbd, &Readfile($infile, 0, \@opt_I)); +ParseDBD($dbd, Readfile($infile, 0, \@opt_I)); my $rtypes = $dbd->recordtypes; die "$tool: Input file must contain a single recordtype definition.\n" @@ -99,9 +99,9 @@ if ($opt_D) { # Output dependencies only, to stdout "\n} ${rn}FieldIndex;\n\n"; print OUTFILE "#ifdef GEN_SIZE_OFFSET\n\n"; if ($opt_s) { - &newtables; + newtables(); } else { - &oldtables; + oldtables(); } print OUTFILE "#endif /* GEN_SIZE_OFFSET */\n"; } diff --git a/src/tools/expandVars.pl b/src/tools/expandVars.pl index 76e35e259..c61bfbf6e 100644 --- a/src/tools/expandVars.pl +++ b/src/tools/expandVars.pl @@ -22,10 +22,10 @@ use EPICS::Copy; # Process command line options our ($opt_a, $opt_d, @opt_D, $opt_h, $opt_t); getopts('a:dD@ht:') - or &HELP_MESSAGE; + or HELP_MESSAGE(); # Handle the -h command -&HELP_MESSAGE if $opt_h; +HELP_MESSAGE() if $opt_h; die "Path to TOP not set, use -t option\n" unless $opt_t; diff --git a/src/tools/fullPathName.pl b/src/tools/fullPathName.pl index a553dbd3c..0b1bdc0dd 100644 --- a/src/tools/fullPathName.pl +++ b/src/tools/fullPathName.pl @@ -13,17 +13,56 @@ # might have trailing directory names that don't exist yet. use strict; +use warnings; + +use Getopt::Std; +$Getopt::Std::STANDARD_HELP_VERSION = 1; use FindBin qw($Bin); use lib ("$Bin/../../lib/perl", $Bin); -use Getopt::Std; use EPICS::Path; +use Pod::Usage; + +=head1 NAME + +fullPathName.pl - Convert a pathname to an absolute path + +=head1 SYNOPSIS + +B [B<-h>] /path/to/something + +=head1 DESCRIPTION + +The EPICS build system needs the ability to get the absolute path of a file or +directory that does not exist at the time. The AbsPath() function in the +EPICS::Path module provides the necessary functionality, which this script makes +available to the build system. The string which is returned on the standard +output stream has had any shell special characters escaped with a back-slash +(except on Windows). + +=head1 OPTIONS + +B understands the following options: + +=over 4 + +=item B<-h> + +Help, display this document as text. + +=back + +=cut + our ($opt_h); -$Getopt::Std::OUTPUT_HELP_VERSION = 1; -&HELP_MESSAGE if !getopts('h') || $opt_h || @ARGV != 1; +sub HELP_MESSAGE { + pod2usage(-exitval => 2, -verbose => $opt_h); +} + +HELP_MESSAGE() if !getopts('h') || $opt_h || @ARGV != 1; my $path = AbsPath(shift); @@ -32,8 +71,11 @@ $path =~ s/([!"\$&'\(\)*,:;<=>?\[\\\]^`{|}])/\\$1/g unless $^O eq 'MSWin32'; print "$path\n"; +=head1 COPYRIGHT AND LICENSE -sub HELP_MESSAGE { - print STDERR "Usage: fullPathName.pl [-h] pathname\n"; - exit 2; -} +Copyright (C) 2009 UChicago Argonne LLC, as Operator of Argonne National +Laboratory. + +This software is distributed under the terms of the EPICS Open License. + +=cut diff --git a/src/tools/munch.pl b/src/tools/munch.pl index f6c0d6e08..2aee71344 100644 --- a/src/tools/munch.pl +++ b/src/tools/munch.pl @@ -7,19 +7,65 @@ # EPICS BASE is distributed subject to a Software License Agreement found # in the file LICENSE that is included with this distribution. #************************************************************************* + # $Revision-Id$ -# -# Creates a ctdt.c file of C++ static constructors and destructors, -# as required for all vxWorks binaries containing C++ code. use strict; use warnings; + use Getopt::Std; +$Getopt::Std::STANDARD_HELP_VERSION = 1; -our ($opt_o); +use Pod::Usage; -$Getopt::Std::OUTPUT_HELP_VERSION = 1; -&HELP_MESSAGE if !getopts('o:') || @ARGV != 1; +=head1 NAME + +munch.pl - Combine C++ static constructors and destructors for libraries + +=head1 SYNOPSIS + +B [B<-h>] [B<-o> file_ctdt.c] file.nm + +=head1 DESCRIPTION + +Creates a ctdt.c file of C++ static constructors and destructors, as required +for all vxWorks binaries containing C++ code. The VxWorks linking loader and +unloader only call one constructor function, so the code generated by this +script is needed to ensure that all the static constructors and destructors in +the library module will be executed at the appropriate time. + +The file input to this function is generated by running the B program on the +library concerned. The processing algorithm was reverse-engineered from the +B scripts provided with various versions of VxWorks up to 6.9. + +=head1 OPTIONS + +B understands the following options: + +=over 4 + +=item B<-h> + +Help, display this document as text. + +=item B<-o> file_ctdt.c + +Name of the output file to be created. + +=back + +If no output filename is set with a B<-o> option, the generated C code will be +sent to the standard output stream. + +=cut + +our ($opt_o, $opt_h); + +sub HELP_MESSAGE { + pod2usage(-exitval => 2, -verbose => $opt_h); +} + +HELP_MESSAGE() if !getopts('ho:') || $opt_h || @ARGV != 1; # Is exception handler frame info required? my $need_eh_frame = 0; @@ -154,7 +200,11 @@ sub cDecl { return $decl; } -sub HELP_MESSAGE { - print STDERR "Usage: munch.pl [-o file_ctdt.c] file.nm\n"; - exit 2; -} +=head1 COPYRIGHT AND LICENSE + +Copyright (C) 2013 UChicago Argonne LLC, as Operator of Argonne National +Laboratory. + +This software is distributed under the terms of the EPICS Open License. + +=cut diff --git a/src/tools/podRemove.pl b/src/tools/podRemove.pl index c44f16a3d..66f09e308 100644 --- a/src/tools/podRemove.pl +++ b/src/tools/podRemove.pl @@ -6,17 +6,57 @@ # in file LICENSE that is included with this distribution. #************************************************************************* -# $Id$ +# $Revision-Id$ use strict; use warnings; use Getopt::Std; +$Getopt::Std::STANDARD_HELP_VERSION = 1; -our ($opt_o); +use Pod::Usage; -$Getopt::Std::OUTPUT_HELP_VERSION = 1; -&HELP_MESSAGE if !getopts('o:') || @ARGV != 1; +=head1 NAME + +podRemove.pl - Remove POD directives from files + +=head1 SYNOPSIS + +B [B<-h>] [B<-o> file] file.pod + +=head1 DESCRIPTION + +Removes Perl's POD documentation from a text file + +=head1 OPTIONS + +B understands the following options: + +=over 4 + +=item B<-h> + +Help, display this document as text. + +=item B<-o> file + +Name of the output file to be created. + +=back + +If no output filename is set, the file created will be named after the input +file, removing any directory components in the path and removing any .pod file +extension. + +=cut + +our ($opt_o, $opt_h); + +sub HELP_MESSAGE { + pod2usage(-exitval => 2, -verbose => $opt_h); +} + +HELP_MESSAGE() if !getopts('ho:') || $opt_h || @ARGV != 1; my $infile = shift @ARGV; @@ -43,7 +83,11 @@ while (<$inp>) { close $out; close $inp; -sub HELP_MESSAGE { - print STDERR "Usage: podRemove.pl [-o file] file.pod\n"; - exit 2; -} +=head1 COPYRIGHT AND LICENSE + +Copyright (C) 2015 UChicago Argonne LLC, as Operator of Argonne National +Laboratory. + +This software is distributed under the terms of the EPICS Open License. + +=cut diff --git a/src/tools/podToHtml.pl b/src/tools/podToHtml.pl index d5817c797..e950f6c6e 100644 --- a/src/tools/podToHtml.pl +++ b/src/tools/podToHtml.pl @@ -6,21 +6,25 @@ # in file LICENSE that is included with this distribution. #************************************************************************* -# $Id$ +# $Revision-Id$ use strict; use warnings; use Getopt::Std; +$Getopt::Std::STANDARD_HELP_VERSION = 1; + use Pod::Simple::HTML; +use Pod::Usage; + =head1 NAME -podToHtml.pl - convert EPICS .pod files to .html +podToHtml.pl - Convert EPICS .pod files to .html =head1 SYNOPSIS -B [B<-s>] [B<-o> file.html] file.pod +B [B<-h>] [B<-s>] [B<-o> file.html] file.pod =head1 DESCRIPTION @@ -33,10 +37,14 @@ is calculated based on the number of components in the path to the input file. =head1 OPTIONS -I understands the following options: +B understands the following options: =over 4 +=item B<-h> + +Help, display this document as text. + =item B<-s> Indicates that the first component of the input file path is not part of the @@ -55,11 +63,14 @@ extension with .html. =cut -our $opt_o; +our ($opt_o, $opt_h); our $opt_s = 0; -$Getopt::Std::OUTPUT_HELP_VERSION = 1; -&HELP_MESSAGE if !getopts('o:s') || @ARGV != 1; +sub HELP_MESSAGE { + pod2usage(-exitval => 2, -verbose => $opt_h); +} + +HELP_MESSAGE() if !getopts('ho:s') || $opt_h || @ARGV != 1; my $infile = shift @ARGV; @@ -89,14 +100,9 @@ $podHtml->run; print $out $html; close $out; -sub HELP_MESSAGE { - print STDERR "Usage: podToHtml.pl [-s] [-o file.html] file.pod\n"; - exit 2; -} - =head1 COPYRIGHT AND LICENSE -Copyright (C) 2010 UChicago Argonne LLC, as Operator of Argonne National +Copyright (C) 2013 UChicago Argonne LLC, as Operator of Argonne National Laboratory. This software is distributed under the terms of the EPICS Open License. diff --git a/src/tools/registerRecordDeviceDriver.pl b/src/tools/registerRecordDeviceDriver.pl index 368d7acea..ea93a0d60 100644 --- a/src/tools/registerRecordDeviceDriver.pl +++ b/src/tools/registerRecordDeviceDriver.pl @@ -30,7 +30,7 @@ my @path = map { split /[:;]/ } @opt_I; # FIXME: Broken on Win32? my ($file, $subname, $bldTop) = @ARGV; my $dbd = DBD->new(); -&ParseDBD($dbd, &Readfile($file, "", \@path)); +ParseDBD($dbd, Readfile($file, "", \@path)); if ($opt_D) { # Output dependencies only my %filecount;