rev 11016 - in people/modax/copyright-helper/trunk: . parsers

Modestas Vainius modax-guest at alioth.debian.org
Fri Jun 13 19:49:52 UTC 2008


Author: modax-guest
Date: 2008-06-13 19:49:52 +0000 (Fri, 13 Jun 2008)
New Revision: 11016

Added:
   people/modax/copyright-helper/trunk/parsers/numsign.pm
Modified:
   people/modax/copyright-helper/trunk/CHCopyright.pm
   people/modax/copyright-helper/trunk/CHCore.pm
   people/modax/copyright-helper/trunk/CHParsers.pm
   people/modax/copyright-helper/trunk/copyright-helper.pl
Log:
Add support for files with # comments. Even more UTF-8 fixes

Modified: people/modax/copyright-helper/trunk/CHCopyright.pm
===================================================================
--- people/modax/copyright-helper/trunk/CHCopyright.pm	2008-06-13 19:47:06 UTC (rev 11015)
+++ people/modax/copyright-helper/trunk/CHCopyright.pm	2008-06-13 19:49:52 UTC (rev 11016)
@@ -19,7 +19,7 @@
 # Perl does not seem to match (regex) © without this trick in utf8 mode
 our $__copyright_symbol = '©';
 
-our $__copyright_separator = qr/copyright\W|(?:^|[^@])authors?:|(?:\(C\)|$__copyright_symbol)\s+(?!\d)/io;
+our $__copyright_separator = qr/copyright\W|(?:^|[^@])authors?:|(?:\(C\)|$__copyright_symbol)\s*/io;
 our $__copyright_match = qr/\(C\)|$__copyright_symbol/io;
 our $__email_regexp = qr/([a-zA-Z0-9_\+-.]+@[a-zA-Z0-9_\+-.]+)/o;
 our $__fuzzy_emailpart_regexp = qr/(?:[a-z0-9_\\+-]+(?:\s+dot\s+|[.\s]))+/io;

Modified: people/modax/copyright-helper/trunk/CHCore.pm
===================================================================
--- people/modax/copyright-helper/trunk/CHCore.pm	2008-06-13 19:47:06 UTC (rev 11015)
+++ people/modax/copyright-helper/trunk/CHCore.pm	2008-06-13 19:49:52 UTC (rev 11016)
@@ -15,6 +15,7 @@
 
 package CHCore;
 use strict;
+use open ":encoding(utf8)";
 
 @CHCore::Directory::ISA = qw( CHCore::File );
 

Modified: people/modax/copyright-helper/trunk/CHParsers.pm
===================================================================
--- people/modax/copyright-helper/trunk/CHParsers.pm	2008-06-13 19:47:06 UTC (rev 11015)
+++ people/modax/copyright-helper/trunk/CHParsers.pm	2008-06-13 19:49:52 UTC (rev 11016)
@@ -15,6 +15,7 @@
 
 package CHParsers;
 use strict;
+use open ":encoding(utf8)";
 
 require Exporter;
 our @ISA = qw( Exporter );

Modified: people/modax/copyright-helper/trunk/copyright-helper.pl
===================================================================
--- people/modax/copyright-helper/trunk/copyright-helper.pl	2008-06-13 19:47:06 UTC (rev 11015)
+++ people/modax/copyright-helper/trunk/copyright-helper.pl	2008-06-13 19:49:52 UTC (rev 11016)
@@ -29,6 +29,7 @@
 use open ":encoding(utf8)";
 binmode STDOUT, ":utf8";
 use encoding "utf8";
+use utf8;
 
 my $max_header = 70;
 my $opt_show_headers = 1;
@@ -220,7 +221,7 @@
 }
 
 # Entry point
-${main::VERSION}='0.4.5';
+${main::VERSION}='0.4.6';
 print_msg "\n";
 print_msg "Copyright Helper v${main::VERSION}\n";
 print_msg "Extracts copyright and license information from source code\n\n";

Added: people/modax/copyright-helper/trunk/parsers/numsign.pm
===================================================================
--- people/modax/copyright-helper/trunk/parsers/numsign.pm	                        (rev 0)
+++ people/modax/copyright-helper/trunk/parsers/numsign.pm	2008-06-13 19:49:52 UTC (rev 11016)
@@ -0,0 +1,69 @@
+# Copyright (C) 2008 Modestas Vainius <modestas at vainius.eu>
+#
+# 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, either version 3 of the License, or
+# (at your option) any later version.
+#
+# 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/>
+
+package CHParsers::numsign;
+use strict;
+
+our @ISA = qw( CHParsers::ParserBase );
+
+sub __push_comment(\@\@) {
+    my ($comments, $comment) = @_;
+    if (scalar(@$comment) > 0) {
+        push @$comments, join("\n", @$comment);
+        @{$_[1]} = ();
+    }
+}
+
+sub filter ($$) {
+    my ($self, $fh) = @_;
+    my @comments = ();
+    my @comment = ();
+    while (<$fh>) {
+        # Beginning of the comment
+        if (m/#\s*(.*)$/) {
+            if ($1) {
+                push @comment, $1;
+            } else {
+                __push_comment @comments, @comment;
+            }
+        } else {
+            __push_comment @comments, @comment;
+        }
+    }
+    __push_comment @comments, @comment;
+    return @comments;
+}
+
+sub toParagraphs($\@) {
+    my $self = shift;
+    my @text = @{shift()};
+    my @parags = ();
+
+    foreach $_ (@text) {
+        my @lines = split(/\n/);
+        map s/\s+/ /g, @lines;
+        push @parags, @lines;
+    }
+    return @parags;
+}
+
+sub getCopyrights($\@) {
+    # Fuzzy search is forced
+    return $_[0]->getStandardCopyrights($_[1], 1);
+}
+
+sub extensions { 
+    return qw( pl py cmake );
+}




More information about the pkg-kde-commits mailing list