This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
describe encoding status of DATA handle
[perl5.git] / pod / buildtoc
index 61ea096..004a726 100644 (file)
@@ -1,13 +1,12 @@
 #!/usr/bin/perl -w
 
 use strict;
-use vars qw(%Found $Quiet);
 use File::Spec;
-use File::Find;
 use FindBin;
 use Text::Wrap;
 use Getopt::Long;
 
+our $Quiet;
 no locale;
 
 # Assumption is that we're either already being run from the top level (*nix,
@@ -15,41 +14,17 @@ no locale;
 BEGIN {
   my $Top = File::Spec->catdir($FindBin::Bin, File::Spec->updir);
   chdir $Top or die "Can't chdir to $Top: $!";
-  require 'Porting/pod_lib.pl';
+  require './Porting/pod_lib.pl';
 }
 
 die "$0: Usage: $0 [--quiet]\n"
-    unless GetOptions (quiet => \$Quiet) && !@ARGV;
+    unless GetOptions ('q|quiet' => \$Quiet) && !@ARGV;
 
 my $state = get_pod_metadata(0, sub { warn @_ if @_ }, 'pod/perltoc.pod');
 
-# Find all the modules
-# manpages not to be installed
-my %do_not_install = map { ($_ => 1) }
-    qw(Pod::Functions XS::APItest XS::Typemap);
-
-my %done;
-find({no_chdir => 1,
-      wanted => sub {
-          if (/\.p(od|m)$/) {
-              return if m!(?:^|/)t/!;
-              return if m!lib/Net/FTP/.+\.pm!; # Hi, Graham! :-)
-              return if s!\.pm\z!.pod! && -e $_;
-              s!\.pod\z!!;
-              s!\Alib/!!;
-              s!/!::!g;
-              my_die("Duplicate files for $_, '$done{$_}' and '$File::Find::name'")
-                  if exists $done{$_};
-              $done{$_} = $File::Find::name;
-
-              return if $do_not_install{$_};
-              return if is_duplicate_pod($File::Find::name);
-
-              $Found{/\A[a-z]/ ? 'PRAGMA' : 'MODULE'}{$_} = $File::Find::name;
-          }
-      }}, 'lib');
-
-my_die "Can't find any pods!\n" unless %done;
+my $found = pods_to_install();
+
+my_die "Can't find any pods!\n" unless %$found;
 
 # Accumulating everything into a lexical before writing to disk dates from the
 # time when this script also provided the functionality of regen/pod_rules.pl
@@ -66,6 +41,8 @@ my $roffitall;
        # This file is autogenerated by buildtoc from all the other pods.
        # Edit those files and run $0 to effect changes.
 
+       =encoding UTF-8
+
        =head1 NAME
 
        perltoc - perl documentation table of contents
@@ -95,9 +72,9 @@ foreach my $type (qw(PRAGMA MODULE)) {
 
 EOPOD2B
 
-    foreach my $name (sort keys %{$Found{$type}}) {
+    foreach my $name (sort keys %{$found->{$type}}) {
         $roffitall .= "    \$libdir/$name.3 \\\n";
-        podset($name, $Found{$type}{$name});
+        podset($name, $found->{$type}{$name});
     }
 }
 
@@ -209,7 +186,7 @@ my ($inhead1, $inhead2, $initem);
 sub podset {
     my ($pod, $file) = @_;
 
-    open my $fh, '<', $file or my_die "Can't open file '$file' for $pod: $!";
+    open my $fh, '<:raw', $file or my_die "Can't open file '$file' for $pod: $!";
 
     local *_;
     my $found_pod;
@@ -298,9 +275,4 @@ sub unitem {
     $initem = 0;
 }
 
-# Local variables:
-# cperl-indent-level: 4
-# indent-tabs-mode: nil
-# End:
-#
 # ex: set ts=8 sts=4 sw=4 et: