[devscripts] 02/03: licensecheck: extracted parse_file
dod at debian.org
dod at debian.org
Fri Mar 25 13:17:44 UTC 2016
This is an automated email from the git hooks/post-receive script.
dod pushed a commit to branch master
in repository devscripts.
commit 6f55701d917bb0a1576abe3306af091a9fad0ed9
Author: Dominique Dumont <dod at debian.org>
Date: Fri Mar 25 13:29:05 2016 +0100
licensecheck: extracted parse_file
---
scripts/licensecheck.pl | 38 +++++++++++++++++++++++---------------
1 file changed, 23 insertions(+), 15 deletions(-)
diff --git a/scripts/licensecheck.pl b/scripts/licensecheck.pl
index 63f0c6a..16d3ef4 100755
--- a/scripts/licensecheck.pl
+++ b/scripts/licensecheck.pl
@@ -401,13 +401,33 @@ while (@ARGV) {
while (@files) {
my $file = shift @files;
+
+ my $enc = $OPT{encoding} ;
+
+ my ($license, $copyright) = parse_file($file, $enc) ;
+
+ 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_file {
+ my $file = shift;
+ my $enc = shift;
my $content = '';
my $copyright_match;
my $copyright = '';
my $st = stat $file;
-
- my $enc = $OPT{encoding} ;
my $mode = $enc ? "<:encoding($enc)" : '<';
# need to use "<" when encoding is unknown otherwise we break compatibility
my $fh = IO::File->new ($file ,$mode) or die "Unable to access $file: $!\n";
@@ -446,19 +466,7 @@ while (@files) {
}
$fh->close;
-
- 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'};
- }
+ return ($license, $copyright);
}
sub extract_copyright {
--
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