Explorar el Código

Dpkg::ErrorHandling: Add new report_options()

Set report options via this new function instead of directly exporting
private variables.
Guillem Jover hace 17 años
padre
commit
b299dad5ad

+ 12 - 3
scripts/Dpkg/ErrorHandling.pm

@@ -4,11 +4,20 @@ use Dpkg;
 use Dpkg::Gettext;
 
 use base qw(Exporter);
-our @EXPORT = qw(info warning error errormsg
+our @EXPORT = qw(report_options info warning error errormsg
                  syserr internerr subprocerr usageerr syntaxerr);
-our @EXPORT_OK = qw(report unknown $quiet_warnings);
+our @EXPORT_OK = qw(report unknown);
 
-our $quiet_warnings = 0;
+my $quiet_warnings = 0;
+
+sub report_options
+{
+    my (%options) = @_;
+
+    if (exists $options{quiet_warnings}) {
+        $quiet_warnings = $options{quiet_warnings};
+    }
+}
 
 sub report(@)
 {

+ 2 - 2
scripts/dpkg-source.pl

@@ -6,7 +6,7 @@ use warnings;
 
 use Dpkg;
 use Dpkg::Gettext;
-use Dpkg::ErrorHandling qw(:DEFAULT unknown $quiet_warnings);
+use Dpkg::ErrorHandling qw(:DEFAULT unknown);
 use Dpkg::Arch qw(debarch_eq);
 use Dpkg::Deps qw(@src_dep_fields %dep_field_type);
 use Dpkg::Fields qw(:list capit);
@@ -115,7 +115,7 @@ while (@ARGV && $ARGV[0] =~ m/^-/) {
         # Deprecated option
         warning(_g("-E and -W are deprecated, they are without effect"));
     } elsif (m/^-q$/) {
-        $quiet_warnings = 1;
+        report_options(quiet_warnings => 1);
         $options{'quiet'} = 1;
     } elsif (m/^--$/) {
         last;

+ 3 - 3
scripts/t/100_Dpkg_Version.t

@@ -1,13 +1,13 @@
 # -*- mode: cperl;-*-
 
 use Test::More;
-use Dpkg::ErrorHandling qw($quiet_warnings);
-
-$quiet_warnings = 1;
+use Dpkg::ErrorHandling;
 
 use strict;
 use warnings;
 
+report_options(quiet_warnings => 1);
+
 my @tests = <DATA>;
 my @ops = ("<", "<<", "lt",
 	   "<=", "le",

+ 2 - 1
scripts/t/300_Dpkg_BuildOptions.t

@@ -1,6 +1,7 @@
 # -*- mode: cperl;-*-
 
 use Test::More tests => 6;
+use Dpkg::ErrorHandling;
 
 use strict;
 use warnings;
@@ -11,7 +12,7 @@ use_ok('Dpkg::BuildOptions');
     no warnings;
     # Disable warnings related to invalid values fed during
     # the tests
-    $Dpkg::ErrorHandling::quiet_warnings = 1;
+    report_options(quiet_warnings => 1);
 }
 
 $ENV{DEB_BUILD_OPTIONS} = 'noopt foonostripbar parallel=3 bazNOCHECK';