|
Revision 1, 1.1 KB
(checked in by root, 6 years ago)
|
|
First post
|
| Line | |
|---|
| 1 | #!/usr/bin/perl |
|---|
| 2 | # |
|---|
| 3 | # $Id: capsfix_dir.pl,v 1.1.1.1 2004/08/31 13:33:28 thomasez Exp $ |
|---|
| 4 | |
|---|
| 5 | # This piece moves all CAPSed modules to it's own directory in case there are |
|---|
| 6 | # modules with the same name with and without CAPS. |
|---|
| 7 | # |
|---|
| 8 | # It will not handle module paths wit CAPS right now. |
|---|
| 9 | # (I'm too lazy) |
|---|
| 10 | # |
|---|
| 11 | # Thomas Lundquist 2003-09-20 |
|---|
| 12 | |
|---|
| 13 | use strict; |
|---|
| 14 | |
|---|
| 15 | my $dir = "2.4-std"; |
|---|
| 16 | # my $dir = "test"; |
|---|
| 17 | |
|---|
| 18 | my %files; |
|---|
| 19 | my %paths; |
|---|
| 20 | |
|---|
| 21 | while (<>) { |
|---|
| 22 | if (/[A-Z]/ && !m/\/caps\//) { |
|---|
| 23 | my (@mods) = split(/\t/); |
|---|
| 24 | foreach my $mod (@mods) { |
|---|
| 25 | my ($path, $module); |
|---|
| 26 | ($path, $module) = ($1, $2) |
|---|
| 27 | if ( $mod =~ /(.*)\/([A-Z|a-z|0-9|_|-]+\.o)/ ); |
|---|
| 28 | if ($module =~ /[A-Z]/) { |
|---|
| 29 | if (/:/) { |
|---|
| 30 | $files{$module} = $path; |
|---|
| 31 | $paths{$path} = 1; |
|---|
| 32 | } |
|---|
| 33 | |
|---|
| 34 | $mod =~ s/(.*)\/([A-Z|a-z|0-9|_|-]+\.o)/$1\/caps\/$2/g; |
|---|
| 35 | |
|---|
| 36 | } |
|---|
| 37 | $mod = "\t$mod" unless ($mod =~ /:/); |
|---|
| 38 | print $mod; |
|---|
| 39 | } |
|---|
| 40 | } else { |
|---|
| 41 | print; |
|---|
| 42 | } |
|---|
| 43 | } |
|---|
| 44 | |
|---|
| 45 | # |
|---|
| 46 | # Only need to make the new path once. |
|---|
| 47 | # |
|---|
| 48 | foreach my $p (keys (%paths)) { |
|---|
| 49 | my ($newpath) = $p . "/caps"; |
|---|
| 50 | mkdir("$dir/$newpath",0755); |
|---|
| 51 | } |
|---|
| 52 | |
|---|
| 53 | # |
|---|
| 54 | # Copy files |
|---|
| 55 | # |
|---|
| 56 | foreach my $f (keys (%files)) { |
|---|
| 57 | my ($newpath) = $files{$f} . "/caps"; |
|---|
| 58 | rename("$dir/$files{$f}/$f", "$dir/$newpath/$f"); |
|---|
| 59 | } |
|---|