]> granicus.if.org Git - icu/commitdiff
ICU-8863 fix cpyscan.pl
authorAbhinav Gupta <mail@abhinavg.net>
Mon, 3 Oct 2011 19:09:39 +0000 (19:09 +0000)
committerAbhinav Gupta <mail@abhinavg.net>
Mon, 3 Oct 2011 19:09:39 +0000 (19:09 +0000)
X-SVN-Rev: 30780

tools/scripts/cpysearch/cpyscan.pl

index b386bfde97424c056d24ac62259ed9fc9d307f2b..deb7506ef78820399b3ea2971ee5eb73c743abe6 100755 (executable)
@@ -1,25 +1,32 @@
 #!/usr/bin/perl -w
 #  ***********************************************************************
 #  * COPYRIGHT:
-#  * Copyright (c) 2002-2007, International Business Machines Corporation
+#  * Copyright (c) 2002-2011, International Business Machines Corporation
 #  * and others. All Rights Reserved.
 #  ***********************************************************************
 # 
 #  Search for and list files which don't have a copyright notice, and should.
 #
 use strict;
+use warnings;
+use File::Find;
 
-my $icuSource = $ARGV[0];
-my $ignore = "data/out/build|CVS|\\.svn|\\~|\\#|Debug|Release|\\.dll|\\.ilk|\\.idb|\\.pdb|\\.dsp|\\.dsw|\\.opt|\\.ncb|\\.vcproj|\\.sln|\\.suo|\\.cvsignore|\\.cnv|\\.res|\\.icu|\\.exe|\\.obj|\\.bin|\\.exp|\\.lib|\\.out|\\.plg|positions|unidata|\\.jar|\\.spp|\\.stub|\\.policy|\\.otf|\\.ttf|\\.TTF";
+use FindBin qw($Bin);
+use lib $Bin;
 
-my $command = "find $icuSource -type f | fgrep -v -f cpyskip.txt";
-my @files = `$command`;
-@files = grep(!/$ignore/, @files);
-my $file;
-foreach $file (@files) {
-  chomp $file;
-  my @lines = `head -n 20 "$file"`;
-  if (grep(/copyright.*(international|ibm)/i, @lines) == 0) {
-    print "$file\n";
-  }
-}
+use Cpy;
+my $icu_src = $ARGV[0] || ".";
+die "Can't open ICU directory: $icu_src" unless -d $icu_src;
+find({
+        wanted => sub {
+            return unless -f;
+            return if should_ignore($_);
+
+            open F, "<$_" or die "Error opening '$_'.";
+            my $result = any { $_ =~ /copyright.*(international|ibm)/i } <F>;
+            close F;
+
+            print "$_\n" unless $result;
+        },
+        no_chdir => 1,
+    }, $icu_src);