Forráskód Böngészése

dpkg-scansources: Update Getopt::Long setup code

Configure it at use time. Use posix_default instead of defining
POSIXLY_CORRECT in the environment and setting the options that
would be enabled by default on POSIX. Call GetOptions in main
instead of calling init.
Guillem Jover 16 éve
szülő
commit
6456236bc3
1 módosított fájl, 3 hozzáadás és 29 törlés
  1. 3 29
      scripts/dpkg-scansources.pl

+ 3 - 29
scripts/dpkg-scansources.pl

@@ -20,6 +20,8 @@
 use strict;
 use strict;
 use warnings;
 use warnings;
 
 
+use Getopt::Long qw(:config posix_default bundling no_ignorecase);
+
 use Dpkg;
 use Dpkg;
 use Dpkg::Gettext;
 use Dpkg::Gettext;
 use Dpkg::ErrorHandling;
 use Dpkg::ErrorHandling;
@@ -30,8 +32,6 @@ use Dpkg::Compression;
 
 
 textdomain("dpkg-dev");
 textdomain("dpkg-dev");
 
 
-use Getopt::Long ();
-
 # Errors with a single package are warned about but don't affect the
 # Errors with a single package are warned about but don't affect the
 # exit code. Only errors which affect everything cause a non-zero exit.
 # exit code. Only errors which affect everything cause a non-zero exit.
 my $Exit = 0;
 my $Exit = 0;
@@ -100,38 +100,12 @@ See the man page for the full documentation.
     exit;
     exit;
 }
 }
 
 
-# Getopt::Long has some really awful defaults.  This function loads it
-# then configures it to use more sane settings.
-
-sub getopt(@);
-sub configure_getopt {
-    Getopt::Long->import(2.11);
-    *getopt = \&Getopt::Long::GetOptions;
-
-    # I'm setting this environment variable lest he sneaks more bad
-    # defaults into the module.
-    local $ENV{POSIXLY_CORRECT} = 1;
-    Getopt::Long::config qw(
-	default
-	no_autoabbrev
-	no_getopt_compat
-	require_order
-	bundling
-	no_ignorecase
-    );
-}
-
 sub close_msg {
 sub close_msg {
     my $name = shift;
     my $name = shift;
     return sprintf(_g("error closing %s (\$? %d, \$! `%s')"),
     return sprintf(_g("error closing %s (\$? %d, \$! `%s')"),
                    $name, $?, $!)."\n";
                    $name, $?, $!)."\n";
 }
 }
 
 
-sub init {
-    configure_getopt;
-    getopt @Option_spec or usage;
-}
-
 sub load_override {
 sub load_override {
     my $file = shift;
     my $file = shift;
     local $_;
     local $_;
@@ -337,7 +311,7 @@ sub process_dsc {
 sub main {
 sub main {
     my (@out);
     my (@out);
 
 
-    init;
+    GetOptions(@Option_spec) or usage;
     @ARGV >= 1 && @ARGV <= 3 or usageerr(_g("1 to 3 args expected\n"));
     @ARGV >= 1 && @ARGV <= 3 or usageerr(_g("1 to 3 args expected\n"));
 
 
     push @ARGV, undef		if @ARGV < 2;
     push @ARGV, undef		if @ARGV < 2;