This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Embed.t fails on Win32
[perl5.git] / Porting / check83.pl
CommitLineData
8c284f99
JH
1#!/usr/local/bin/perl
2
4d8cc5f8
JH
3# Check whether there are naming conflicts when names are truncated to
4# the DOSish case-ignoring 8.3 format, plus other portability no-nos.
8c284f99 5
9c406a46
PN
6# The "8.3 rule" is loose: "if reducing the directory entry names
7# within one directory to lowercase and 8.3-truncated causes
8# conflicts, that's a bad thing". So the rule is NOT the strict
9# "no filename shall be longer than eight and a suffix if present
10# not longer than three".
9a715e86 11
9c406a46
PN
12# TODO: this doesn't actually check for *directory entries*, what this
13# does is to check for *MANIFEST entries*, which are only files, not
14# directories. In other words, a 8.3 conflict between a directory
15# "abcdefghx" and a file "abcdefghy" wouldn't be noticed-- or even for
16# a directory "abcdefgh" and a file "abcdefghy".
9a715e86 17
9e371ce5
JH
18sub eight_dot_three {
19 my ($dir, $base, $ext) = ($_[0] =~ m!^(?:(.+)/)?([^/.]+)(?:\.([^/.]+))?$!);
4d8cc5f8 20 my $file = $base . defined $ext ? ".$ext" : "";
9e371ce5
JH
21 $base = substr($base, 0, 8);
22 $ext = substr($ext, 0, 3) if defined $ext;
4d8cc5f8
JH
23 if ($dir =~ /\./) {
24 warn "$dir: directory name contains '.'\n";
25 }
26 if ($file =~ /[^A-Za-z0-9\._-]/) {
27 warn "$file: filename contains non-portable characters\n";
28 }
29 if (length $file > 30) {
9c406a46 30 warn "$file: filename longer than 30 characters\n"; # make up a limit
4d8cc5f8 31 }
9e371ce5
JH
32 if (defined $dir) {
33 return ($dir, defined $ext ? "$dir/$base.$ext" : "$dir/$base");
34 } else {
35 return ('.', defined $ext ? "$base.$ext" : $base);
36 }
37}
38
39my %dir;
40
41if (open(MANIFEST, "MANIFEST")) {
42 while (<MANIFEST>) {
43 chomp;
44 s/\s.+//;
45 unless (-f) {
46 warn "$_: missing\n";
47 next;
48 }
49 if (tr/././ > 1) {
8c284f99 50 print "$_: more than one dot\n";
9e371ce5
JH
51 next;
52 }
53 my ($dir, $edt) = eight_dot_three($_);
8c284f99 54 ($dir, $edt) = map { lc } ($dir, $edt);
9e371ce5
JH
55 push @{$dir{$dir}->{$edt}}, $_;
56 }
57} else {
58 die "$0: MANIFEST: $!\n";
59}
60
61for my $dir (sort keys %dir) {
62 for my $edt (keys %{$dir{$dir}}) {
63 my @files = @{$dir{$dir}->{$edt}};
64 if (@files > 1) {
8c284f99 65 print "@files: directory $dir conflict $edt\n";
9e371ce5
JH
66 }
67 }
68}