root/trunk/bin/copyrightCheck.pl @ 3887

Revision 3887, 2.9 KB (checked in by sukyoungryu, 5 months ago)

[static checker] Fixed a bug handling symmetric exclusion relationship.
Implemented checking that if trait T excludes trait U, no third trait may extend both T and U, nor may either T or U extend the other.
Added tests and eliminated unnecessary excludes clauses in the CompilerBuiltin? library.
Refactored static checker code.

  • Property svn:executable set to *
Line 
1#!/usr/bin/perl
2# ################################################################################
3#    Copyright 2009 Sun Microsystems, Inc.,
4#    4150 Network Circle, Santa Clara, California 95054, U.S.A.
5#    All rights reserved.
6#
7#    U.S. Government Rights - Commercial software.
8#    Government users are subject to the Sun Microsystems, Inc. standard
9#    license agreement and applicable provisions of the FAR and its supplements.
10#
11#    Use is subject to license terms.
12#
13#    This distribution may include materials developed by third parties.
14#
15#    Sun, Sun Microsystems, the Sun logo and Java are trademarks or registered
16#    trademarks of Sun Microsystems, Inc. in the U.S. and other countries.
17################################################################################
18
19use XML::Simple;
20use IO::File;
21use strict;
22
23# Some special stuff happens if $debug > 1
24my $debug=0;
25
26my $path = $ENV{'FORTRESS_HOME'};
27if (!$path) {
28   print "FORTRESS_HOME must be set";
29   exit;
30 }
31
32#print "$path\n";
33
34chdir $path;
35
36my $checkRev=3300;       # Only examine files from versions greater than this.
37my $checkDate = 2009;    # Only examine files in this year.
38my $rootDir = $path;
39my $copyright = "Copyright $checkDate "; # The message to look for.
40my $maxlines = 10;       # The message must appear within this many lines of the top of the file.
41my $ignoreThese = 'ant|fortress-keywords|UserDictionary|README.txt|README$|\.fsg$|\.NW$|fortress.vim|\.ods|\.jar$|\.timing$|\.war$|\.zip$|\.tgz$|\/\.|^\.|^Sandbox';
42my $tempFile = '/tmp/svnInfo.xml';
43
44#
45my $xmlfh;               # a filehandle for the XML output of the svn command.
46
47if ($debug>1) {
48   $xmlfh = new IO::File $tempFile;   # just read a local file on debug.
49} else {
50   $xmlfh = new IO::File 'svn info -R --xml $path |'; # Ask svn for info
51   die("Can't get svn info") if (!$xmlfh);
52}
53
54
55my $xs1 = XML::Simple->new();
56my $doc = $xs1->XMLin($xmlfh);   #  Read the XML filehandle
57
58$xmlfh->close();                 # Done, close it.
59
60foreach my $entry ((@{$doc->{entry}})){
61     # Skip over...
62     next if ( $entry->{kind} ne 'file' );      # ...non-files
63     next if ( $entry->{revision} < $checkRev );# ...old revisions
64     next if ( $entry->{commit}->{date} !~ m/$checkDate/); # ...things before this year.
65     next if ( $entry->{path} =~ m/$ignoreThese/ );    # ... file names to ignore
66
67     # Scan the beginging of the file for the copyright message.
68     my ($line,$cnt,$missingCopyRight);
69     $missingCopyRight=1;
70     $cnt=0;
71     print "opening-> $rootDir/$entry->{path}\n" if ($debug);
72     my $fh = new IO::File "$entry->{path}";
73     warn ("Can't open $entry->{path}") if (!$fh);
74     while (($line = <$fh> )|| ($cnt++<$maxlines)) {
75       print $line if ($debug);
76       if ($line =~ m/$copyright/) {
77          $missingCopyRight=0;
78          last;
79        }
80     }
81     $fh->close();
82     # If the copyRight wasn't found, print out the file name.
83     if ($missingCopyRight) {
84       print "$entry->{path}\n";
85     }
86  }
Note: See TracBrowser for help on using the browser.