summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorMarc Green <marcgreen@cpan.org>2011-06-30 10:36:18 -0400
committerMarc Green <marcgreen@cpan.org>2011-10-31 13:26:42 -0400
commit042c2bc8aafe40de8820e3d79b96a237b9989292 (patch)
tree30d481039a3769b4a3cead2f1728e8ba38e5c58b /ext
parented36117c53cad58d523d403adfd3fa303361697c (diff)
downloadperl-042c2bc8aafe40de8820e3d79b96a237b9989292.tar.gz
Fix crossref bug
Take into account Windows paths in Podroot and Podpath
Diffstat (limited to 'ext')
-rw-r--r--ext/Pod-Html/lib/Pod/Html.pm31
-rw-r--r--ext/Pod-Html/t/htmldir.t11
2 files changed, 20 insertions, 22 deletions
diff --git a/ext/Pod-Html/lib/Pod/Html.pm b/ext/Pod-Html/lib/Pod/Html.pm
index 02968b9b4e..f85310db93 100644
--- a/ext/Pod-Html/lib/Pod/Html.pm
+++ b/ext/Pod-Html/lib/Pod/Html.pm
@@ -134,8 +134,7 @@ HTML converted forms can be linked to in cross references.
--podroot=name
-Specify the base directory for finding library pods. This is prepended
-to each directory in podpath before searching for PODs. Default is the
+Specify the base directory for finding library pods. Default is the
current working directory.
=item quiet
@@ -272,14 +271,16 @@ sub pod2html {
$Htmlfileurl = "$Htmldir/" . substr( $Htmlfile, length( $Htmldir ) + 1);
}
- # get the full path
- @Podpath = map { File::Spec->catdir($Podroot, $_) } @Podpath;
+ my $pwd = getcwd();
+ chdir($Podroot) || die "$0: error changing to directory $Podroot: $!\n";
# find all pod modules/pages in podpath, store in %Pages
- # - callback used to remove $Podroot from each file
+ # - callback used to remove Podroot and extension from each file
# - laborious to allow '.' in dirnames (e.g., /usr/share/perl/5.14.1)
Pod::Simple::Search->new->inc(0)->verbose($Verbose)->laborious(1)
- ->callback(\&_save_page)->recurse($Recurse)->survey(@Podpath);
+ ->callback(\&_save_page)->recurse($Recurse)->survey(@Podpath);
+
+ chdir($pwd) || die "$0: error changing to directory $pwd: $!\n";
# set options for the parser
my $parser = Pod::Simple::XHTML::LocalPodLinks->new();
@@ -509,12 +510,18 @@ sub anchorify {
sub _save_page {
my ($modspec, $modname) = @_;
- # Remove $Podroot from path for cross referencing
- my $slash = $Podroot =~ m|/\z| ? 0 : 1; # Account for trailing slash
- my $rel_path = substr($modspec, length($Podroot) + $slash);
-
- my ($file, $dir) = fileparse($rel_path, qr/\.[^.]*/); # strip .ext
- $Pages{$modname} = $dir . $file;
+ # Remove Podroot from path
+ foreach my $p (@Podpath) {
+ my $beg_path = File::Spec->catdir($Podroot, $p);
+ # Replace $Podroot/$p with $p
+ if ($beg_path eq substr($modspec, 0, length($beg_path), $p)) {
+ last; # Keep replacement
+ }
+ }
+
+ my ($file, $dir) = fileparse($modspec, qr/\.[^.]*/); # strip .ext
+ $Pages{$modname} = File::Spec::Unix->catdir( # convert '\'s to '/'s and such
+ File::Spec->splitdir($dir . $file));
}
1;
diff --git a/ext/Pod-Html/t/htmldir.t b/ext/Pod-Html/t/htmldir.t
index 3d3a28d11a..e11f31817c 100644
--- a/ext/Pod-Html/t/htmldir.t
+++ b/ext/Pod-Html/t/htmldir.t
@@ -5,7 +5,7 @@ BEGIN {
}
use strict;
-use Test::More tests => 3;
+use Test::More tests => 2;
use File::Spec;
use Cwd;
@@ -34,15 +34,6 @@ convert_n_test("htmldir", "test --htmldir and --htmlroot 1b",
"--htmlroot=/",
);
-seek DATA, $data_pos, 0; # to read <DATA> thrice (expected output is the same)
-
-convert_n_test("htmldir", "test --htmldir and --htmlroot 1c",
- "--podpath=t:test.lib",
- "--podroot=$relcwd",
- "--htmldir=$relcwd",
- "--htmlroot=/",
-);
-
__DATA__
<?xml version="1.0" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">