The following commit has been merged in the master branch:
commit 2e62609bbee5104f546df72c861a09f919d0fad6
Author: Guillem Jover <guil...@debian.org>
Date:   Sun May 20 15:22:35 2012 +0200

    scripts: Use new pkg_name_is_illegal() instead of ad-hoc checks

diff --git a/scripts/Dpkg/Vars.pm b/scripts/Dpkg/Vars.pm
index 6f82103..d0ccb29 100644
--- a/scripts/Dpkg/Vars.pm
+++ b/scripts/Dpkg/Vars.pm
@@ -1,3 +1,4 @@
+# Copyright © 2007-2009,2012 Guillem Jover <guil...@debian.org>
 # Copyright © 2007 Raphaël Hertzog <hert...@debian.org>
 #
 # This program is free software; you can redistribute it and/or modify
@@ -18,29 +19,22 @@ package Dpkg::Vars;
 use strict;
 use warnings;
 
-our $VERSION = "0.01";
+our $VERSION = "0.02";
 
 use Dpkg::ErrorHandling;
 use Dpkg::Gettext;
+use Dpkg::Package;
 
 use base qw(Exporter);
 our @EXPORT = qw($sourcepackage set_source_package);
 
 our $sourcepackage;
 
-sub check_package_name {
-    my $name = shift || '';
-    $name =~ m/[^-+.0-9a-z]/o &&
-        error(_g("source package name `%s' contains illegal character `%s'"),
-              $name, $&);
-    $name =~ m/^[0-9a-z]/o ||
-        error(_g("source package name `%s' starts with non-alphanum"), $name);
-}
-
 sub set_source_package {
     my $v = shift;
+    my $err = pkg_name_is_illegal($v);
+    error(_g("source package name '%s' is illegal: %s"), $v, $err) if $err;
 
-    check_package_name($v);
     if (defined($sourcepackage)) {
         $v eq $sourcepackage ||
             error(_g("source package has two conflicting values - %s and %s"),
diff --git a/scripts/dpkg-gencontrol.pl b/scripts/dpkg-gencontrol.pl
index fab4452..77502e3 100755
--- a/scripts/dpkg-gencontrol.pl
+++ b/scripts/dpkg-gencontrol.pl
@@ -4,6 +4,7 @@
 #
 # Copyright © 1996 Ian Jackson
 # Copyright © 2000,2002 Wichert Akkerman
+# Copyright © 2006-2012 Guillem Jover <guil...@debian.org>
 #
 # 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
@@ -28,6 +29,7 @@ use Dpkg;
 use Dpkg::Gettext;
 use Dpkg::ErrorHandling;
 use Dpkg::Arch qw(get_host_arch debarch_eq debarch_is);
+use Dpkg::Package;
 use Dpkg::Deps;
 use Dpkg::Control;
 use Dpkg::Control::Info;
@@ -91,10 +93,10 @@ Options:
 
 while (@ARGV) {
     $_=shift(@ARGV);
-    if (m/^-p([-+0-9a-z.]+)$/) {
-        $oppackage= $1;
-    } elsif (m/^-p(.*)/) {
-        error(_g("Illegal package name \`%s'"), $1);
+    if (m/^-p/) {
+        $oppackage = $';
+        my $err = pkg_name_is_illegal($oppackage);
+        error(_g("illegal package name '%s': %s"), $oppackage, $err) if $err;
     } elsif (m/^-c/) {
         $controlfile= $';
     } elsif (m/^-l/) {
diff --git a/scripts/dpkg-gensymbols.pl b/scripts/dpkg-gensymbols.pl
index c574331..9e900b2 100755
--- a/scripts/dpkg-gensymbols.pl
+++ b/scripts/dpkg-gensymbols.pl
@@ -3,6 +3,7 @@
 # dpkg-gensymbols
 #
 # Copyright © 2007 Raphaël Hertzog
+# Copyright © 2007-2012 Guillem Jover <guil...@debian.org>
 #
 # 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
@@ -22,6 +23,7 @@ use warnings;
 
 use Dpkg;
 use Dpkg::Arch qw(get_host_arch);
+use Dpkg::Package;
 use Dpkg::Shlibs qw(@librarypaths);
 use Dpkg::Shlibs::Objdump;
 use Dpkg::Shlibs::SymbolFile;
@@ -95,8 +97,10 @@ Options:
 my @files;
 while (@ARGV) {
     $_ = shift(@ARGV);
-    if (m/^-p([-+0-9a-z.]+)$/) {
-       $oppackage = $1;
+    if (m/^-p/) {
+       $oppackage = $';
+       my $err = pkg_name_is_illegal($oppackage);
+       error(_g("illegal package name '%s': %s"), $oppackage, $err) if $err;
     } elsif (m/^-c(\d)?$/) {
        $compare = defined($1) ? $1 : 1;
     } elsif (m/^-q$/) {
@@ -115,8 +119,6 @@ while (@ARGV) {
            warning(_g("pattern '%s' did not match any file"), $file)
                unless scalar(@to_add);
        }
-    } elsif (m/^-p(.*)/) {
-       error(_g("Illegal package name \`%s'"), $1);
     } elsif (m/^-P(.+)$/) {
        $packagebuilddir = $1;
        $packagebuilddir =~ s{/+$}{};

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to debian-dpkg-cvs-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to