Commit | Line | Data |
360aca43 |
1 | #!/usr/local/bin/perl |
2 | |
3 | use Config; |
4 | use File::Basename qw(&basename &dirname); |
933fea7f |
5 | use Cwd; |
360aca43 |
6 | |
7 | # List explicitly here the variables you want Configure to |
8 | # generate. Metaconfig only looks for shell variables, so you |
9 | # have to mention them as if they were shell variables, not |
10 | # %Config entries. Thus you write |
11 | # $startperl |
12 | # to ensure Configure will look for $Config{startperl}. |
13 | |
3b5ca523 |
14 | # This forces PL files to create target in same directory as PL file. |
15 | # This is so that make depend always knows where to find PL derivatives. |
933fea7f |
16 | $origdir = cwd; |
3b5ca523 |
17 | chdir(dirname($0)); |
18 | ($file = basename($0)) =~ s/\.PL$//; |
19 | $file =~ s/\.pl$// |
933fea7f |
20 | if ($^O eq 'VMS' or $^O eq 'os2' or $^O eq 'dos'); # "case-forgiving" |
360aca43 |
21 | |
22 | open OUT,">$file" or die "Can't create $file: $!"; |
23 | |
24 | print "Extracting $file (with variable substitutions)\n"; |
25 | |
26 | # In this section, perl variables will be expanded during extraction. |
27 | # You can use $Config{...} to use Configure variables. |
28 | |
29 | print OUT <<"!GROK!THIS!"; |
30 | $Config{'startperl'} |
31 | eval 'exec perl -S \$0 "\$@"' |
32 | if 0; |
33 | !GROK!THIS! |
34 | |
35 | # In the following, perl variables are not expanded during extraction. |
36 | |
37 | print OUT <<'!NO!SUBS!'; |
38 | ############################################################################# |
39 | # podchecker -- command to invoke the podchecker function in Pod::Checker |
40 | # |
41 | # Derived from Tom Christiansen's pod2text script. |
42 | # (with extensive modifications) |
43 | # |
44 | # Copyright (c) 1998 Bradford Appleton. All rights reserved. |
45 | # This file is part of "PodParser". PodParser is free software; |
46 | # you can redistribute it and/or modify it under the same terms |
47 | # as Perl itself. |
48 | ############################################################################# |
49 | |
50 | use strict; |
51 | use diagnostics; |
52 | |
53 | =head1 NAME |
54 | |
55 | podchecker - check the syntax of POD format documentation files |
56 | |
57 | =head1 SYNOPSIS |
58 | |
59 | B<podchecker> [B<-help>] [B<-man>] [I<file>S< >...] |
60 | |
61 | =head1 OPTIONS AND ARGUMENTS |
62 | |
63 | =over 8 |
64 | |
65 | =item B<-help> |
66 | |
67 | Print a brief help message and exit. |
68 | |
69 | =item B<-man> |
70 | |
71 | Print the manual page and exit. |
72 | |
73 | =item I<file> |
74 | |
75 | The pathname of a POD file to syntax-check (defaults to standard input). |
76 | |
77 | =back |
78 | |
79 | =head1 DESCRIPTION |
80 | |
81 | B<podchecker> will read the given input files looking for POD |
82 | syntax errors in the POD documentation and will print any errors |
83 | it find to STDERR. At the end, it will print a status message |
84 | indicating the number of errors found. |
85 | |
86 | B<podchecker> invokes the B<podchecker()> function exported by B<Pod::Checker> |
87 | Please see L<Pod::Checker/podchecker()> for more details. |
88 | |
89 | =head1 SEE ALSO |
90 | |
91 | L<Pod::Parser> and L<Pod::Checker> |
92 | |
93 | =head1 AUTHOR |
94 | |
95 | Brad Appleton E<lt>bradapp@enteract.comE<gt> |
96 | |
97 | Based on code for B<Pod::Text::pod2text(1)> written by |
98 | Tom Christiansen E<lt>tchrist@mox.perl.comE<gt> |
99 | |
100 | =cut |
101 | |
102 | |
103 | use Pod::Checker; |
104 | use Pod::Usage; |
105 | use Getopt::Long; |
106 | |
107 | ## Define options |
108 | my %options = ( |
109 | "help" => 0, |
110 | "man" => 0, |
111 | ); |
112 | |
113 | ## Parse options |
114 | GetOptions(\%options, "help", "man") || pod2usage(2); |
115 | pod2usage(1) if ($options{help}); |
116 | pod2usage(-verbose => 2) if ($options{man}); |
117 | |
118 | ## Dont default to STDIN if connected to a terminal |
119 | pod2usage(2) if ((@ARGV == 0) && (-t STDIN)); |
120 | |
121 | ## Invoke podchecker() |
122 | if(@ARGV) { |
123 | for (@ARGV) { podchecker($_) }; |
124 | } else { |
125 | podchecker("<&STDIN"); |
126 | } |
127 | |
128 | !NO!SUBS! |
129 | |
130 | close OUT or die "Can't close $file: $!"; |
131 | chmod 0755, $file or die "Can't reset permissions for $file: $!\n"; |
132 | exec("$Config{'eunicefix'} $file") if $Config{'eunicefix'} ne ':'; |
933fea7f |
133 | chdir $origdir; |