[licensecheck] 39/112: Add trait pattern license_version.

Jonas Smedegaard dr at jones.dk
Fri Nov 25 22:01:47 UTC 2016


This is an automated email from the git hooks/post-receive script.

js pushed a commit to branch master
in repository licensecheck.

commit 3f48b06b13dd619c9b8654aa0330afc2ae5b8536
Author: Jonas Smedegaard <dr at jones.dk>
Date:   Mon Nov 21 17:23:12 2016 +0100

    Add trait pattern license_version.
---
 lib/App/Licensecheck.pm             | 53 ++++++++++++++++++-------------------
 lib/Regexp/Pattern/License.pm       |  8 ++++++
 lib/Regexp/Pattern/License/Parts.pm |  7 +++++
 3 files changed, 41 insertions(+), 27 deletions(-)

diff --git a/lib/App/Licensecheck.pm b/lib/App/Licensecheck.pm
index 7d88ba5..1ce8b36 100755
--- a/lib/App/Licensecheck.pm
+++ b/lib/App/Licensecheck.pm
@@ -76,7 +76,6 @@ my %SPDX = (
 );
 
 my $ver_prefix_re = qr/(?:version |v\.? ?)?/i;
-my $ver_re        = qr/\d(?:\.\d+)*/;
 
 my $default_check_regex = q!
 	/[\w-]+$ # executable scripts or README like file
@@ -463,27 +462,27 @@ sub parse_license
 
 	# version of AGPL/GPL/LGPL
 	given ($licensetext) {
-		when ( /version ($ver_re)(?: of the License)?,? or(?: \(at your option\))? version ($ver_re)/ ) {
+		when ( /version ($L{re}{version_number})(?: of the License)?,? or(?: \(at your option\))? version ($L{re}{version_number})/ ) {
 			$gplver = " (v$1 or v$2)";
 			@spdx_gplver = ( $1, $2 );
 		}
-		when ( /version ($ver_re)[.,]? (?:\(?only\)?.? )?(?:of the GNU (Affero |Lesser |Library )?General Public License )?(as )?published by the Free Software Foundation/i ) {
+		when ( /version ($L{re}{version_number})[.,]? (?:\(?only\)?.? )?(?:of the GNU (Affero |Lesser |Library )?General Public License )?(as )?published by the Free Software Foundation/i ) {
 			$gplver      = " (v$1)";
 			@spdx_gplver = ($1)
 		}
-		when ( /GNU (?:Affero |Lesser |Library )?General Public License (?:as )?published by the Free Software Foundation[;,] $ver_prefix_re($ver_re)[.,]? /i ) {
+		when ( /GNU (?:Affero |Lesser |Library )?General Public License (?:as )?published by the Free Software Foundation[;,] $ver_prefix_re($L{re}{version_number})[.,]? /i ) {
 			$gplver      = " (v$1)";
 			@spdx_gplver = ($1);
 		}
-		when ( /GNU (?:Affero |Lesser |Library )?General Public License ?(?:[(),AGPL]+) ?$ver_prefix_re($ver_re)[ \.]/i ) {
+		when ( /GNU (?:Affero |Lesser |Library )?General Public License ?(?:[(),AGPL]+) ?$ver_prefix_re($L{re}{version_number})[ \.]/i ) {
 			$gplver      = " (v$1)";
 			@spdx_gplver = ($1);
 		}
-		when ( /either $ver_prefix_re($ver_re)(?: of the License)?, or (?:\(at your option\) )?any later version/ ) {
+		when ( /either $ver_prefix_re($L{re}{version_number})(?: of the License)?, or (?:\(at your option\) )?any later version/ ) {
 			$gplver      = " (v$1 or later)";
 			@spdx_gplver = ( $1 . '+' );
 		}
-		when ( /GPL as published by the Free Software Foundation, version ($ver_re)/i ) {
+		when ( /GPL as published by the Free Software Foundation, version ($L{re}{version_number})/i ) {
 			$gplver      = " (v$1)";
 			@spdx_gplver = ($1)
 		}
@@ -522,7 +521,7 @@ sub parse_license
 			push @spdx_license, $gen_spdx->('LGPL');
 		}
 		# For Perl modules handled by Dist::Zilla
-		when ( /this is free software,? licensed under:? (?:the )?(?:GNU (?:Library |Lesser )General Public License|LGPL),? $ver_prefix_re($ver_re)/i ) {
+		when ( /this is free software,? licensed under:? (?:the )?(?:GNU (?:Library |Lesser )General Public License|LGPL),? $ver_prefix_re($L{re}{version_number})/i ) {
 			$gen_license->( 'LGPL', $1 );
 		}
 	}
@@ -541,7 +540,7 @@ sub parse_license
 		when ( /means either [^.]+, the GNU Affero General Public License/i ) {
 			break;
 		}
-		when ( /AFFERO GENERAL PUBLIC LICENSE(?:,? $ver_prefix_re($ver_re)(,? or(?: any)? (?:later|newer))?)?/i ) {
+		when ( /AFFERO GENERAL PUBLIC LICENSE(?:,? $ver_prefix_re($L{re}{version_number})(,? or(?: any)? (?:later|newer))?)?/i ) {
 			$gen_license->( 'AGPL', $1, $2 );
 		}
 	}
@@ -570,11 +569,11 @@ sub parse_license
 	# CC
 	given ($licensetext) {
 		foreach my $id (qw<cc_by cc_by_nc cc_by_nc_nd cc_by_nc_sa cc_by_nd cc_by_sa cc_cc0>) {
-			when ( /$L{re}{$id}(?i: version)? ($ver_re) or ($ver_re)/i ) {
+			when ( /$L{re}{$id}(?i: version)? ($L{re}{version_number}) or ($L{re}{version_number})/i ) {
 				$license = "$L{caption}{$id} (v$1 or v$2) $license";
 				push @spdx_license, "$L{name}{$id}-$1 or $L{name}{$id}-$1";
 			}
-			when ( /$L{re}{$id}(?: $ver_prefix_re($ver_re)?)(?: License)?( (?:and|or)(?: \(at your option\))? any later(?: version)|[,.] Later versions are permitted)?(?:,? (?:and|or)(?: the)?(?:GNU)? (AGPL|GPL|LGPL)(?:-?($ver_re)( or later)?)?)?/i ) {
+			when ( /$L{re}{$id}(?: $ver_prefix_re($L{re}{version_number})?)(?: License)?( (?:and|or)(?: \(at your option\))? any later(?: version)|[,.] Later versions are permitted)?(?:,? (?:and|or)(?: the)?(?:GNU)? (AGPL|GPL|LGPL)(?:-?($L{re}{version_number})( or later)?)?)?/i ) {
 				$gen_license->( $id, $1, $2, $3, $4 );
 			}
 		}
@@ -668,10 +667,10 @@ sub parse_license
 
 	# MPL
 	given ($licensetext) {
-		when ( /Mozilla Public License,? $ver_prefix_re($ver_re)/ ) {
+		when ( /Mozilla Public License,? $ver_prefix_re($L{re}{version_number})/ ) {
 			$gen_license->( 'MPL', $1 );
 		}
-		when ( /Mozilla Public License,? \($ver_prefix_re($ver_re)\)/ ) {
+		when ( /Mozilla Public License,? \($ver_prefix_re($L{re}{version_number})\)/ ) {
 			$gen_license->( 'MPL', $1 );
 		}
 	}
@@ -718,7 +717,7 @@ sub parse_license
 	given ($licensetext) {
 		# either *begins* with "The Artistic license v2.0" (hopefully the actual license)
 		# or some license grant,
-		when ( /(?:^ ?|(?:This is free software, licensed|Released|be used|use and modify this (?:module|software)) under (?:the terms of )?)[Tt]he Artistic License v?($ver_re)/ ) {
+		when ( /(?:^ ?|(?:This is free software, licensed|Released|be used|use and modify this (?:module|software)) under (?:the terms of )?)[Tt]he Artistic License v?($L{re}{version_number})/ ) {
 			$gen_license->( 'Artistic', $1 );
 		}
 	}
@@ -737,22 +736,22 @@ sub parse_license
 
 	# Apache
 	given ($licensetext) {
-		when ( /Apache(?: Software)? License(?:,? $ver_prefix_re($ver_re)( or(?: any)? (?:later|newer))?)?(?:(?: or)? [^ ,]*?apache[^ ,]*| \([^(),]+\))*,? or(?: the)?(?:(?: GNU)? General Public License(?: \(GPL\))?|GPL)(?: $ver_prefix_re($ver_re)( or(?: any)? (?:later|newer))?)?/i ) {
+		when ( /Apache(?: Software)? License(?:,? $ver_prefix_re($L{re}{version_number})( or(?: any)? (?:later|newer))?)?(?:(?: or)? [^ ,]*?apache[^ ,]*| \([^(),]+\))*,? or(?: the)?(?:(?: GNU)? General Public License(?: \(GPL\))?|GPL)(?: $ver_prefix_re($L{re}{version_number})( or(?: any)? (?:later|newer))?)?/i ) {
 			$gen_license->( 'Apache', $1, $2, 'GPL', $3, $4 );
 		}
-		when ( /Apache(?: Software)? License(?:,? $ver_prefix_re($ver_re)( or(?: any)? (?:later|newer))?)?(?:(?: or)? [^ ,]*?apache[^ ,]*| \([^(),]\))*,? or(?: the)? bsd(?:[ -](\d)-clause)?\b/i ) {
+		when ( /Apache(?: Software)? License(?:,? $ver_prefix_re($L{re}{version_number})( or(?: any)? (?:later|newer))?)?(?:(?: or)? [^ ,]*?apache[^ ,]*| \([^(),]\))*,? or(?: the)? bsd(?:[ -](\d)-clause)?\b/i ) {
 			$gen_license->( 'Apache', $1, $2, "bsd_${3}_clause" );
 		}
-		when ( /Apache(?: Software)? License(?:,? $ver_prefix_re($ver_re)( or(?: any)? (?:later|newer))?)?(?:(?: or)? [^ ,]*?apache[^ ,]*| \([^(),]\))*,? or $L{re}{mit_new}\b/i ) {
+		when ( /Apache(?: Software)? License(?:,? $ver_prefix_re($L{re}{version_number})( or(?: any)? (?:later|newer))?)?(?:(?: or)? [^ ,]*?apache[^ ,]*| \([^(),]\))*,? or $L{re}{mit_new}\b/i ) {
 			$gen_license->( 'Apache', $1, $2, 'mit_new', $3, $4 );
 		}
-		when ( /Apache(?: Software)? License(?:,? $ver_prefix_re($ver_re)( or(?: any)? (?:later|newer))?)?(?:(?: or)? [^ ,]*?apache[^ ,]*| \([^(),]\))*,? or $L{re}{mit}\b/i ) {
+		when ( /Apache(?: Software)? License(?:,? $ver_prefix_re($L{re}{version_number})( or(?: any)? (?:later|newer))?)?(?:(?: or)? [^ ,]*?apache[^ ,]*| \([^(),]\))*,? or $L{re}{mit}\b/i ) {
 			$gen_license->( 'Apache', $1, $2, 'mit', $3, $4 );
 		}
-		when ( /Apache(?: Software)? License(?:,? $ver_prefix_re($ver_re)(,? or(?: any)? (?:later|newer))?)?/i ) {
+		when ( /Apache(?: Software)? License(?:,? $ver_prefix_re($L{re}{version_number})(,? or(?: any)? (?:later|newer))?)?/i ) {
 			$gen_license->( 'Apache', $1, $2 );
 		}
-		when ( m<https?www.apache.org/licenses(?:/LICENSE-($ver_re))?>i ) {
+		when ( m<https?www.apache.org/licenses(?:/LICENSE-($L{re}{version_number}))?>i ) {
 			$gen_license->( 'Apache', $1 );
 		}
 	}
@@ -809,7 +808,7 @@ sub parse_license
 
 	# PHP
 	given ($licensetext) {
-		when ( /This source file is subject to version ($ver_re) of the PHP license/ ) {
+		when ( /This source file is subject to version ($L{re}{version_number}) of the PHP license/ ) {
 			$gen_license->( 'PHP', $1 );
 		}
 	}
@@ -840,7 +839,7 @@ sub parse_license
 
 	# CDDL
 	given ($licensetext) {
-		when ( /terms of the Common Development and Distribution License(?:,? $ver_prefix_re($ver_re))?/ ) {
+		when ( /terms of the Common Development and Distribution License(?:,? $ver_prefix_re($L{re}{version_number}))?/ ) {
 			$gen_license->( 'CDDL', $1 );
 		}
 	}
@@ -854,14 +853,14 @@ sub parse_license
 
 	# AFL
 	given ($licensetext) {
-		when ( /Licensed under the Academic Free License(?: $ver_prefix_re($ver_re))?/ ) {
+		when ( /Licensed under the Academic Free License(?: $ver_prefix_re($L{re}{version_number}))?/ ) {
 			$gen_license->( 'AFL', $1 );
 		}
 	}
 
 	# EPL
 	given ($licensetext) {
-		when ( /This program and the accompanying materials are made available under the terms of the Eclipse Public License(?:[ ,-]+$ver_prefix_re($ver_re))?/ ) {
+		when ( /This program and the accompanying materials are made available under the terms of the Eclipse Public License(?:[ ,-]+$ver_prefix_re($L{re}{version_number}))?/ ) {
 			$gen_license->( 'EPL', $1 );
 		}
 	}
@@ -871,7 +870,7 @@ sub parse_license
 		when ( /Permission is hereby granted, free of charge, to any person or organization obtaining a copy of the software and accompanying documentation covered by this license \(the Software\)/ ) {
 			$gen_license->('BSL');
 		}
-		when ( /Boost Software License(?:[ ,-]+ $ver_prefix_re($ver_re))?/i ) {
+		when ( /Boost Software License(?:[ ,-]+ $ver_prefix_re($L{re}{version_number}))?/i ) {
 			$gen_license->( 'BSL', $1, $2 );
 		}
 	}
@@ -885,7 +884,7 @@ sub parse_license
 
 	# Python
 	given ($licensetext) {
-		when ( /PYTHON SOFTWARE FOUNDATION LICENSE(?:,? $ver_prefix_re($ver_re))?/i ) {
+		when ( /PYTHON SOFTWARE FOUNDATION LICENSE(?:,? $ver_prefix_re($L{re}{version_number}))?/i ) {
 			$gen_license->( 'Python', $1, $2 );
 		}
 	}
@@ -932,7 +931,7 @@ sub parse_license
 
 	# WTFPL
 	given ($licensetext) {
-		when ( /Do What The Fuck You Want To Public License,? $ver_prefix_re($ver_re)/i ) {
+		when ( /Do What The Fuck You Want To Public License,? $ver_prefix_re($L{re}{version_number})/i ) {
 			$gen_license->( 'WTFPL', $1 );
 		}
 	}
diff --git a/lib/Regexp/Pattern/License.pm b/lib/Regexp/Pattern/License.pm
index 89313ad..95f9515 100644
--- a/lib/Regexp/Pattern/License.pm
+++ b/lib/Regexp/Pattern/License.pm
@@ -266,6 +266,8 @@ Patterns each covering a single trait occuring in licenses.
 
 =item * disclaimer
 
+=item * version_number
+
 =back
 
 =cut
@@ -305,6 +307,12 @@ $RE{'disclaimer'} = {
 	pat  => qr/$P{discl}/,
 };
 
+$RE{'version_number'} = {
+	caption => 'version number',
+	tags    => ['trait'],
+	pat     => qr/$P{version_number}/,
+};
+
 =head2 Multiple licenses
 
 Patterns each covering multiple licenses.
diff --git a/lib/Regexp/Pattern/License/Parts.pm b/lib/Regexp/Pattern/License/Parts.pm
index 6c7e732..4247045 100644
--- a/lib/Regexp/Pattern/License/Parts.pm
+++ b/lib/Regexp/Pattern/License/Parts.pm
@@ -63,6 +63,8 @@ Patterns each covering a single part, e.g. a clause or a disclaimer phrase.
 
 =item * use_sw_doc_any
 
+=item * version_number
+
 =back
 
 =cut
@@ -246,6 +248,11 @@ our %RE = (
 		tags    => ['clause'],
 		pat     => qr/$to_use $sw_doc $any_purpose/,
 	},
+	version_number => {
+		caption => 'version number',
+		tags    => ['component'],
+		pat     => qr/\d(?:\.\d+)*/,
+	},
 );
 
 =encoding UTF-8

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/licensecheck.git



More information about the Pkg-perl-cvs-commits mailing list