Commit | Line | Data |
23b3bd7f |
1 | #!/usr/bin/perl |
8c284f99 |
2 | |
4d8cc5f8 |
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 |
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 |
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 |
18 | sub eight_dot_three { |
19 | my ($dir, $base, $ext) = ($_[0] =~ m!^(?:(.+)/)?([^/.]+)(?:\.([^/.]+))?$!); |
4d8cc5f8 |
20 | my $file = $base . defined $ext ? ".$ext" : ""; |
9e371ce5 |
21 | $base = substr($base, 0, 8); |
22 | $ext = substr($ext, 0, 3) if defined $ext; |
4d8cc5f8 |
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 |
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 | |
39 | my %dir; |
40 | |
41 | if (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 |
51 | next; |
52 | } |
53 | my ($dir, $edt) = eight_dot_three($_); |
8c284f99 |
54 | ($dir, $edt) = map { lc } ($dir, $edt); |
9e371ce5 |
55 | push @{$dir{$dir}->{$edt}}, $_; |
56 | } |
57 | } else { |
58 | die "$0: MANIFEST: $!\n"; |
59 | } |
60 | |
61 | for 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 |
66 | } |
67 | } |
68 | } |