[devscripts] 04/04: licensecheck: parse multi-line copyright block (Closes: #519080)

dod at debian.org dod at debian.org
Sun Nov 22 19:51:20 UTC 2015


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

dod pushed a commit to branch master
in repository devscripts.

commit 8d8ea3e1675ea1d3144690840d83b6adff0a2a2d
Author: Dominique Dumont <dod at debian.org>
Date:   Fri Nov 20 13:43:01 2015 +0100

    licensecheck: parse multi-line copyright block (Closes: #519080)
---
 debian/changelog                         |  1 +
 scripts/licensecheck.pl                  | 15 +++++++++++++--
 test/licensecheck/multi-line-copyright.c | 25 +++++++++++++++++++++++++
 test/test_licensecheck                   |  2 ++
 4 files changed, 41 insertions(+), 2 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index f0108ae..70e8f35 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -33,6 +33,7 @@ devscripts (2.15.10) UNRELEASED; urgency=medium
     + added freetype license
     * remove 'by' from copyritght owners
     * remove white space from end of multiline copyright statements
+    * parse multi-lien copyright blocks (Closes: #519080)
 
   [ Osamu Aoki ]
   * uscan:
diff --git a/scripts/licensecheck.pl b/scripts/licensecheck.pl
index 740c763..5f81286 100755
--- a/scripts/licensecheck.pl
+++ b/scripts/licensecheck.pl
@@ -374,11 +374,12 @@ sub extract_copyright {
     my %copyrights;
     my $lines_after_copyright_block = 0;
 
+    my $in_copyright_block = 0;
     while (@c) {
 	my $line = shift @c ;
-	my $copyright_match = parse_copyright($line) ;
+	my $copyright_match = parse_copyright($line, \$in_copyright_block) ;
 	if ($copyright_match) {
-	    while (@c && $copyright_match =~ /\d[,.]?\s*$/) {
+	    while (@c and $copyright_match =~ /\d[,.]?\s*$/) {
 		# looks like copyright end with a year, assume the owner is on next line(s)
 		$copyright_match .= ' '. shift @c;
 	    }
@@ -397,6 +398,7 @@ sub extract_copyright {
 
 sub parse_copyright {
     my $data = shift ;
+    my $in_copyright_block_ref = shift;
     my $copyright = '';
     my $match;
 
@@ -404,6 +406,7 @@ sub parse_copyright {
 	#print "match against ->$data<-\n";
         if ($data =~ $copyright_indicator_regex_with_capture) {
             $match = $1;
+	    $$in_copyright_block_ref = 1;
             # Ignore lines matching "see foo for copyright information" etc.
             if ($match !~ $copyright_disindicator_regex) {
 		# De-cruft
@@ -417,6 +420,14 @@ sub parse_copyright {
                 $copyright = $match;
             }
         }
+	elsif ($$in_copyright_block_ref and $data =~ /^\d{2,}[,\s]+/) {
+	    # following lines beginning with a year are supposed to be
+	    # continued copyright blocks
+	    $copyright = $data;
+	}
+	else {
+	    $$in_copyright_block_ref = 0;
+	}
     }
 
     return $copyright;
diff --git a/test/licensecheck/multi-line-copyright.c b/test/licensecheck/multi-line-copyright.c
new file mode 100644
index 0000000..224ea3d
--- /dev/null
+++ b/test/licensecheck/multi-line-copyright.c
@@ -0,0 +1,25 @@
+/*************************************************************************
+ * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
+ *             2005 Lars Knoll & Zack Rusin, Trolltech
+ *             2008 Aaron Plattner, NVIDIA Corporation
+ *
+ * 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
+ * the Free Software Foundation; version 3 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see http://www.gnu.org/licenses/.
+ *
+ * This file may incorporate work that is in the public domain and/or
+ * covered under the following copyright and permission notice:
+ *
+ *   Written by devscripts developers and released to the public domain,
+ *   as explained at http://creativecommons.org/publicdomain/zero/1.0/
+ ************************************************************************/
+
+/* See https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=519080 */
diff --git a/test/test_licensecheck b/test/test_licensecheck
index 44da012..977baa4 100755
--- a/test/test_licensecheck
+++ b/test/test_licensecheck
@@ -62,6 +62,8 @@ testMultiLineDeclaration() {
     license2 "-m --copyright" "bsd-regents.c" "BSD (3 clause)	1987, 1993, 1994 The Regents of the University of California. All rights reserved."
     # or 3 lines
     license2 "-m --copyright" "texinfo.tex" "GPL (v3 or later)	1985, 1986, 1988, 1990, 1991, 1992, 1993, 1994, 1995 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc."
+    # BTS #519080
+    license2 "-m --copyright" "multi-line-copyright.c" "Public domain GPL (v3)	2008 Aaron Plattner, NVIDIA Corporation / 2005 Lars Knoll & Zack Rusin, Trolltech / 2000 Keith Packard, member of The XFree86 Project, Inc"
 }
 
 testDuplicatedCopyright() {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/collab-maint/devscripts.git



More information about the devscripts-devel mailing list