• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/perl -w
2#
3# Copyright (C) 2017 and later: Unicode, Inc. and others.
4# License & terms of use: http://www.unicode.org/copyright.html
5#
6#  ***********************************************************************
7#  * Copyright (C) 2016 and later: Unicode, Inc. and others.
8#  * License & terms of use: http://www.unicode.org/copyright.html
9#  ***********************************************************************
10#  ***********************************************************************
11#  * COPYRIGHT:
12#  * Copyright (c) 2002-2011, International Business Machines Corporation
13#  * and others. All Rights Reserved.
14#  ***********************************************************************
15#
16#  Search for and list files which don't have a copyright notice, and should.
17#
18use strict;
19use warnings;
20use File::Find;
21
22use FindBin qw($Bin);
23use lib $Bin;
24
25use Cpy;
26my $icu_src = $ARGV[0] || ".";
27my $exitStatus = 0;
28my $icu_src_len = length($icu_src);
29die "Can't open ICU directory: $icu_src" unless -d $icu_src;
30find({
31        wanted => sub {
32            # save a little bit of time.
33            if ($_ eq './.git') {
34                $File::Find::prune = 1;
35                return;
36            }
37            return unless -f;
38            my $relpath = substr($_, $icu_src_len + 1);
39            return if should_ignore($relpath);
40
41            open F, "<$_" or die "Error opening '$_'.";
42            my $result = any { $_ =~ /(Copyright|©).*Unicode/i } <F>;
43
44            close F;
45            if (not $result) {
46                print "$relpath\n";
47                $exitStatus = 1;
48            }
49        },
50        no_chdir => 1,
51    }, $icu_src);
52
53if ($exitStatus) {
54    die "Above files did not contain the correct copyright notice.";
55}
56exit $exitStatus;
57