package AutoSplit;
-use 5.005_64;
+use 5.006_001;
use Exporter ();
use Config qw(%Config);
use Carp qw(carp);
use File::Basename ();
use File::Path qw(mkpath);
-use File::Spec::Functions qw(curdir catfile);
+use File::Spec::Functions qw(curdir catfile catdir);
use strict;
our($VERSION, @ISA, @EXPORT, @EXPORT_OK, $Verbose, $Keep, $Maxlen,
$CheckForAutoloader, $CheckModTime);
-$VERSION = "1.0305";
+$VERSION = "1.0307";
@ISA = qw(Exporter);
@EXPORT = qw(&autosplit &autosplit_lib_modules);
@EXPORT_OK = qw($Verbose $Keep $Maxlen $CheckForAutoloader $CheckModTime);
The
fourth argument, I<$check>, instructs C<autosplit> to check the module
-currently being split to ensure that it does include a C<use>
+currently being split to ensure that it includes a C<use>
specification for the AutoLoader module, and skips the module if
AutoLoader is not detected.
$check defaults to 1.
$_ = catfile($1, $2);
}
s|\\|/|g; # bug in ksh OS/2
+ s#^lib/##s; # incase specified as lib/*.pm
my($lib) = catfile(curdir(), "lib");
- s#^$lib\W+##s; # incase specified as lib/*.pm
+ if ($Is_VMS) { # may need to convert VMS-style filespecs
+ $lib =~ s#^\[\]#.\/#;
+ }
+ s#^$lib\W+##s; # incase specified as ./lib/*.pm
if ($Is_VMS && /[:>\]]/) { # may need to convert VMS-style filespecs
my ($dir,$name) = (/(.*])(.*)/s);
$dir =~ s/.*lib[\.\]]//s;
# private functions
+my $self_mod_time = (stat __FILE__)[9];
+
sub autosplit_file {
my($filename, $autodir, $keep, $check_for_autoloader, $check_mod_time)
= @_;
$in_pod = 1 if /^=\w/;
$in_pod = 0 if /^=cut/;
next if ($in_pod || /^=cut/);
+ next if /^\s*#/;
# record last package name seen
$def_package = $1 if (m/^\s*package\s+([\w:]+)\s*;/);
die "Package $def_package ($modpname.pm) does not ".
"match filename $filename"
unless ($filename =~ m/\Q$modpname.pm\E$/ or
- ($^O eq 'dos') or ($^O eq 'MSWin32') or
+ ($^O eq 'dos') or ($^O eq 'MSWin32') or ($^O eq 'NetWare') or
$Is_VMS && $filename =~ m/$modpname.pm/i);
- my($al_idx_file) = "$autodir/$modpname/$IndexFile";
+ my($al_idx_file) = catfile($autodir, $modpname, $IndexFile);
if ($check_mod_time){
my($al_ts_time) = (stat("$al_idx_file"))[9] || 1;
- if ($al_ts_time >= $pm_mod_time){
+ if ($al_ts_time >= $pm_mod_time and
+ $al_ts_time >= $self_mod_time){
print "AutoSplit skipped ($al_idx_file newer than $filename)\n"
if ($Verbose >= 2);
return undef; # one undef, not a list
}
}
- my($modnamedir) = catfile($autodir, $modpname);
+ my($modnamedir) = catdir($autodir, $modpname);
print "AutoSplitting $filename ($modnamedir)\n"
if $Verbose;
- unless (-d "$modnamedir"){
- mkpath("$modnamedir",0,0777);
+ unless (-d $modnamedir){
+ mkpath($modnamedir,0,0777);
}
# We must try to deal with some SVR3 systems with a limit of 14
push(@subnames, $fq_subname);
my($lname, $sname) = ($subname, substr($subname,0,$maxflen-3));
$modpname = _modpname($this_package);
- my($modnamedir) = catfile($autodir, $modpname);
- mkpath("$modnamedir",0,0777);
+ my($modnamedir) = catdir($autodir, $modpname);
+ mkpath($modnamedir,0,0777);
my($lpath) = catfile($modnamedir, "$lname.al");
my($spath) = catfile($modnamedir, "$sname.al");
my $path;
if ($Verbose>=1);
}
push(@outfiles, $path);
+ my $lineno = $fnr - @cache;
print OUT <<EOT;
# NOTE: Derived from $filename.
-# Changes made here will be lost when autosplit again.
+# Changes made here will be lost when autosplit is run again.
# See AutoSplit.pm.
package $this_package;
-#line $fnr "$filename (autosplit into $path)"
+#line $lineno "$filename (autosplit into $path)"
EOT
print OUT @cache;
@cache = ();
if ($^O eq 'MSWin32') {
$modpname =~ s#::#\\#g;
} else {
- while ($modpname =~ m#(.*?[^:])::([^:].*)#) {
- $modpname = catfile($1, $2);
- }
+ my @modpnames = ();
+ while ($modpname =~ m#(.*?[^:])::([^:].*)#) {
+ push @modpnames, $1;
+ $modpname = $2;
+ }
+ $modpname = catfile(@modpnames, $modpname);
+ }
+ if ($Is_VMS) {
+ $modpname = VMS::Filespec::unixify($modpname); # may have dirs
}
$modpname;
}