Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Store paths to *.pm files not absolute but relative to pdldoc.db
This makes the pdldoc.db format relocatable.
  • Loading branch information
kmx authored and devel-chm committed Dec 29, 2014
1 parent 9abb318 commit 974f21f
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion Doc/Doc.pm
Expand Up @@ -4,6 +4,8 @@
package PDL::PodParser;
use PDL::Core '';
use Pod::Select;
use File::Spec;
use File::Basename;

@ISA = qw(Pod::Select);

Expand Down Expand Up @@ -470,6 +472,7 @@ sub ensuredb {
my ($len) = unpack "S", $plen;
read IN, $txt, $len;
my ($sym, %hash) = split chr(0), $txt;
$hash{Dbfile} = $fi; # keep the origin pdldoc.db path
$this->{SYMS}->{$sym} = {%hash};
}
close IN;
Expand All @@ -492,6 +495,12 @@ sub savedb {
binmode OUT;
while (my ($key,$val) = each %$hash) {
next if 0 == scalar(%$val);
my $fi = $val->{File};
if (File::Spec->file_name_is_absolute($fi) && -f $fi) {
#store paths to *.pm files relative to pdldoc.db
$val->{File} = File::Spec->abs2rel($fi, dirname($this->{Outfile})) ;
}
delete $val->{Dbfile}; # no need to store Dbfile
my $txt = "$key".chr(0).join(chr(0),%$val);
print OUT pack("S",length($txt)).$txt;
}
Expand Down Expand Up @@ -747,7 +756,12 @@ sub funcdocs {
my ($this,$func,$fout) = @_;
my $hash = $this->ensuredb;
barf "unknown function '$func'" unless defined($hash->{$func});
funcdocs_fromfile($func,$hash->{$func}->{File},$fout);
my $file = $hash->{$func}->{File};
my $dbf = $hash->{$func}->{Dbfile};
if (!File::Spec->file_name_is_absolute($file) && $dbf) {
$file = File::Spec->rel2abs($file, dirname($dbf));
}
funcdocs_fromfile($func,$file,$fout);
}
=head1 FUNCTIONS
Expand Down

0 comments on commit 974f21f

Please sign in to comment.