cygwin port
[p5sagit/p5-mst-13.2.git] / utils / perldoc.PL
index 7dc478b..7147607 100644 (file)
@@ -51,12 +51,12 @@ if (@ARGV<1) {
        my $me = $0;            # Editing $0 is unportable
        $me =~ s,.*/,,;
        die <<EOF;
-Usage: $me [-h] [-r] [-i] [-v] [-t] [-u] [-m] [-l] [-F] [-X] PageName|ModuleName|ProgramName
+Usage: $me [-h] [-r] [-i] [-v] [-t] [-u] [-m] [-n program] [-l] [-F] [-X] PageName|ModuleName|ProgramName
        $me -f PerlFunc
        $me -q FAQKeywords
 
 The -h option prints more help.  Also try "perldoc perldoc" to get
-aquainted with the system.
+acquainted with the system.
 EOF
 }
 
@@ -87,6 +87,7 @@ Options:
              (-t is the default on win32)
     -u  Display unformatted pod text
     -m   Display module's file in its entirety
+    -n   Specify replacement for nroff
     -l   Display the module's file name
     -F   Arguments are file names, not modules
     -v  Verbosely describe what's going on
@@ -121,7 +122,7 @@ if (defined $ENV{"PERLDOC"}) {
 }
 !NO!SUBS!
 
-my $getopts = "mhtluvriFf:Xq:";
+my $getopts = "mhtluvriFf:Xq:n:";
 print OUT <<"!GET!OPTS!";
 
 use vars qw( @{[map "\$opt_$_", ($getopts =~ /\w/g)]} );
@@ -132,6 +133,7 @@ getopts("$getopts") || usage;
 print OUT <<'!NO!SUBS!';
 
 usage if $opt_h;
+$opt_n = "nroff" if !$opt_n;
 
 my $podidx;
 if ($opt_X) {
@@ -243,6 +245,7 @@ sub minus_f_nocase {
 
 sub check_file {
     my($dir,$file) = @_;
+    return "" if length $dir and not -d $dir;
     if ($opt_m) {
        return minus_f_nocase($dir,$file);
     }
@@ -278,6 +281,8 @@ sub searchfor {
                     $ret = check_file $dir,"$s.bat")
                or ( $ret = check_file "$dir/pod","$s.pod")
                or ( $ret = check_file "$dir/pod",$s)
+               or ( $ret = check_file "$dir/pods","$s.pod")
+               or ( $ret = check_file "$dir/pods",$s)
        ) {
            return $ret;
        }
@@ -318,7 +323,7 @@ sub printout {
        close OUT;
     }
     elsif (not $opt_u) {
-       my $cmd = "pod2man --lax $file | nroff -man";
+       my $cmd = "pod2man --lax $_ | $opt_n -man";
        $cmd .= " | col -x" if $^O =~ /hpux/;
        my $rslt = `$cmd`;
        $rslt = filter_nroff($rslt) if $filter;
@@ -554,6 +559,13 @@ if ($opt_q) {
     local @ARGV = @found;      # I'm lazy, sue me.
     my $found = 0;
     my %found_in;
+    my $rx = eval { qr/$opt_q/ };
+    die <<EOD unless $rx;
+Invalid regular expression '$opt_q' given as -q pattern:
+  $@
+Did you mean \\Q$opt_q ?
+
+EOD
 
     while (<>) {
        if (/^=head2\s+.*(?:$opt_q)/oi) {
@@ -708,14 +720,18 @@ and others.
 =cut
 
 #
+# Version 1.15: Tue Aug 24 01:50:20 EST 1999
+#       Charles Wilson <cwilson@ece.gatech.edu>
+#      changed /pod/ directory to /pods/ for cygwin
+#         to support cygwin/win32
 # Version 1.14: Wed Jul 15 01:50:20 EST 1998
 #       Robin Barker <rmb1@cise.npl.co.uk>
 #      -strict, -w cleanups
 # Version 1.13: Fri Feb 27 16:20:50 EST 1997
-#       Gurusamy Sarathy <gsar@umich.edu>
+#       Gurusamy Sarathy <gsar@activestate.com>
 #      -doc tweaks for -F and -X options
 # Version 1.12: Sat Apr 12 22:41:09 EST 1997
-#       Gurusamy Sarathy <gsar@umich.edu>
+#       Gurusamy Sarathy <gsar@activestate.com>
 #      -various fixes for win32
 # Version 1.11: Tue Dec 26 09:54:33 EST 1995
 #       Kenneth Albanowski <kjahds@kjahds.com>