Create Porting/pod_rules.pl, with all non perltoc.pod code from buildtoc.
authorNicholas Clark <nick@ccl4.org>
Tue, 8 Nov 2011 14:11:46 +0000 (15:11 +0100)
committerNicholas Clark <nick@ccl4.org>
Fri, 18 Nov 2011 10:08:57 +0000 (11:08 +0100)
pod/buildtoc now only generates pod/perltoc.pod, and only takes a --quiet
option. All the other file (re)generation code is now in Porting/pod_rules.pl.

This splits functionality which generates a new file at build time from
functionality for maintainers, which edits files in place. This permits the
unwinding of some of commit 02cc404a20a8a345, which achieved net
simplification in pod/buildtoc by merging code paths dealing with new files
(only pod/perltoc.pod) and existing files being edited.

pod_rules.pl has a --tap option, instead of buildtoc's non-standard --test
option, and defaults to --build-all if no arguments are passed. As buildtoc
now does one job, it no longer takes a --build-toc option, hence all the
Makefiles which call it need updating.

MANIFEST
Makefile.SH
Porting/pod_rules.pl [new file with mode: 0644]
pod/Makefile.SH
pod/buildtoc
t/porting/buildtoc.t
vms/descrip_mms.template
win32/Makefile
win32/makefile.mk

index b9a399b..e2a3c90 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -4696,6 +4696,7 @@ Porting/newtests-perldelta.pl     Generate Perldelta stub for newly added tests
 Porting/perldelta_template.pod Template for creating new perldelta.pod files
 Porting/perlhist_calculate.pl          Perform calculations to update perlhist
 Porting/pod_lib.pl             Code for handling pod.lst
+Porting/pod_rules.pl           generate lists of pod files for Makefiles
 Porting/podtidy                        Reformat pod using Pod::Tidy
 Porting/pumpkin.pod            Guidelines and hints for Perl maintainers
 Porting/README.y2038           Perl notes for the 2038 fix
index 19257b0..94952bd 100755 (executable)
@@ -1045,7 +1045,7 @@ uni.data: $(MINIPERL_EXE) $(CONFIGPM) lib/unicore/mktables $(nonxs_ext)
 # But also this ensures that all extensions are built before we try to scan
 # them, which picks up Devel::PPPort's documentation.
 pod/perltoc.pod: $(perltoc_pod_prereqs)  $(PERL_EXE) $(ext) pod/buildtoc
-       $(RUN_PERL) -f -Ilib pod/buildtoc --build-toc -q
+       $(RUN_PERL) -f -Ilib pod/buildtoc -q
 
 pod/perlapi.pod: pod/perlintern.pod
 
diff --git a/Porting/pod_rules.pl b/Porting/pod_rules.pl
new file mode 100644 (file)
index 0000000..d7b7842
--- /dev/null
@@ -0,0 +1,311 @@
+#!/usr/bin/perl -w
+
+use strict;
+use vars qw(%Build %Targets $Verbose $Test);
+use Text::Tabs;
+use Text::Wrap;
+use Getopt::Long;
+use Carp;
+
+# Generate the sections of files listed in %Targets from pod.lst
+# Mostly these are rules in Makefiles
+#
+# --verbose gives slightly more output
+# --build-all tries to build everything
+# --build-foo updates foo as follows
+# --showfiles shows the files to be changed
+# --test exit if perl.pod, pod.lst, MANIFEST are consistent, and regenerated
+#   files are up to date, die otherwise.
+
+%Targets = (
+            manifest => 'MANIFEST',
+            perlpod => 'pod/perl.pod',
+            vms => 'vms/descrip_mms.template',
+            nmake => 'win32/Makefile',
+            dmake => 'win32/makefile.mk',
+            podmak => 'win32/pod.mak',
+            unix => 'Makefile.SH',
+            # plan9 =>  'plan9/mkfile',
+           );
+
+require 'Porting/pod_lib.pl';
+sub my_die;
+
+# process command-line switches
+{
+    my @files = keys %Targets;
+    my $filesopts = join(" | ", map { "--build-$_" } "all", sort @files);
+    my $showfiles;
+    my %build_these;
+    die "$0: Usage: $0 [--verbose] [--showfiles] [$filesopts]\n"
+        unless GetOptions (verbose => \$Verbose,
+                           showfiles => \$showfiles,
+                           tap => \$Test,
+                           map {+"build-$_", \$build_these{$_}} @files, 'all')
+            && !@ARGV;
+    if ($build_these{all}) {
+        %Build = %Targets;
+    } else {
+        while (my ($file, $want) = each %build_these) {
+            $Build{$file} = $Targets{$file} if $want;
+        }
+        # Default to --build-all if no targets given.
+        %Build = %Targets if !%Build;
+    }
+    if ($showfiles) {
+        print join(" ", sort { lc $a cmp lc $b } values %Build), "\n";
+        exit(0);
+    }
+}
+
+if ($Verbose) {
+    print "I will be building $_\n" foreach keys %Build;
+}
+
+my $state = get_pod_metadata();
+
+my $test = 1;
+if ($Test) {
+    printf "1..%d\n", 1 + scalar keys %Build;
+    if (@{$state->{inconsistent}}) {
+        print "not ok $test\n";
+        die @{$state->{inconsistent}};
+    }
+    print "ok $test\n";
+}
+else {
+    warn @{$state->{inconsistent}} if @{$state->{inconsistent}};
+}
+
+sub generate_perlpod {
+    my @output;
+    my $maxlength = 0;
+    foreach (@{$state->{master}}) {
+        my $flags = $_->[0];
+        next if $flags->{aux};
+        next if $flags->{perlpod_omit};
+
+        if (@$_ == 2) {
+            # Heading
+            push @output, "=head2 $_->[1]\n";
+        } elsif (@$_ == 5) {
+            # Section
+            my $start = " " x (4 + $flags->{indent}) . $_->[4];
+            $maxlength = length $start if length ($start) > $maxlength;
+            push @output, [$start, $_->[3]];
+        } elsif (@$_ == 0) {
+            # blank line
+            push @output, "\n";
+        } else {
+            my_die "Illegal length " . scalar @$_;
+        }
+    }
+    # want at least 2 spaces padding
+    $maxlength += 2;
+    $maxlength = ($maxlength + 3) & ~3;
+    # sprintf gives $1.....$2 where ... are spaces:
+    return unexpand (map {ref $_ ? sprintf "%-${maxlength}s%s\n", @$_ : $_}
+                     @output);
+}
+
+sub generate_manifest {
+    # Annoyingly, unexpand doesn't consider it good form to replace a single
+    # space before a tab with a tab
+    # Annoyingly (2) it returns read only values.
+    my @temp = unexpand (map {sprintf "%-32s%s", @$_} @_);
+    map {s/ \t/\t\t/g; $_} @temp;
+}
+
+sub generate_manifest_pod {
+    generate_manifest map {["pod/$_.pod", $state->{pods}{$_}]}
+        sort grep {
+            !$state->{copies}{"$_.pod"}
+                && !$state->{generated}{"$_.pod"}
+                    && !-e "$_.pod"
+                } keys %{$state->{pods}};
+}
+
+sub generate_manifest_readme {
+    generate_manifest sort {$a->[0] cmp $b->[0]}
+        ["README.vms", "Notes about installing the VMS port"],
+            map {["README.$_", $state->{readmes}{$_}]} keys %{$state->{readmes}};
+}
+
+sub generate_nmake_1 {
+    # XXX Fix this with File::Spec
+    (map {sprintf "\tcopy ..\\README.%-8s ..\\pod\\perl$_.pod\n", $_}
+     sort keys %{$state->{readmes}}),
+         (map {"\tcopy ..\\pod\\$state->{copies}{$_} ..\\pod\\$_\n"}
+          sort keys %{$state->{copies}});
+}
+
+# This doesn't have a trailing newline
+sub generate_nmake_2 {
+    # Spot the special case
+    local $Text::Wrap::columns = 76;
+    my $line = wrap ("\t    ", "\t    ",
+                     join " ", sort(keys %{$state->{copies}},
+                                    keys %{$state->{generated}},
+                                    map {"perl$_.pod"} keys %{$state->{readmes}}));
+    $line =~ s/$/ \\/mg;
+    $line =~ s/ \\$//;
+    $line;
+}
+
+sub generate_pod_mak {
+    my $variable = shift;
+    my @lines;
+    my $line = "\U$variable = " . join "\t\\\n\t",
+        map {"$_.$variable"} sort grep { $_ !~ m{/} } keys %{$state->{pods}};
+    # Special case
+    $line =~ s/.*perltoc.html.*\n//m;
+    $line;
+}
+
+sub verify_contiguous {
+    my ($name, $content, $what) = @_;
+    my $sections = () = $content =~ m/\0+/g;
+    croak("$0: $name contains no $what") if $sections < 1;
+    croak("$0: $name contains discontiguous $what") if $sections > 1;
+}
+
+sub do_manifest {
+    my ($name, $prev) = @_;
+    my @manifest =
+        grep {! m!^pod/[^.]+\.pod.*!}
+            grep {! m!^README\.(\S+)! || $state->{ignore}{$1}} split "\n", $prev;
+    join "\n", (
+                # Dictionary order - fold and handle non-word chars as nothing
+                map  { $_->[0] }
+                sort { $a->[1] cmp $b->[1] || $a->[0] cmp $b->[0] }
+                map  { my $f = lc $_; $f =~ s/[^a-z0-9\s]//g; [ $_, $f ] }
+                @manifest,
+                &generate_manifest_pod(),
+                &generate_manifest_readme()), '';
+}
+
+sub do_nmake {
+    my ($name, $makefile) = @_;
+    $makefile =~ s/^\tcopy \.\.\\README.*\n/\0/gm;
+    verify_contiguous($name, $makefile, 'README copies');
+    # Now remove the other copies that follow
+    1 while $makefile =~ s/\0\tcopy .*\n/\0/gm;
+    $makefile =~ s/\0+/join ("", &generate_nmake_1)/se;
+
+    $makefile =~ s{(-cd \$\(PODDIR\) && del /f[^\n]+).*?(-cd \.\.\\utils && del /f)}
+                  {"$1\n" . &generate_nmake_2."\n\t$2"}se;
+    $makefile;
+}
+
+# shut up used only once warning
+*do_dmake = *do_dmake = \&do_nmake;
+
+sub do_perlpod {
+    my ($name, $pod) = @_;
+
+    unless ($pod =~ s{(For\ ease\ of\ access,\ .*\n)
+                      (?:\s+[a-z]{4,}.*\n   #   fooo
+                      |=head.*\n            # =head foo
+                      |\s*\n                # blank line
+                   )+
+                 }
+                     {$1 . join "", &generate_perlpod}mxe) {
+        my_die "Failed to insert amendments in do_perlpod";
+    }
+    $pod;
+}
+
+sub do_podmak {
+    my ($name, $body) = @_;
+    foreach my $variable (qw(pod man html tex)) {
+        my_die "could not find $variable in $name"
+            unless $body =~ s{\n\U$variable\E = (?:[^\n]*\\\n)*[^\n]*}
+                             {"\n" . generate_pod_mak ($variable)}se;
+    }
+    $body;
+}
+
+sub do_vms {
+    my ($name, $makefile) = @_;
+
+    # Looking for the macro defining the current perldelta:
+    #PERLDELTA_CURRENT = [.pod]perl5139delta.pod
+
+    $makefile =~ s{\nPERLDELTA_CURRENT\s+=\s+\Q[.pod]perl\E\d+delta\.pod\n}
+                  {\0}sx;
+    verify_contiguous($name, $makefile, 'current perldelta macro');
+    $makefile =~ s/\0+/join "\n", '', "PERLDELTA_CURRENT = [.pod]$state->{delta_target}", ''/se;
+
+    $makefile;
+}
+
+sub do_unix {
+    my ($name, $makefile_SH) = @_;
+
+    $makefile_SH =~ s{^(perltoc_pod_prereqs = extra.pods).*}
+                     {join ' ', $1, map "pod/$_",
+                          sort(keys %{$state->{copies}},
+                               grep {!/perltoc/} keys %{$state->{generated}})
+                      }mge;
+
+    # pod/perl511delta.pod: pod/perldelta.pod
+    #         cd pod && $(LNS) perldelta.pod perl511delta.pod
+
+    $makefile_SH =~ s!(
+pod/perl[a-z0-9_]+\.pod: pod/perl[a-z0-9_]+\.pod
+       \$\(LNS\) perl[a-z0-9_]+\.pod pod/perl[a-z0-9_]+\.pod
+)+!\0!gm;
+
+    verify_contiguous($name, $makefile_SH, 'copy rules');
+
+    my @copy_rules = map "
+pod/$_: pod/$state->{copies}{$_}
+       \$(LNS) $state->{copies}{$_} pod/$_
+", keys %{$state->{copies}};
+
+    $makefile_SH =~ s/\0+/join '', @copy_rules/se;
+    $makefile_SH;
+}
+
+# Do stuff
+while (my ($target, $name) = each %Targets) {
+    print "Now processing $name\n" if $Verbose;
+
+    my $fh = open_or_die($name);
+    binmode $fh;
+    local $/;
+    my $orig = <$fh>;
+    my_die "$name contains NUL bytes" if $orig =~ /\0/;
+
+    my $new = do {
+        no strict 'refs';
+        &{"do_$target"}($target, $orig);
+    };
+
+    if ($Test) {
+        printf "%s %d # $name is up to date\n",
+            $new eq $orig ? 'ok' : 'not ok',
+                ++$test;
+        next;
+    } elsif ($new eq $orig) {
+        print "Was not modified\n"
+            if $Verbose;
+        next;
+    }
+
+    my $mode = (stat $name)[2] // my_die "Can't stat $name: $!";
+    rename $name, "$name.old" or my_die "Can't rename $name to $name.old: $!";
+
+    open $fh, '>', $name or my_die "Can't open $name for writing: $!";
+    binmode $fh;
+    print $fh $new or my_die "print to $name failed: $!";
+    close $fh or my_die "close $name failed: $!";
+    chmod $mode & 0777, $name or my_die "can't chmod $mode $name: $!";
+}
+
+# Local variables:
+# cperl-indent-level: 4
+# indent-tabs-mode: nil
+# End:
+#
+# ex: set ts=8 sts=4 sw=4 et:
index d970c86..5cc9b83 100644 (file)
@@ -76,7 +76,7 @@ html: $(POD2HTML) $(HTML)
 tex:   $(POD2LATEX) $(TEX)
 
 toc perltoc.pod:       buildtoc
-       $(PERLILIB) buildtoc --build-toc
+       $(PERLILIB) buildtoc
 
 .SUFFIXES: .pm .pod
 
index c1dc6bf..ef7cbb0 100644 (file)
@@ -1,17 +1,14 @@
 #!/usr/bin/perl -w
 
 use strict;
-use vars qw(%Build %Targets %Pragmata %Modules $Verbose $Quiet $Test);
+use vars qw(%Pragmata %Modules $Quiet);
 use File::Spec;
 use File::Find;
 use FindBin;
-use Text::Tabs;
 use Text::Wrap;
 use Getopt::Long;
-use Carp;
 
 no locale;
-require 5.010;
 
 # Assumption is that we're either already being run from the top level (*nix,
 # VMS), or have absolute paths in @INC (Win32, pod/Makefile)
@@ -21,84 +18,16 @@ BEGIN {
   require 'Porting/pod_lib.pl';
 }
 
-# Generate any/all of these files
-# --verbose gives slightly more output
-# --quiet suppresses routine warnings
-# --build-all tries to build everything
-# --build-foo updates foo as follows
-# --showfiles shows the files to be changed
-# --test exit if perl.pod, pod.lst, MANIFEST are consistent, and regenerated
-#   files are up to date, die otherwise.
-
-%Targets
-  = (
-     toc => 'pod/perltoc.pod',
-     manifest => 'MANIFEST',
-     perlpod => 'pod/perl.pod',
-     vms => 'vms/descrip_mms.template',
-     nmake => 'win32/Makefile',
-     dmake => 'win32/makefile.mk',
-     podmak => 'win32/pod.mak',
-     # plan9 =>  'plan9/mkfile'),
-     unix => 'Makefile.SH',
-     # TODO: add roffitall
-    );
-
-# process command-line switches
-
-{
-  my @files = keys %Targets;
-  my $filesopts = join(" | ", map { "--build-$_" } "all", sort @files);
-  my $showfiles;
-  my %build_these;
-  die <<__USAGE__
-$0: Usage: $0 [--verbose] [--showfiles] $filesopts
-__USAGE__
-  unless @ARGV
-       && GetOptions (verbose => \$Verbose,
-                      quiet => \$Quiet,
-                      showfiles => \$showfiles,
-                      test => \$Test,
-                      map {+"build-$_", \$build_these{$_}} @files, 'all');
-  if ($build_these{all}) {
-    %Build = %Targets;
-  } else {
-    while (my ($file, $want) = each %build_these) {
-      $Build{$file} = $Targets{$file} if $want;
-    }
-  }
-  if ($showfiles) {
-      print join(" ", sort { lc $a cmp lc $b } values %Build), "\n";
-      exit(0);
-  }
-}
-
-if ($Verbose) {
-  print "I will be building $_\n" foreach keys %Build;
-}
+die "$0: Usage: $0 [--quiet]\n"
+    unless GetOptions (quiet => \$Quiet) && !@ARGV;
 
-my $state = get_pod_metadata(values %Build);
-
-if ($Test) {
-    delete $Build{toc};
-    printf "1..%d\n", 1 + scalar keys %Build;
-    if (@{$state->{inconsistent}}) {
-        print "not ok 1\n";
-        die @{$state->{inconsistent}};
-    }
-    print "ok 1\n";
-}
-else {
-    warn @{$state->{inconsistent}} if @{$state->{inconsistent}};
-}
+my $state = get_pod_metadata('pod/perltoc.pod');
 
+warn @{$state->{inconsistent}} if @{$state->{inconsistent}};
 
 # Find all the modules
-if ($Build{toc}) {
-  my @modpods;
-  find \&getpods => 'lib';
-
-  sub getpods {
+my @modpods;
+find(sub {
     if (/\.p(od|m)$/) {
       my $file = $File::Find::name;
       return if $file =~ qr!/lib/Pod/Functions.pm\z!; # Used only by pod itself
@@ -125,12 +54,12 @@ if ($Build{toc}) {
        warn "$0: NOTE: cannot find '=head1 NAME' in:\n  $file\n" unless $Quiet;
       }
     }
-  }
+  }, 'lib');
 
-  my_die "Can't find any pods!\n" unless @modpods;
+my_die "Can't find any pods!\n" unless @modpods;
 
-  my %done;
-  for (@modpods) {
+my %done;
+for (@modpods) {
     my $name = $_;
     $name =~ s/\.p(m|od)$//;
     $name =~ s-.*?/lib/--;
@@ -138,26 +67,25 @@ if ($Build{toc}) {
     next if $done{$name}++;
 
     if ($name =~ /^[a-z]/) {
-      $Pragmata{$name} = $_;
+       $Pragmata{$name} = $_;
     } else {
-      $Modules{$name} = $_;
+       $Modules{$name} = $_;
     }
-  }
 }
 
-# OK. Now a lot of ancillary function definitions follow
-# Main program returns at "Do stuff"
+# 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
+# and this code was in a subroutine do_toc(). In turn, the use of a file scoped
+# lexical instead of a parameter or return value is because the code dates back
+# further still, and used *only* to create pod/perltoc.pod by printing direct
 
 my $OUT;
 
-sub do_toc {
-  my $filename = shift;
-
-  ($_= <<"EOPOD2B") =~ s/^\t//gm and $OUT .= $_;
+($_= <<"EOPOD2B") =~ s/^\t//gm and $OUT .= $_;
 
        # !!!!!!!   DO NOT EDIT THIS FILE   !!!!!!!
        # This file is autogenerated by buildtoc from all the other pods.
-       # Edit those files and run buildtoc --build-toc to effect changes.
+       # Edit those files and run $0 to effect changes.
 
        =head1 NAME
 
@@ -172,15 +100,14 @@ sub do_toc {
        =head1 BASIC DOCUMENTATION
 
 EOPOD2B
-#' make emacs happy
 
-  # All the things in the master list that happen to be pod filenames
-  foreach (grep {defined $_ && @$_ == 3 && !$_->[0]{toc_omit}} @{$state->{master}}) {
+# All the things in the master list that happen to be pod filenames
+foreach (grep {defined $_ && @$_ == 3 && !$_->[0]{toc_omit}} @{$state->{master}}) {
     podset(@$_);
-  }
+}
 
 
-  ($_= <<"EOPOD2B") =~ s/^\t//gm and $OUT .= $_;
+($_= <<"EOPOD2B") =~ s/^\t//gm and $OUT .= $_;
 
 
 
@@ -188,11 +115,11 @@ EOPOD2B
 
 EOPOD2B
 
-  foreach (sort keys %Pragmata) {
+foreach (sort keys %Pragmata) {
     podset($_, $Pragmata{$_});
-  }
+}
 
-  ($_= <<"EOPOD2B") =~ s/^\t//gm and $OUT .= $_;
+($_= <<"EOPOD2B") =~ s/^\t//gm and $OUT .= $_;
 
 
 
@@ -200,11 +127,11 @@ EOPOD2B
 
 EOPOD2B
 
-  foreach (sort keys %Modules) {
+foreach (sort keys %Modules) {
     podset($_, $Modules{$_});
-  }
+}
 
-  $_= <<"EOPOD2B";
+$_= <<"EOPOD2B";
 
 
        =head1 AUXILIARY DOCUMENTATION
@@ -216,8 +143,8 @@ EOPOD2B
 
 EOPOD2B
 
-  $_ .=  join "\n", map {"\t=item $_\n"} sort keys %{$state->{aux}};
-  $_ .= <<"EOPOD2B" ;
+$_ .=  join "\n", map {"\t=item $_\n"} sort keys %{$state->{aux}};
+$_ .= <<"EOPOD2B" ;
 
        =back
 
@@ -229,16 +156,21 @@ EOPOD2B
 
 EOPOD2B
 
-  s/^\t//gm;
-  $OUT .= "$_\n";
+s/^\t//gm;
+$OUT .= "$_\n";
 
-  $OUT =~ s/\n\s+\n/\n\n/gs;
-  $OUT =~ s/\n{3,}/\n\n/g;
+$OUT =~ s/\n\s+\n/\n\n/gs;
+$OUT =~ s/\n{3,}/\n\n/g;
 
-  $OUT =~ s/([^\n]+)/wrap('', '', $1)/ge;
+$OUT =~ s/([^\n]+)/wrap('', '', $1)/ge;
 
-  return $OUT;
-}
+my $filename = 'pod/perltoc.pod';
+open my $fh, '>', $filename
+    or my_die "Can't open $filename for writing: $!";
+print $fh $OUT or my_die "Can't print to $filename: $!";
+close $fh or  my_die "Can't close $filename: $!";
+
+exit(0);
 
 # Below are all the auxiliary routines for generating perltoc.pod
 
@@ -321,59 +253,9 @@ sub unitem {
     $initem = 0;
 }
 
-# End of original buildtoc. From here on are routines to generate new sections
-# for and inplace edit other files
-
-sub generate_perlpod {
-  my @output;
-  my $maxlength = 0;
-  foreach (@{$state->{master}}) {
-    my $flags = $_->[0];
-    next if $flags->{aux};
-    next if $flags->{perlpod_omit};
-
-    if (@$_ == 2) {
-      # Heading
-      push @output, "=head2 $_->[1]\n";
-    } elsif (@$_ == 5) {
-      # Section
-      my $start = " " x (4 + $flags->{indent}) . $_->[4];
-      $maxlength = length $start if length ($start) > $maxlength;
-      push @output, [$start, $_->[3]];
-    } elsif (@$_ == 0) {
-      # blank line
-      push @output, "\n";
-    } else {
-      my_die "Illegal length " . scalar @$_;
-    }
-  }
-  # want at least 2 spaces padding
-  $maxlength += 2;
-  $maxlength = ($maxlength + 3) & ~3;
-  # sprintf gives $1.....$2 where ... are spaces:
-  return unexpand (map {ref $_ ? sprintf "%-${maxlength}s%s\n", @$_ : $_}
-                  @output);
-}
-
-
-sub generate_manifest {
-  # Annoyingly, unexpand doesn't consider it good form to replace a single
-  # space before a tab with a tab
-  # Annoyingly (2) it returns read only values.
-  my @temp = unexpand (map {sprintf "%-32s%s", @$_} @_);
-  map {s/ \t/\t\t/g; $_} @temp;
-}
-sub generate_manifest_pod {
-  generate_manifest map {["pod/$_.pod", $state->{pods}{$_}]}
-    sort grep {
-        !$state->{copies}{"$_.pod"} && !$state->{generated}{"$_.pod"} && !-e "$_.pod"
-    } keys %{$state->{pods}};
-}
-sub generate_manifest_readme {
-  generate_manifest sort {$a->[0] cmp $b->[0]}
-    ["README.vms", "Notes about installing the VMS port"],
-      map {["README.$_", $state->{readmes}{$_}]} keys %{$state->{readmes}};
-}
+# Code added in commit 416302502f485afa, but never used.
+# Probably roffitall should become something that buildtoc generates, instead
+# of something that we ship in the distribution.
 
 sub generate_roffitall {
   (map ({"\t\$maindir/$_.1\t\\"}sort keys %{$state->{pods}}),
@@ -385,186 +267,3 @@ sub generate_roffitall {
    map ({"\t\$libdir/$_.3\t\\"}sort keys %Modules),
   )
 }
-
-sub generate_nmake_1 {
-  # XXX Fix this with File::Spec
-  (map {sprintf "\tcopy ..\\README.%-8s ..\\pod\\perl$_.pod\n", $_}
-    sort keys %{$state->{readmes}}),
-      (map {"\tcopy ..\\pod\\$state->{copies}{$_} ..\\pod\\$_\n"} sort keys %{$state->{copies}});
-}
-
-# This doesn't have a trailing newline
-sub generate_nmake_2 {
-  # Spot the special case
-  local $Text::Wrap::columns = 76;
-  my $line = wrap ("\t    ", "\t    ",
-                   join " ", sort keys %{$state->{copies}}, keys %{$state->{generated}},
-                                  map {"perl$_.pod"} keys %{$state->{readmes}});
-  $line =~ s/$/ \\/mg;
-  $line =~ s/ \\$//;
-  $line;
-}
-
-sub generate_pod_mak {
-  my $variable = shift;
-  my @lines;
-  my $line = "\U$variable = " . join "\t\\\n\t",
-    map {"$_.$variable"} sort grep { $_ !~ m{/} } keys %{$state->{pods}};
-  # Special case
-  $line =~ s/.*perltoc.html.*\n//m;
-  $line;
-}
-
-sub verify_contiguous {
-  my ($name, $content, $what) = @_;
-  my $sections = () = $content =~ m/\0+/g;
-  croak("$0: $name contains no $what") if $sections < 1;
-  croak("$0: $name contains discontiguous $what") if $sections > 1;
-}
-
-sub do_manifest {
-  my ($name, $prev) = @_;
-  my @manifest =
-    grep {! m!^pod/[^.]+\.pod.*!}
-      grep {! m!^README\.(\S+)! || $state->{ignore}{$1}} split "\n", $prev;
-  join "\n", (
-             # Dictionary order - fold and handle non-word chars as nothing
-             map  { $_->[0] }
-             sort { $a->[1] cmp $b->[1] || $a->[0] cmp $b->[0] }
-             map  { my $f = lc $_; $f =~ s/[^a-z0-9\s]//g; [ $_, $f ] }
-             @manifest,
-             &generate_manifest_pod(),
-             &generate_manifest_readme()), '';
-}
-
-sub do_nmake {
-  my ($name, $makefile) = @_;
-  $makefile =~ s/^\tcopy \.\.\\README.*\n/\0/gm;
-  verify_contiguous($name, $makefile, 'README copies');
-  # Now remove the other copies that follow
-  1 while $makefile =~ s/\0\tcopy .*\n/\0/gm;
-  $makefile =~ s/\0+/join ("", &generate_nmake_1)/se;
-
-  $makefile =~ s{(-cd \$\(PODDIR\) && del /f[^\n]+).*?(-cd \.\.\\utils && del /f)}
-    {"$1\n" . &generate_nmake_2."\n\t$2"}se;
-  $makefile;
-}
-
-# shut up used only once warning
-*do_dmake = *do_dmake = \&do_nmake;
-
-sub do_perlpod {
-  my ($name, $pod) = @_;
-
-  unless ($pod =~ s{(For\ ease\ of\ access,\ .*\n)
-                   (?:\s+[a-z]{4,}.*\n #   fooo
-                   |=head.*\n          # =head foo
-                   |\s*\n              # blank line
-                  )+
-                 }
-         {$1 . join "", &generate_perlpod}mxe) {
-    my_die "Failed to insert amendments in do_perlpod";
-  }
-  $pod;
-}
-
-sub do_podmak {
-  my ($name, $body) = @_;
-  foreach my $variable (qw(pod man html tex)) {
-    my_die "could not find $variable in $name"
-      unless $body =~ s{\n\U$variable\E = (?:[^\n]*\\\n)*[^\n]*}
-       {"\n" . generate_pod_mak ($variable)}se;
-  }
-  $body;
-}
-
-sub do_vms {
-  my ($name, $makefile) = @_;
-
-# Looking for the macro defining the current perldelta:
-#PERLDELTA_CURRENT = [.pod]perl5139delta.pod
-
-  $makefile =~ s/\nPERLDELTA_CURRENT\s+=\s+\Q[.pod]perl\E\d+delta\.pod\n
-                   /\0/sx;
-  verify_contiguous($name, $makefile, 'current perldelta macro');
-  $makefile =~ s/\0+/join "\n", '', "PERLDELTA_CURRENT = [.pod]$state->{delta_target}", ''/se;
-
-  $makefile;
-}
-
-sub do_unix {
-  my ($name, $makefile_SH) = @_;
-
-  $makefile_SH =~ s{^(perltoc_pod_prereqs = extra.pods).*}
-                  {join ' ', $1, map "pod/$_",
-                        sort keys %{$state->{copies}}, grep {!/perltoc/} keys %{$state->{generated}}
-                   }mge;
-
-# pod/perl511delta.pod: pod/perldelta.pod
-#      cd pod && $(LNS) perldelta.pod perl511delta.pod
-
-  $makefile_SH =~ s!(
-pod/perl[a-z0-9_]+\.pod: pod/perl[a-z0-9_]+\.pod
-       \$\(LNS\) perl[a-z0-9_]+\.pod pod/perl[a-z0-9_]+\.pod
-)+!\0!gm;
-
-  verify_contiguous($name, $makefile_SH, 'copy rules');
-
-  my @copy_rules = map "
-pod/$_: pod/$state->{copies}{$_}
-       \$(LNS) $state->{copies}{$_} pod/$_
-", keys %{$state->{copies}};
-
-  $makefile_SH =~ s/\0+/join '', @copy_rules/se;
-  $makefile_SH;
-
-}
-
-# Do stuff
-
-my $built;
-while (my ($target, $name) = each %Targets) {
-  print "Working on target $target\n" if $Verbose;
-  next unless $Build{$target};
-  $built++;
-  my ($orig, $mode);
-  print "Now processing $name\n" if $Verbose;
-  if ($target ne "toc") {
-    local $/;
-    my $thing = open_or_die($name);
-    binmode $thing;
-    $orig = <$thing>;
-    my_die "$name contains NUL bytes" if $orig =~ /\0/;
-  }
-
-  my $new = do {
-    no strict 'refs';
-    &{"do_$target"}($target, $orig);
-  };
-
-  if (defined $orig) {
-    if ($new eq $orig) {
-      if ($Test) {
-       printf "ok %d # $name is up to date\n", $built + 1;
-      } elsif ($Verbose) {
-       print "Was not modified\n";
-      }
-      next;
-    } elsif ($Test) {
-      printf "not ok %d # $name is up to date\n", $built + 1;
-      next;
-    }
-    $mode = (stat $name)[2] // my_die "Can't stat $name: $!";
-    rename $name, "$name.old" or my_die "Can't rename $name to $name.old: $!";
-  }
-
-  open my $thing, '>', $name or my_die "Can't open $name for writing: $!";
-  binmode $thing;
-  print $thing $new or my_die "print to $name failed: $!";
-  close $thing or my_die "close $name failed: $!";
-  if (defined $mode) {
-    chmod $mode & 0777, $name or my_die "can't chmod $mode $name: $!";
-  }
-}
-
-warn "$0: was not instructed to build anything\n" unless $built || $Test;
index 4fbcac9..ee53667 100644 (file)
@@ -9,7 +9,7 @@ use strict;
 require 't/test.pl';
 
 my $result = runperl(switches => ['-f', '-Ilib'], 
-                     progfile => 'pod/buildtoc', 
-                     args     => ['--build-toc', '-q', '--test', '--build-all']);
+                     progfile => 'Porting/pod_rules.pl',
+                     args     => ['--tap']);
 
 print $result;
index 6247e92..3ce1244 100644 (file)
@@ -361,7 +361,7 @@ $(PERLDELTA_CURRENT) : [.pod]perldelta.pod
 
 [.pod]perltoc.pod : $(PERLDELTA_CURRENT) [.pod]perlapi.pod [.pod]perlintern.pod  [.pod]perlmodlib.pod extra.pods $(PERL_EXE)
        @ define/user_mode $(DBG)PERLSHR SYS$DISK:[]$(DBG)perlshr$(E)
-       $(PERL) "-f" [.pod]buildtoc "-q" "--build-toc"
+       $(PERL) "-f" [.pod]buildtoc "-q"
 
 archcorefiles : $(ac) $(ARCHAUTO)time.stamp
        @ $(NOOP)
index c49bfb2..6b6d460 100644 (file)
@@ -1081,7 +1081,7 @@ utils: $(PERLEXE) $(X2P)
        $(PERLEXE) $(ICWD) ..\pod\perlmodlib.pl -q
 
 ..\pod\perltoc.pod: $(PERLEXE) Extensions Extensions_nonxs
-       $(PERLEXE) -f ..\pod\buildtoc --build-toc -q
+       $(PERLEXE) -f ..\pod\buildtoc -q
 
 # Note that the pod cleanup in this next section is parsed (and regenerated
 # by pod/buildtoc so please check that script before making changes here
index a83b3b3..bcead25 100644 (file)
@@ -1266,7 +1266,7 @@ utils: $(PERLEXE) $(X2P)
        $(PERLEXE) $(ICWD) ..\pod\perlmodlib.pl -q
 
 ..\pod\perltoc.pod: $(PERLEXE) Extensions Extensions_nonxs
-       $(PERLEXE) -f ..\pod\buildtoc --build-toc -q
+       $(PERLEXE) -f ..\pod\buildtoc -q
 
 # Note that the pod cleanup in this next section is parsed (and regenerated
 # by pod/buildtoc so please check that script before making changes here