summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2011-12-18 10:35:09 +0100
committerNicholas Clark <nick@ccl4.org>2011-12-19 13:55:19 +0100
commitd4c6b7ae2c2b00211f9528f146804b76b755480d (patch)
treed6a7c84d267626c3e4db22af778c3b0fc708507e
parent449e2f794bd454dce291b0a7192232fe882f1318 (diff)
downloadperl-d4c6b7ae2c2b00211f9528f146804b76b755480d.tar.gz
Change get_pod_metadata() to take a callback to report consistency errors.
Using the callback to report errors instead of passing the 'inconsistent' arrayref back in the state means that get_pod_metadata() doesn't even need to calculate this information if it's not going to be used.
-rw-r--r--Porting/pod_lib.pl6
-rw-r--r--Porting/pod_rules.pl25
-rw-r--r--pod/buildtoc4
3 files changed, 17 insertions, 18 deletions
diff --git a/Porting/pod_lib.pl b/Porting/pod_lib.pl
index 3676953db6..b9a9ef7795 100644
--- a/Porting/pod_lib.pl
+++ b/Porting/pod_lib.pl
@@ -50,6 +50,8 @@ sub is_duplicate_pod {
sub get_pod_metadata {
# Do we expect to find generated pods on disk?
my $permit_missing_generated = shift;
+ # Do they want a consistency report?
+ my $callback = shift;
my %BuildFiles;
foreach my $path (@_) {
@@ -146,6 +148,8 @@ sub get_pod_metadata {
}
close $master or my_die "close pod.lst: $!";
+ return \%state unless $callback;
+
# Sanity cross check
my (%disk_pods, %manipods, %manireadmes, %perlpods);
@@ -245,7 +249,7 @@ sub get_pod_metadata {
or $not_yet_there{$i};
}
}
- $state{inconsistent} = \@inconsistent;
+ &$callback(@inconsistent);
return \%state;
}
diff --git a/Porting/pod_rules.pl b/Porting/pod_rules.pl
index acea2d22f5..d23f86f935 100644
--- a/Porting/pod_rules.pl
+++ b/Porting/pod_rules.pl
@@ -62,23 +62,20 @@ if ($Verbose) {
print "I will be building $_\n" foreach keys %Build;
}
+my $test = 1;
# For testing, generated files must be present and we're rebuilding nothing.
# For normal rebuilding, generated files may not be present, and we mute
# warnings about inconsistencies in any file we're about to rebuild.
-my $state = get_pod_metadata($Test ? () : (1, values %Build));
-
-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}};
-}
+my $state = $Test
+ ? get_pod_metadata(0, sub {
+ printf "1..%d\n", 1 + scalar keys %Build;
+ if (@_) {
+ print "not ok $test\n";
+ die @_;
+ }
+ print "ok $test\n";
+ })
+ : get_pod_metadata(1, sub { warn @_ if @_ }, values %Build);
sub generate_perlpod {
my @output;
diff --git a/pod/buildtoc b/pod/buildtoc
index edf77ed1fd..839fbb16a4 100644
--- a/pod/buildtoc
+++ b/pod/buildtoc
@@ -21,9 +21,7 @@ BEGIN {
die "$0: Usage: $0 [--quiet]\n"
unless GetOptions (quiet => \$Quiet) && !@ARGV;
-my $state = get_pod_metadata(0, 'pod/perltoc.pod');
-
-warn @{$state->{inconsistent}} if @{$state->{inconsistent}};
+my $state = get_pod_metadata(0, sub { warn @_ if @_ }, 'pod/perltoc.pod');
# Find all the modules
my @modpods;