summaryrefslogtreecommitdiffstats
path: root/third_party/devscripts/licensecheck.pl.vanilla
diff options
context:
space:
mode:
authorphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-23 19:02:00 +0000
committerphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-23 19:02:00 +0000
commit959708c6f41ec074586e01e7435273f62cf6da95 (patch)
tree0032ec6bf17884faad9d67d33ebda718ad850ae4 /third_party/devscripts/licensecheck.pl.vanilla
parentaaaee3541ebdbdb25a36f83a9acb2ec996ea4285 (diff)
downloadchromium_src-959708c6f41ec074586e01e7435273f62cf6da95.zip
chromium_src-959708c6f41ec074586e01e7435273f62cf6da95.tar.gz
chromium_src-959708c6f41ec074586e01e7435273f62cf6da95.tar.bz2
Update licensecheck to version 2.12.4.
BUG=none TEST=none Review URL: https://codereview.chromium.org/11029052 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@163628 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'third_party/devscripts/licensecheck.pl.vanilla')
-rw-r--r--third_party/devscripts/licensecheck.pl.vanilla62
1 files changed, 44 insertions, 18 deletions
diff --git a/third_party/devscripts/licensecheck.pl.vanilla b/third_party/devscripts/licensecheck.pl.vanilla
index 9f5de0c..d98b974 100644
--- a/third_party/devscripts/licensecheck.pl.vanilla
+++ b/third_party/devscripts/licensecheck.pl.vanilla
@@ -4,6 +4,7 @@
#
# This version is
# Copyright (C) 2007, 2008 Adam D. Barratt
+# Copyright (C) 2012 Francesco Poli
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -28,7 +29,8 @@ B<licensecheck> B<--help>|B<--version>
B<licensecheck> [B<--no-conf>] [B<--verbose>] [B<--copyright>]
[B<-l>|B<--lines=>I<N>] [B<-i>|B<--ignore=>I<regex>] [B<-c>|B<--check=>I<regex>]
-[B<-r>|B<--recursive>] I<list of files and directories to check>
+[B<-m>|B<--machine>] [B<-r>|B<--recursive>]
+I<list of files and directories to check>
=head1 DESCRIPTION
@@ -77,6 +79,13 @@ The default includes common source files.
Also display copyright text found within the file
+=item B<-m>, B<--machine>
+
+Display the information in a machine readable way, i.e. in the form
+<file><tab><license>[<tab><copyright>] so that it can be easily sorted
+and/or filtered, e.g. with the B<awk> and B<sort> commands.
+Note that using the B<--verbose> option will kill the readability.
+
=item B<--no-conf>, B<--noconf>
Do not read any configuration files. This can only be used as the first
@@ -155,7 +164,7 @@ my $default_ignore_regex = '
$default_ignore_regex =~ s/^#.*$//mg;
$default_ignore_regex =~ s/\n//sg;
-my $default_check_regex = '\.(c(c|pp|xx)?|h(h|pp|xx)?|f(77|90)?|p(l|m)|xs|sh|php|py|rb|java|vala|el|sc(i|e)|cs|pas|inc|dtd|xsl|mod)$';
+my $default_check_regex = '\.(c(c|pp|xx)?|h(h|pp|xx)?|f(77|90)?|p(l|m)|xs|sh|php|py(|x)|rb|java|vala|el|sc(i|e)|cs|pas|inc|dtd|xsl|mod|m|tex|mli?)$';
my $modified_conf_msg;
@@ -163,6 +172,7 @@ my ($opt_verbose, $opt_lines, $opt_noconf, $opt_ignore_regex, $opt_check_regex)
= ('', '', '', '', '');
my $opt_recursive = 0;
my $opt_copyright = 0;
+my $opt_machine = 0;
my ($opt_help, $opt_version);
my $def_lines = 60;
@@ -218,6 +228,7 @@ GetOptions("help|h" => \$opt_help,
"recursive|r" => \$opt_recursive,
"check|c=s" => \$opt_check_regex,
"copyright" => \$opt_copyright,
+ "machine|m" => \$opt_machine,
"noconf" => \$opt_noconf,
"no-conf" => \$opt_noconf,
)
@@ -289,20 +300,27 @@ while (@files) {
print qq(----- $file header -----\n$content----- end header -----\n\n)
if $opt_verbose;
+ # Remove Fortran comments
+ $content =~ s/^[cC] //gm;
$content =~ tr/\t\r\n/ /;
# Remove C / C++ comments
$content =~ s#(\*/|/[/*])##g;
$content =~ tr% A-Za-z.,@;0-9\(\)/-%%cd;
- $content =~ s/ c //g; # Remove fortran comments
$content =~ tr/ //s;
$license = parselicense($content);
- print "$file: ";
- print "*No copyright* " unless $copyright;
- print $license . "\n";
- print " [Copyright: " . $copyright . "]\n"
- if $copyright and $opt_copyright;
- print "\n" if $opt_copyright;
+ if ($opt_machine) {
+ print "$file\t$license";
+ print "\t" . ($copyright or "*No copyright*") if $opt_copyright;
+ print "\n";
+ } else {
+ print "$file: ";
+ print "*No copyright* " unless $copyright;
+ print $license . "\n";
+ print " [Copyright: " . $copyright . "]\n"
+ if $copyright and $opt_copyright;
+ print "\n" if $opt_copyright;
+ }
}
sub parse_copyright($) {
@@ -356,9 +374,10 @@ Valid options are:
--check, -c Specify a pattern indicating which files should
be checked
(Default: '$default_check_regex')
+ --machine, -m Display in a machine readable way (good for awk)
--recursive, -r Add the contents of directories recursively
--copyright Also display the file's copyright
- --ignore, -i Specify that files / directories matching the
+ --ignore, -i Specify that files / directories matching the
regular expression should be ignored when
checking files
(Default: '$default_ignore_regex')
@@ -388,11 +407,11 @@ sub parselicense($) {
my $extrainfo = "";
my $license = "";
- if ($licensetext =~ /version ([^ ]+) (?:\(?only\)?.? )?(?:of the GNU (Affero )?General Public License )?as published by the Free Software Foundation/i or
- $licensetext =~ /GNU (?:Affero )?General Public License as published by the Free Software Foundation; version ([^ ]+) /i) {
+ if ($licensetext =~ /version ([^, ]+?)[.,]? (?:\(?only\)?.? )?(?:of the GNU (Affero )?(Lesser |Library )?General Public License )?(as )?published by the Free Software Foundation/i or
+ $licensetext =~ /GNU (?:Affero )?(?:Lesser |Library )?General Public License (?:as )?published by the Free Software Foundation; version ([^, ]+?)[.,]? /i) {
$gplver = " (v$1)";
- } elsif ($licensetext =~ /GNU (?:Affero ?)General Public License, version ([^ ]+?)[ .]/) {
+ } elsif ($licensetext =~ /GNU (?:Affero )?(?:Lesser |Library )?General Public License, version (\d+(?:\.\d+)?)[ \.]/) {
$gplver = " (v$1)";
} elsif ($licensetext =~ /either version ([^ ]+)(?: of the License)?, or \(at your option\) any later version/) {
$gplver = " (v$1 or later)";
@@ -410,7 +429,7 @@ sub parselicense($) {
$license = "GENERATED FILE";
}
- if ($licensetext =~ /is free software.? you can redistribute it and\/or modify it under the terms of the (GNU (Library|Lesser) General Public License|LGPL)/i) {
+ if ($licensetext =~ /is (free software.? you can redistribute it and\/or modify it|licensed) under the terms of (version [^ ]+ of )?the (GNU (Library |Lesser )General Public License|LGPL)/i) {
$license = "LGPL$gplver$extrainfo $license";
}
@@ -481,6 +500,10 @@ sub parselicense($) {
$license = "Apache (v$1) $license";
}
+ if ($licensetext =~ /(THE BEER-WARE LICENSE)/i) {
+ $license = "Beerware $license";
+ }
+
if ($licensetext =~ /This source file is subject to version ([^ ]+) of the PHP license/) {
$license = "PHP (v$1) $license";
}
@@ -498,7 +521,7 @@ sub parselicense($) {
}
if ($licensetext =~ /is in the public domain/i) {
- $license = "Public domain";
+ $license = "Public domain $license";
}
if ($licensetext =~ /terms of the Common Development and Distribution License(, Version ([^(]+))? \(the License\)/) {
@@ -526,19 +549,22 @@ sub parselicense($) {
}
if ($licensetext =~ /Do What The Fuck You Want To Public License, Version ([^, ]+)/i) {
- $license = "WTFPL (v$1)";
+ $license = "WTFPL (v$1) $license";
}
if ($licensetext =~ /Do what The Fuck You Want To Public License/i) {
- $license = "WTFPL";
+ $license = "WTFPL $license";
}
if ($licensetext =~ /(License WTFPL|Under (the|a) WTFPL)/i) {
- $license = "WTFPL";
+ $license = "WTFPL $license";
}
$license = "UNKNOWN" if (!length($license));
+ # Remove trailing spaces.
+ $license =~ s/\s+$//;
+
return $license;
}