1*0Sstevel@tonic-gate#!/usr/local/bin/perl 2*0Sstevel@tonic-gate 3*0Sstevel@tonic-gateuse Config; 4*0Sstevel@tonic-gateuse File::Basename qw(&basename &dirname); 5*0Sstevel@tonic-gateuse Cwd; 6*0Sstevel@tonic-gate 7*0Sstevel@tonic-gate# List explicitly here the variables you want Configure to 8*0Sstevel@tonic-gate# generate. Metaconfig only looks for shell variables, so you 9*0Sstevel@tonic-gate# have to mention them as if they were shell variables, not 10*0Sstevel@tonic-gate# %Config entries. Thus you write 11*0Sstevel@tonic-gate# $startperl 12*0Sstevel@tonic-gate# to ensure Configure will look for $Config{startperl}. 13*0Sstevel@tonic-gate 14*0Sstevel@tonic-gate# This forces PL files to create target in same directory as PL file. 15*0Sstevel@tonic-gate# This is so that make depend always knows where to find PL derivatives. 16*0Sstevel@tonic-gate$origdir = cwd; 17*0Sstevel@tonic-gatechdir(dirname($0)); 18*0Sstevel@tonic-gate($file = basename($0)) =~ s/\.PL$//; 19*0Sstevel@tonic-gate$file =~ s/\.pl$// 20*0Sstevel@tonic-gate if ($^O eq 'VMS' or $^O eq 'os2' or $^O eq 'dos'); # "case-forgiving" 21*0Sstevel@tonic-gate$file .= '.com' if $^O eq 'VMS'; 22*0Sstevel@tonic-gate 23*0Sstevel@tonic-gateopen OUT,">$file" or die "Can't create $file: $!"; 24*0Sstevel@tonic-gate 25*0Sstevel@tonic-gateprint "Extracting $file (with variable substitutions)\n"; 26*0Sstevel@tonic-gate 27*0Sstevel@tonic-gate# In this section, perl variables will be expanded during extraction. 28*0Sstevel@tonic-gate# You can use $Config{...} to use Configure variables. 29*0Sstevel@tonic-gate 30*0Sstevel@tonic-gateprint OUT <<"!GROK!THIS!"; 31*0Sstevel@tonic-gate$Config{'startperl'} 32*0Sstevel@tonic-gate eval 'exec perl -S \$0 "\$@"' 33*0Sstevel@tonic-gate if 0; 34*0Sstevel@tonic-gate!GROK!THIS! 35*0Sstevel@tonic-gate 36*0Sstevel@tonic-gate# In the following, perl variables are not expanded during extraction. 37*0Sstevel@tonic-gate 38*0Sstevel@tonic-gateprint OUT <<'!NO!SUBS!'; 39*0Sstevel@tonic-gate############################################################################# 40*0Sstevel@tonic-gate# podchecker -- command to invoke the podchecker function in Pod::Checker 41*0Sstevel@tonic-gate# 42*0Sstevel@tonic-gate# Copyright (c) 1998-2000 by Bradford Appleton. All rights reserved. 43*0Sstevel@tonic-gate# This file is part of "PodParser". PodParser is free software; 44*0Sstevel@tonic-gate# you can redistribute it and/or modify it under the same terms 45*0Sstevel@tonic-gate# as Perl itself. 46*0Sstevel@tonic-gate############################################################################# 47*0Sstevel@tonic-gate 48*0Sstevel@tonic-gateuse strict; 49*0Sstevel@tonic-gate#use diagnostics; 50*0Sstevel@tonic-gate 51*0Sstevel@tonic-gate=head1 NAME 52*0Sstevel@tonic-gate 53*0Sstevel@tonic-gatepodchecker - check the syntax of POD format documentation files 54*0Sstevel@tonic-gate 55*0Sstevel@tonic-gate=head1 SYNOPSIS 56*0Sstevel@tonic-gate 57*0Sstevel@tonic-gateB<podchecker> [B<-help>] [B<-man>] [B<-(no)warnings>] [I<file>S< >...] 58*0Sstevel@tonic-gate 59*0Sstevel@tonic-gate=head1 OPTIONS AND ARGUMENTS 60*0Sstevel@tonic-gate 61*0Sstevel@tonic-gate=over 8 62*0Sstevel@tonic-gate 63*0Sstevel@tonic-gate=item B<-help> 64*0Sstevel@tonic-gate 65*0Sstevel@tonic-gatePrint a brief help message and exit. 66*0Sstevel@tonic-gate 67*0Sstevel@tonic-gate=item B<-man> 68*0Sstevel@tonic-gate 69*0Sstevel@tonic-gatePrint the manual page and exit. 70*0Sstevel@tonic-gate 71*0Sstevel@tonic-gate=item B<-warnings> B<-nowarnings> 72*0Sstevel@tonic-gate 73*0Sstevel@tonic-gateTurn on/off printing of warnings. Repeating B<-warnings> increases the 74*0Sstevel@tonic-gatewarning level, i.e. more warnings are printed. Currently increasing to 75*0Sstevel@tonic-gatelevel two causes flagging of unescaped "E<lt>,E<gt>" characters. 76*0Sstevel@tonic-gate 77*0Sstevel@tonic-gate=item I<file> 78*0Sstevel@tonic-gate 79*0Sstevel@tonic-gateThe pathname of a POD file to syntax-check (defaults to standard input). 80*0Sstevel@tonic-gate 81*0Sstevel@tonic-gate=back 82*0Sstevel@tonic-gate 83*0Sstevel@tonic-gate=head1 DESCRIPTION 84*0Sstevel@tonic-gate 85*0Sstevel@tonic-gateB<podchecker> will read the given input files looking for POD 86*0Sstevel@tonic-gatesyntax errors in the POD documentation and will print any errors 87*0Sstevel@tonic-gateit find to STDERR. At the end, it will print a status message 88*0Sstevel@tonic-gateindicating the number of errors found. 89*0Sstevel@tonic-gate 90*0Sstevel@tonic-gateDirectories are ignored, an appropriate warning message is printed. 91*0Sstevel@tonic-gate 92*0Sstevel@tonic-gateB<podchecker> invokes the B<podchecker()> function exported by B<Pod::Checker> 93*0Sstevel@tonic-gatePlease see L<Pod::Checker/podchecker()> for more details. 94*0Sstevel@tonic-gate 95*0Sstevel@tonic-gate=head1 RETURN VALUE 96*0Sstevel@tonic-gate 97*0Sstevel@tonic-gateB<podchecker> returns a 0 (zero) exit status if all specified 98*0Sstevel@tonic-gatePOD files are ok. 99*0Sstevel@tonic-gate 100*0Sstevel@tonic-gate=head1 ERRORS 101*0Sstevel@tonic-gate 102*0Sstevel@tonic-gateB<podchecker> returns the exit status 1 if at least one of 103*0Sstevel@tonic-gatethe given POD files has syntax errors. 104*0Sstevel@tonic-gate 105*0Sstevel@tonic-gateThe status 2 indicates that at least one of the specified 106*0Sstevel@tonic-gatefiles does not contain I<any> POD commands. 107*0Sstevel@tonic-gate 108*0Sstevel@tonic-gateStatus 1 overrides status 2. If you want unambigouus 109*0Sstevel@tonic-gateresults, call B<podchecker> with one single argument only. 110*0Sstevel@tonic-gate 111*0Sstevel@tonic-gate=head1 SEE ALSO 112*0Sstevel@tonic-gate 113*0Sstevel@tonic-gateL<Pod::Parser> and L<Pod::Checker> 114*0Sstevel@tonic-gate 115*0Sstevel@tonic-gate=head1 AUTHORS 116*0Sstevel@tonic-gate 117*0Sstevel@tonic-gateBrad Appleton E<lt>bradapp@enteract.comE<gt>, 118*0Sstevel@tonic-gateMarek Rouchal E<lt>marek@saftsack.fs.uni-bayreuth.deE<gt> 119*0Sstevel@tonic-gate 120*0Sstevel@tonic-gateBased on code for B<Pod::Text::pod2text(1)> written by 121*0Sstevel@tonic-gateTom Christiansen E<lt>tchrist@mox.perl.comE<gt> 122*0Sstevel@tonic-gate 123*0Sstevel@tonic-gate=cut 124*0Sstevel@tonic-gate 125*0Sstevel@tonic-gate 126*0Sstevel@tonic-gateuse Pod::Checker; 127*0Sstevel@tonic-gateuse Pod::Usage; 128*0Sstevel@tonic-gateuse Getopt::Long; 129*0Sstevel@tonic-gate 130*0Sstevel@tonic-gate## Define options 131*0Sstevel@tonic-gatemy %options; 132*0Sstevel@tonic-gate 133*0Sstevel@tonic-gate## Parse options 134*0Sstevel@tonic-gateGetOptions(\%options, qw(help man warnings+ nowarnings)) || pod2usage(2); 135*0Sstevel@tonic-gatepod2usage(1) if ($options{help}); 136*0Sstevel@tonic-gatepod2usage(-verbose => 2) if ($options{man}); 137*0Sstevel@tonic-gate 138*0Sstevel@tonic-gateif($options{nowarnings}) { 139*0Sstevel@tonic-gate $options{warnings} = 0; 140*0Sstevel@tonic-gate} 141*0Sstevel@tonic-gateelsif(!defined $options{warnings}) { 142*0Sstevel@tonic-gate $options{warnings} = 1; # default is warnings on 143*0Sstevel@tonic-gate} 144*0Sstevel@tonic-gate 145*0Sstevel@tonic-gate## Dont default to STDIN if connected to a terminal 146*0Sstevel@tonic-gatepod2usage(2) if ((@ARGV == 0) && (-t STDIN)); 147*0Sstevel@tonic-gate 148*0Sstevel@tonic-gate## Invoke podchecker() 149*0Sstevel@tonic-gatemy $status = 0; 150*0Sstevel@tonic-gate@ARGV = qw(-) unless(@ARGV); 151*0Sstevel@tonic-gatefor my $podfile (@ARGV) { 152*0Sstevel@tonic-gate if($podfile eq '-') { 153*0Sstevel@tonic-gate $podfile = "<&STDIN"; 154*0Sstevel@tonic-gate } 155*0Sstevel@tonic-gate elsif(-d $podfile) { 156*0Sstevel@tonic-gate warn "podchecker: Warning: Ignoring directory '$podfile'\n"; 157*0Sstevel@tonic-gate next; 158*0Sstevel@tonic-gate } 159*0Sstevel@tonic-gate my $errors = 160*0Sstevel@tonic-gate podchecker($podfile, undef, '-warnings' => $options{warnings}); 161*0Sstevel@tonic-gate if($errors > 0) { 162*0Sstevel@tonic-gate # errors occurred 163*0Sstevel@tonic-gate $status = 1; 164*0Sstevel@tonic-gate printf STDERR ("%s has %d pod syntax %s.\n", 165*0Sstevel@tonic-gate $podfile, $errors, 166*0Sstevel@tonic-gate ($errors == 1) ? "error" : "errors"); 167*0Sstevel@tonic-gate } 168*0Sstevel@tonic-gate elsif($errors < 0) { 169*0Sstevel@tonic-gate # no pod found 170*0Sstevel@tonic-gate $status = 2 unless($status); 171*0Sstevel@tonic-gate print STDERR "$podfile does not contain any pod commands.\n"; 172*0Sstevel@tonic-gate } 173*0Sstevel@tonic-gate else { 174*0Sstevel@tonic-gate print STDERR "$podfile pod syntax OK.\n"; 175*0Sstevel@tonic-gate } 176*0Sstevel@tonic-gate} 177*0Sstevel@tonic-gateexit $status; 178*0Sstevel@tonic-gate 179*0Sstevel@tonic-gate!NO!SUBS! 180*0Sstevel@tonic-gate 181*0Sstevel@tonic-gateclose OUT or die "Can't close $file: $!"; 182*0Sstevel@tonic-gatechmod 0755, $file or die "Can't reset permissions for $file: $!\n"; 183*0Sstevel@tonic-gateexec("$Config{'eunicefix'} $file") if $Config{'eunicefix'} ne ':'; 184*0Sstevel@tonic-gatechdir $origdir; 185