[libconfig-model-dpkg-perl] 06/09: Patch: keep track of line number when handling free form comment

dod at debian.org dod at debian.org
Fri May 8 08:51:41 UTC 2015


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

dod pushed a commit to branch master
in repository libconfig-model-dpkg-perl.

commit 1069b04aae074e6303939ca7c1f8e2219c479778
Author: Dominique Dumont <dod at debian.org>
Date:   Thu May 7 20:06:02 2015 +0200

    Patch: keep track of line number when handling free form comment
---
 lib/Config/Model/Backend/Dpkg/Patch.pm | 10 +++++++---
 lib/Config/Model/Backend/DpkgSyntax.pm |  8 ++++----
 2 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/lib/Config/Model/Backend/Dpkg/Patch.pm b/lib/Config/Model/Backend/Dpkg/Patch.pm
index 607a30a..2f33e25 100644
--- a/lib/Config/Model/Backend/Dpkg/Patch.pm
+++ b/lib/Config/Model/Backend/Dpkg/Patch.pm
@@ -71,9 +71,13 @@ sub read {
 
     my $c = [] ;
     $logger->trace("header: @$header") ;
-    my @stuff ;
-    my $store_stuff = sub { push @stuff, shift ;} ;
-    
+    my %stuff ;
+    my $store_stuff = sub {
+        my ($l,$nb) = @_;
+        die "undef line nb" unless defined $nb;
+        $stuff{$nb} = $l ;
+    } ;
+
     if (@$header) {
         $c = eval { $self->parse_dpkg_lines( $header, $check, 0, $store_stuff ); };
         my $e;
diff --git a/lib/Config/Model/Backend/DpkgSyntax.pm b/lib/Config/Model/Backend/DpkgSyntax.pm
index d8a9de9..8417a5f 100644
--- a/lib/Config/Model/Backend/DpkgSyntax.pm
+++ b/lib/Config/Model/Backend/DpkgSyntax.pm
@@ -72,11 +72,11 @@ sub parse_dpkg_lines {
             push @res, $section_line, $store_list if @$store_list ; # don't store empty sections 
             $store_list = [] ;
             $section_line = $line_nb + 1; # next line, will be clobbered if next line is empty
-	    chomp $$store_ref if defined $$store_ref; # remove trailing \n 
+            chomp $$store_ref if defined $$store_ref; # remove trailing \n
             undef $store_ref ; # to ensure that next line contains a keyword
         }
         elsif (/^\s*$/) {     # "extra" empty line
-            $handle_garbage->($_) if $handle_garbage ;
+            $handle_garbage->($_, $line_nb) if $handle_garbage ;
             $logger->trace("extra empty line: skipped");
             # just skip it
         } 
@@ -89,13 +89,13 @@ sub parse_dpkg_lines {
             _store_line($store_ref,$_ , $check,$line_nb);
         }
         elsif ($handle_garbage) {
-            $handle_garbage->($_) ; 
+            $handle_garbage->($_, $line_nb) ;
         }
         else {
             my $msg = "DpkgSyntax error: Invalid line (missing ':' ?) : $_" ;
             Config::Model::Exception::Syntax -> throw ( message => $msg, parsed_line => $line_nb ) 
                 if $check eq 'yes' ; 
-	    $logger->error($msg) if $check eq 'skip';
+            $logger->error($msg) if $check eq 'skip';
         }
         $line_nb++;
     }

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



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