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

js pushed a commit to branch master
in repository licensecheck.

commit c3df8afed8a6559a0aee61d343af7c6a6b530b18
Author: Jonas Smedegaard <d...@jones.dk>
Date:   Mon Sep 19 23:16:19 2016 +0200

    Tighten regexes: Generalize and improve version matching.
---
 lib/App/Licensecheck.pm | 39 +++++++++++++++++++++------------------
 1 file changed, 21 insertions(+), 18 deletions(-)

diff --git a/lib/App/Licensecheck.pm b/lib/App/Licensecheck.pm
index 6f589a8..966ad86 100755
--- a/lib/App/Licensecheck.pm
+++ b/lib/App/Licensecheck.pm
@@ -53,6 +53,9 @@ See the script for casual usage.
 
 =cut
 
+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
        |\.( # search for file suffix
@@ -379,27 +382,27 @@ sub parse_license
 
        # version of AGPL/GPL/LGPL
        given ($licensetext) {
-               when ( /version (\d(?:\.\d+)*)(?: of the License)?,? or(?: \(at 
your option\))? version (\d+(?:\.\d+)*)/ ) {
+               when ( /version ($ver_re)(?: of the License)?,? or(?: \(at your 
option\))? version ($ver_re)/ ) {
                        $gplver = " (v$1 or v$2)";
                        @spdx_gplver = ( $1, $2 );
                }
-               when ( /version (\d+(?:\.\d+)*)[.,]? (?:\(?only\)?.? )?(?:of 
the GNU (Affero |Lesser |Library )?General Public License )?(as )?published by 
the Free Software Foundation/i ) {
+               when ( /version ($ver_re)[.,]? (?:\(?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[;,] version 
(\d+(?:\.\d+)*)[.,]? /i ) {
+               when ( /GNU (?:Affero |Lesser |Library )?General Public License 
(?:as )?published by the Free Software Foundation[;,] 
$ver_prefix_re($ver_re)[.,]? /i ) {
                        $gplver      = " (v$1)";
                        @spdx_gplver = ($1);
                }
-               when ( /GNU (?:Affero |Lesser |Library )?General Public License 
?(?:[(),GPL]+) ?version (\d+(?:\.\d+)*)[ \.]/i ) {
+               when ( /GNU (?:Affero |Lesser |Library )?General Public License 
?(?:[(),GPL]+) ?$ver_prefix_re($ver_re)[ \.]/i ) {
                        $gplver      = " (v$1)";
                        @spdx_gplver = ($1);
                }
-               when ( /either version (\d+(?:\.\d+)*)(?: of the License)?, or 
(?:\(at your option\) )?any later version/ ) {
+               when ( /either $ver_prefix_re($ver_re)(?: 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 (\d+(?:\.\d+)*)/i ) {
+               when ( /GPL as published by the Free Software Foundation, 
version ($ver_re)/i ) {
                        $gplver      = " (v$1)";
                        @spdx_gplver = ($1)
                }
@@ -438,7 +441,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),? version ([\d\.]+)/i 
) {
+               when ( /this is free software,? licensed under:? (?:the 
)?(?:GNU (?:Library |Lesser )General Public License|LGPL),? 
$ver_prefix_re($ver_re)/i ) {
                        $license = "LGPL (v$1) $license";
                        push @spdx_license, "LGPL-$1";
                }
@@ -550,11 +553,11 @@ sub parse_license
 
        # MPL
        given ($licensetext) {
-               when ( /Mozilla Public License,? (?:(?:Version|v\.) 
)?(\d+(?:\.\d+)?)/ ) {
+               when ( /Mozilla Public License,? $ver_prefix_re($ver_re)/ ) {
                        $license = "MPL (v$1) $license";
                        push @spdx_license, "MPL-$1";
                }
-               when ( /Mozilla Public License,? \((?:Version|v\.) 
(\d+(?:\.\d+)?)\)/ ) {
+               when ( /Mozilla Public License,? \($ver_prefix_re($ver_re)\)/ ) 
{
                        $license = "MPL (v$1) $license";
                        push @spdx_license, "MPL-$1";
                }
@@ -564,7 +567,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?([\d.]*\d)/ ) {
+               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)/ ) {
                        $license = "Artistic (v$1) $license";
                        push @spdx_license, "Artistic-$1";
                }
@@ -586,7 +589,7 @@ sub parse_license
 
        # Apache
        given ($licensetext) {
-               when ( /under the Apache License, Version ([^ ]+)/ ) {
+               when ( /under the Apache License,? $ver_prefix_re($ver_re)/ ) {
                        $license = "Apache (v$1) $license";
                        push @spdx_license, "Apache-$1";
                }
@@ -610,7 +613,7 @@ sub parse_license
 
        # PHP
        given ($licensetext) {
-               when ( /This source file is subject to version ([^ ]+) of the 
PHP license/ ) {
+               when ( /This source file is subject to version ($ver_re) of the 
PHP license/ ) {
                        $license = "PHP (v$1) $license";
                        push @spdx_license, "PHP-$1";
                }
@@ -646,7 +649,7 @@ sub parse_license
 
        # CDDL
        given ($licensetext) {
-               when ( /terms of the Common Development and Distribution 
License(, Version ([^(]+))? \(the License\)/ ) {
+               when ( /terms of the Common Development and Distribution 
License(,? $ver_prefix_re($ver_re))? \(the License\)/ ) {
                        $license = "CDDL " . ( $1 ? "(v$2) " : '' ) . $license;
                        push @spdx_license, 'CDDL' . ( $1 ? "-$2" : '' );
                }
@@ -662,7 +665,7 @@ sub parse_license
 
        # AFL
        given ($licensetext) {
-               when ( /Licensed under the Academic Free License version 
([\d.]+)/ ) {
+               when ( /Licensed under the Academic Free License 
$ver_prefix_re($ver_re)/ ) {
                        $license = $1 ? "AFL-$1" : "AFL";
                        push @spdx_license, 'AFL' . ( $1 ? "-$1" : '' );
                }
@@ -670,7 +673,7 @@ sub parse_license
 
        # EPL
        given ($licensetext) {
-               when ( /This program and the accompanying materials are made 
available under the terms of the Eclipse Public License v?([\d.]+)/ ) {
+               when ( /This program and the accompanying materials are made 
available under the terms of the Eclipse Public License 
$ver_prefix_re($ver_re)/ ) {
                        $license = $1 ? "EPL-$1" : "EPL";
                        push @spdx_license, 'EPL' . ( $1 ? "-$1" : '' );
                }
@@ -682,7 +685,7 @@ sub parse_license
                        $license = "BSL " . ( $1 ? "(v$2) " : '' ) . $license;
                        push @spdx_license, 'BSL' . ( $1 ? "-$2" : '' );
                }
-               when ( /Boost Software License([ ,-]+Version ([^ ]+)?(\.))/i ) {
+               when ( /Boost Software License([ ,-]+ 
$ver_prefix_re($ver_re)?(\.))/i ) {
                        $license = "BSL " . ( $1 ? "(v$2) " : '' ) . $license;
                        push @spdx_license, 'BSL' . ( $1 ? "-$2" : '' );
                }
@@ -690,7 +693,7 @@ sub parse_license
 
        # Python
        given ($licensetext) {
-               when ( /PYTHON SOFTWARE FOUNDATION LICENSE (VERSION ([^ ]+))/i 
) {
+               when ( /PYTHON SOFTWARE FOUNDATION LICENSE(,? 
$ver_prefix_re($ver_re))/i ) {
                        $license = "PSF " . ( $1 ? "(v$2) " : '' ) . $license;
                        push @spdx_license, 'Python' . ( $1 ? "-$2" : '' );
                }
@@ -714,7 +717,7 @@ sub parse_license
 
        # WTFPL
        given ($licensetext) {
-               when ( /Do What The Fuck You Want To Public License, Version 
([^, ]+)/i ) {
+               when ( /Do What The Fuck You Want To Public License,? 
$ver_prefix_re($ver_re)/i ) {
                        $license = "WTFPL (v$1) $license";
                        push @spdx_license, "WTFPL-$1";
                }

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

_______________________________________________
Pkg-perl-cvs-commits mailing list
Pkg-perl-cvs-commits@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-perl-cvs-commits

Reply via email to