This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Add directory depth check for older VMS systems to check83.pl
[perl5.git] / Porting / check83.pl
CommitLineData
81d555a2
RGS
1#!/usr/bin/perl -w
2
3use strict;
8c284f99 4
4d8cc5f8
JH
5# Check whether there are naming conflicts when names are truncated to
6# the DOSish case-ignoring 8.3 format, plus other portability no-nos.
8c284f99 7
9c406a46
PN
8# The "8.3 rule" is loose: "if reducing the directory entry names
9# within one directory to lowercase and 8.3-truncated causes
10# conflicts, that's a bad thing". So the rule is NOT the strict
11# "no filename shall be longer than eight and a suffix if present
12# not longer than three".
9a715e86 13
4a6f7383
CB
14# The 8-level depth rule is for older VMS systems that likely won't
15# even be able to unpack the tarball if more than eight levels
16# (including the top of the source tree) are present.
17
a9b610e9 18my %seen;
81d555a2 19my $maxl = 30; # make up a limit for a maximum filename length
9a715e86 20
9e371ce5 21sub eight_dot_three {
81d555a2
RGS
22 return () if $seen{$_[0]}++;
23 my ($dir, $base, $ext) = ($_[0] =~ m{^(?:(.+)/)?([^/.]+)(?:\.([^/.]+))?$});
a9b610e9 24 my $file = $base . ( defined $ext ? ".$ext" : "" );
9e371ce5
JH
25 $base = substr($base, 0, 8);
26 $ext = substr($ext, 0, 3) if defined $ext;
81d555a2 27 if (defined $dir && $dir =~ /\./) {
a9b610e9 28 print "directory name contains '.': $dir\n";
4d8cc5f8
JH
29 }
30 if ($file =~ /[^A-Za-z0-9\._-]/) {
a9b610e9 31 print "filename contains non-portable characters: $_[0]\n";
4d8cc5f8 32 }
81d555a2
RGS
33 if (length $file > $maxl) {
34 print "filename longer than $maxl characters: $file\n";
4d8cc5f8 35 }
9e371ce5
JH
36 if (defined $dir) {
37 return ($dir, defined $ext ? "$dir/$base.$ext" : "$dir/$base");
38 } else {
39 return ('.', defined $ext ? "$base.$ext" : $base);
40 }
41}
42
43my %dir;
44
45if (open(MANIFEST, "MANIFEST")) {
46 while (<MANIFEST>) {
47 chomp;
48 s/\s.+//;
49 unless (-f) {
a9b610e9 50 print "missing: $_\n";
9e371ce5
JH
51 next;
52 }
53 if (tr/././ > 1) {
a9b610e9 54 print "more than one dot: $_\n";
9e371ce5
JH
55 next;
56 }
4a6f7383
CB
57 if ((my $slashes = $_ =~ tr|\/|\/|) > 7) {
58 print "more than eight levels deep: $_\n";
59 next;
60 }
a9b610e9
YST
61 while (m!/|\z!g) {
62 my ($dir, $edt) = eight_dot_three($`);
81d555a2 63 next unless defined $dir;
a9b610e9
YST
64 ($dir, $edt) = map { lc } ($dir, $edt);
65 push @{$dir{$dir}->{$edt}}, $_;
66 }
9e371ce5
JH
67 }
68} else {
69 die "$0: MANIFEST: $!\n";
70}
71
72for my $dir (sort keys %dir) {
73 for my $edt (keys %{$dir{$dir}}) {
479ac4eb 74 my @files = @{$dir{$dir}{$edt}};
9e371ce5 75 if (@files > 1) {
479ac4eb 76 print "conflict on filename $edt:\n", map " $_\n", @files;
9e371ce5
JH
77 }
78 }
79}