Originally buildtoc called chdir to ensure it ran from the pod/ directory.
However, this caused problems when the environment is set to honour UTF-8
locales, and the regex engine (attempts to) demand-load UTF-8 swashes,
because on *nix and VMS buildtoc is invoked with a relative path in @INC.
d5e2eea989a69524 fixed this by avoiding the chdir.
However, an equally valid solution is to run from the top level of the source
tree, because the actual use cases only have relative paths in @INC when
invoked from the top level, with absolute paths in @INC for the use cases
that invoke perltoc from other directories. Hence, it's always safe to change
to the top level of the source tree. This permits future simplification and
refactoring.
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)
{
my $Top = File::Spec->catdir($FindBin::Bin, File::Spec->updir);
+ chdir $Top or die "Can't chdir to $Top: $!";
sub abs_from_top {
my $path = shift;