Regex Utility Functions and Substituion Fix (XML::Twig core dump)
[p5sagit/p5-mst-13.2.git] / lib / ExtUtils / Manifest.pm
index b016131..70c1ef8 100644 (file)
@@ -2,8 +2,9 @@ package ExtUtils::Manifest;
 
 require Exporter;
 use Config;
-use File::Find;
+use File::Basename;
 use File::Copy 'copy';
+use File::Find;
 use File::Spec;
 use Carp;
 use strict;
@@ -12,7 +13,7 @@ use vars qw($VERSION @ISA @EXPORT_OK
           $Is_MacOS $Is_VMS 
           $Debug $Verbose $Quiet $MANIFEST $DEFAULT_MSKIP);
 
-$VERSION = 1.43;
+$VERSION = '1.49';
 @ISA=('Exporter');
 @EXPORT_OK = qw(mkmanifest
                 manicheck  filecheck  fullcheck  skipcheck
@@ -29,9 +30,7 @@ $Verbose = defined $ENV{PERL_MM_MANIFEST_VERBOSE} ?
 $Quiet = 0;
 $MANIFEST = 'MANIFEST';
 
-my $Filename = __FILE__;
-$DEFAULT_MSKIP = (File::Spec->splitpath($Filename))[1].
-                 "$MANIFEST.SKIP";
+$DEFAULT_MSKIP = File::Spec->catfile( dirname(__FILE__), "$MANIFEST.SKIP" );
 
 
 =head1 NAME
@@ -351,11 +350,14 @@ sub _maniskip {
     open M, $mfile or open M, $DEFAULT_MSKIP or return sub {0};
     while (<M>){
        chomp;
+       s/\r//;
        next if /^#/;
        next if /^\s*$/;
        push @skip, _macify($_);
     }
     close M;
+    return sub {0} unless (scalar @skip > 0);
+
     my $opts = $Is_VMS ? '(?i)' : '';
 
     # Make sure each entry is isolated in its own parentheses, in case
@@ -433,7 +435,7 @@ sub cp_if_diff {
        if (-e $to) {
            unlink($to) or confess "unlink $to: $!";
        }
-      STRICT_SWITCH: {
+        STRICT_SWITCH: {
            best($from,$to), last STRICT_SWITCH if $how eq 'best';
            cp($from,$to), last STRICT_SWITCH if $how eq 'cp';
            ln($from,$to), last STRICT_SWITCH if $how eq 'ln';
@@ -476,9 +478,13 @@ sub _manicopy_chmod {
     chmod( $perm | ( $perm & 0100 ? 0111 : 0 ), $file );
 }
 
+# Files that are often modified in the distdir.  Don't hard link them.
+my @Exceptions = qw(MANIFEST META.yml SIGNATURE);
 sub best {
     my ($srcFile, $dstFile) = @_;
-    if (!$Config{d_link} or -l $srcFile) {
+
+    my $is_exception = grep $srcFile =~ /$_/, @Exceptions;
+    if ($is_exception or !$Config{d_link} or -l $srcFile) {
        cp($srcFile, $dstFile);
     } else {
        ln($srcFile, $dstFile) or cp($srcFile, $dstFile);
@@ -513,11 +519,11 @@ sub _unmacify {
     my($file) = @_;
 
     return $file unless $Is_MacOS;
-    
+
     $file =~ s|^:||;
     $file =~ s|([/ \n])|sprintf("\\%03o", unpack("c", $1))|ge;
     $file =~ y|:|/|;
-    
+
     $file;
 }
 
@@ -572,7 +578,7 @@ sub _fix_manifest {
         close MANIFEST;
     }
 }
-        
+
 
 # UNIMPLEMENTED
 sub _normalize {
@@ -584,9 +590,17 @@ sub _normalize {
 
 =head2 MANIFEST
 
+A list of files in the distribution, one file per line.  The MANIFEST
+always uses Unix filepath conventions even if you're not on Unix.  This
+means F<foo/bar> style not F<foo\bar>.
+
 Anything between white space and an end of line within a C<MANIFEST>
-file is considered to be a comment.  Filenames and comments are
-separated by one or more TAB characters in the output. 
+file is considered to be a comment.  Any line beginning with # is also
+a comment.
+
+    # this a comment
+    some/file
+    some/other/file            comment about some/file
 
 
 =head2 MANIFEST.SKIP
@@ -595,7 +609,9 @@ The file MANIFEST.SKIP may contain regular expressions of files that
 should be ignored by mkmanifest() and filecheck(). The regular
 expressions should appear one on each line. Blank lines and lines
 which start with C<#> are skipped.  Use C<\#> if you need a regular
-expression to start with a sharp character. A typical example:
+expression to start with a C<#>.
+
+For example:
 
     # Version control files and dirs.
     \bRCS\b
@@ -688,7 +704,9 @@ L<ExtUtils::MakeMaker> which has handy targets for most of the functionality.
 
 Andreas Koenig C<andreas.koenig@anima.de>
 
-Currently maintained by Michael G Schwern C<schwern@pobox.com>
+Maintained by Michael G Schwern C<schwern@pobox.com> within the
+ExtUtils-MakeMaker package and, as a separate CPAN package, by
+Randy Kobes C<r.kobes@uwinnipeg.ca>.
 
 =cut