[dh-make-perl] 01/03: Debian::Control::Stanza: accept case-insensitive field names in new()

gregor herrmann gregoa at debian.org
Thu Apr 13 19:40:14 UTC 2017


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

gregoa pushed a commit to branch master
in repository dh-make-perl.

commit 9865bf12a9cbb6477e9a29bc086318a2e971801e
Author: Alex Muntada <alexm at alexm.org>
Date:   Thu Apr 13 15:54:19 2017 +0200

    Debian::Control::Stanza: accept case-insensitive field names in new()
    
    as required by Debian Policy while retaining the canonical accessors.
    
    Thanks: Ben Finney for the bug report.
    Closes: #860023
---
 lib/Debian/Control/Stanza.pm | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/lib/Debian/Control/Stanza.pm b/lib/Debian/Control/Stanza.pm
index f6642e6..3036e14 100644
--- a/lib/Debian/Control/Stanza.pm
+++ b/lib/Debian/Control/Stanza.pm
@@ -48,9 +48,17 @@ L<Debian::Dependencies> class.
 
 use constant fields => ();
 
+my %canonical;
+
 sub import {
     my( $class ) = @_;
 
+    # map the accessor name for the lower case equivalent
+    %canonical = map (
+        ( lc($_) => $_ ),
+        $class->fields,
+    );
+
     $class->mk_accessors( $class->fields );
 }
 
@@ -87,6 +95,8 @@ sub new {
 
     while( my($k,$v) = each %$init ) {
         $k =~ s/-/_/g;
+        # translate field name into the accessor canonical name
+        $k = $canonical{ lc $k } || $k;
         $self->can($k)
             or croak "Invalid field given ($k)";
         $self->$k($v);

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



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