Ben Finney:

> So, with the above example, if each those field names were accepted,
> and they all map to the Perl object accessor ‘Vcs_Git’, and other Perl
> code still needed to spell the *accessor* name that way, that would
> IMO be compliant with Policy and would resolve this bug report.

The patch provided below accepts any valid field ignoring case
by using the canonical name instead, so VCS-Git, vCS-gIT, etc.
will end up being Vcs-Git. Would that be compliant with Policy?

Cheers!
Alex

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);

Attachment: signature.asc
Description: Digital signature

Reply via email to