From 6655716badf61d81cb5103402ab6e0f0bc919f63 Mon Sep 17 00:00:00 2001 From: Abhinav Gupta Date: Mon, 3 Oct 2011 19:09:39 +0000 Subject: [PATCH] ICU-8863 fix cpyscan.pl X-SVN-Rev: 30780 --- tools/scripts/cpysearch/cpyscan.pl | 35 ++++++++++++++++++------------ 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/tools/scripts/cpysearch/cpyscan.pl b/tools/scripts/cpysearch/cpyscan.pl index b386bfde974..deb7506ef78 100755 --- a/tools/scripts/cpysearch/cpyscan.pl +++ b/tools/scripts/cpysearch/cpyscan.pl @@ -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 } ; + close F; + + print "$_\n" unless $result; + }, + no_chdir => 1, + }, $icu_src); -- 2.40.0