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

guillem pushed a commit to branch main
in repository dpkg.

View the commit online:
https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=587fbdbefc4896f58186fb6db9df540a93f7a6fb

commit 587fbdbefc4896f58186fb6db9df540a93f7a6fb
Author: Guillem Jover <[email protected]>
AuthorDate: Mon Aug 5 23:25:44 2024 +0200

    scripts: Use %opts instead of %options for constructor and function options
    
    This uses the same convention as other constructors and functions taking
    an options hash, and we'll reserve the %options name for program options.
---
 scripts/Dpkg/Arch.pm            |  4 +-
 scripts/Dpkg/Changelog.pm       |  2 +-
 scripts/Dpkg/Changelog/Parse.pm | 38 +++++++++----------
 scripts/Dpkg/Deps.pm            | 84 ++++++++++++++++++++---------------------
 scripts/Dpkg/ErrorHandling.pm   | 14 +++----
 scripts/Dpkg/Version.pm         |  2 +-
 scripts/t/Dpkg_Deps.t           |  6 +--
 scripts/t/dpkg_buildpackage.t   |  4 +-
 scripts/t/dpkg_source.t         | 10 ++---
 9 files changed, 82 insertions(+), 82 deletions(-)

diff --git a/scripts/Dpkg/Arch.pm b/scripts/Dpkg/Arch.pm
index 0d352eeb9..e27259014 100644
--- a/scripts/Dpkg/Arch.pm
+++ b/scripts/Dpkg/Arch.pm
@@ -600,7 +600,7 @@ sub debarch_is_wildcard($)
     return 0;
 }
 
-=item $bool = debarch_is_illegal($arch, %options)
+=item $bool = debarch_is_illegal($arch, %opts)
 
 Validate an architecture name.
 
@@ -656,7 +656,7 @@ sub debarch_is_concerned
     return $seen_arch;
 }
 
-=item @array = debarch_list_parse($arch_list, %options)
+=item @array = debarch_list_parse($arch_list, %opts)
 
 Parse an architecture list.
 
diff --git a/scripts/Dpkg/Changelog.pm b/scripts/Dpkg/Changelog.pm
index 6de7bf31e..99d11c1cb 100644
--- a/scripts/Dpkg/Changelog.pm
+++ b/scripts/Dpkg/Changelog.pm
@@ -54,7 +54,7 @@ use overload
 
 =over 4
 
-=item $c = Dpkg::Changelog->new(%options)
+=item $c = Dpkg::Changelog->new(%opts)
 
 Creates a new changelog object.
 
diff --git a/scripts/Dpkg/Changelog/Parse.pm b/scripts/Dpkg/Changelog/Parse.pm
index 9b0afb754..add9539be 100644
--- a/scripts/Dpkg/Changelog/Parse.pm
+++ b/scripts/Dpkg/Changelog/Parse.pm
@@ -103,27 +103,27 @@ All the other keys in %opt are forwarded to the parser 
module constructor.
 =cut
 
 sub changelog_parse {
-    my (%options) = @_;
+    my (%opts) = @_;
 
-    $options{verbose} //= 1;
-    $options{file} //= 'debian/changelog';
-    $options{label} //= $options{file};
-    $options{changelogformat} //= _changelog_detect_format($options{file});
-    $options{format} //= 'dpkg';
-    $options{compression} //= $options{file} ne 'debian/changelog';
+    $opts{verbose} //= 1;
+    $opts{file} //= 'debian/changelog';
+    $opts{label} //= $opts{file};
+    $opts{changelogformat} //= _changelog_detect_format($opts{file});
+    $opts{format} //= 'dpkg';
+    $opts{compression} //= $opts{file} ne 'debian/changelog';
 
     my @range_opts = qw(since until from to offset count reverse all);
-    $options{all} = 1 if exists $options{all};
-    if (none { defined $options{$_} } @range_opts) {
-        $options{count} = 1;
+    $opts{all} = 1 if exists $opts{all};
+    if (none { defined $opts{$_} } @range_opts) {
+        $opts{count} = 1;
     }
     my $range;
     foreach my $opt (@range_opts) {
-        $range->{$opt} = $options{$opt} if exists $options{$opt};
+        $range->{$opt} = $opts{$opt} if exists $opts{$opt};
     }
 
     # Find the right changelog parser.
-    my $format = ucfirst lc $options{changelogformat};
+    my $format = ucfirst lc $opts{changelogformat};
     my $changes;
     eval qq{
         require Dpkg::Changelog::$format;
@@ -132,22 +132,22 @@ sub changelog_parse {
     error(g_('changelog format %s is unknown: %s'), $format, $@) if $@;
     error(g_('changelog format %s is not a Dpkg::Changelog class'), $format)
         unless $changes->isa('Dpkg::Changelog');
-    $changes->set_options(reportfile => $options{label},
-                          verbose => $options{verbose},
+    $changes->set_options(reportfile => $opts{label},
+                          verbose => $opts{verbose},
                           range => $range);
 
     # Load and parse the changelog.
-    $changes->load($options{file}, compression => $options{compression})
-        or error(g_('fatal error occurred while parsing %s'), $options{file});
+    $changes->load($opts{file}, compression => $opts{compression})
+        or error(g_('fatal error occurred while parsing %s'), $opts{file});
 
     # Get the output into several Dpkg::Control objects.
     my @res;
-    if ($options{format} eq 'dpkg') {
+    if ($opts{format} eq 'dpkg') {
         push @res, $changes->format_range('dpkg', $range);
-    } elsif ($options{format} eq 'rfc822') {
+    } elsif ($opts{format} eq 'rfc822') {
         push @res, $changes->format_range('rfc822', $range);
     } else {
-        error(g_('unknown output format %s'), $options{format});
+        error(g_('unknown output format %s'), $opts{format});
     }
 
     if (wantarray) {
diff --git a/scripts/Dpkg/Deps.pm b/scripts/Dpkg/Deps.pm
index 959318452..223d51d39 100644
--- a/scripts/Dpkg/Deps.pm
+++ b/scripts/Dpkg/Deps.pm
@@ -175,7 +175,7 @@ sub deps_concat {
     return join ', ', grep { defined } @dep_list;
 }
 
-=item $dep = deps_parse($line, %options)
+=item $dep = deps_parse($line, %opts)
 
 This function parses the dependency line and returns an object, either a
 L<Dpkg::Deps::AND> or a L<Dpkg::Deps::Union>. Various options can alter the
@@ -260,45 +260,45 @@ dependencies are based on build dependencies (since dpkg 
1.22.1).
 =cut
 
 sub deps_parse {
-    my ($dep_line, %options) = @_;
+    my ($dep_line, %opts) = @_;
 
     # Validate arguments.
-    croak "invalid host_arch $options{host_arch}"
-        if defined $options{host_arch} and not defined 
debarch_to_debtuple($options{host_arch});
-    croak "invalid build_arch $options{build_arch}"
-        if defined $options{build_arch} and not defined 
debarch_to_debtuple($options{build_arch});
-
-    $options{use_arch} //= 1;
-    $options{reduce_arch} //= 0;
-    $options{use_profiles} //= 1;
-    $options{reduce_profiles} //= 0;
-    $options{reduce_restrictions} //= 0;
-    $options{union} //= 0;
-    $options{virtual} //= 0;
-    $options{build_dep} //= 0;
-    $options{tests_dep} //= 0;
-
-    if ($options{reduce_restrictions}) {
-        $options{reduce_arch} = 1;
-        $options{reduce_profiles} = 1;
+    croak "invalid host_arch $opts{host_arch}"
+        if defined $opts{host_arch} and not defined 
debarch_to_debtuple($opts{host_arch});
+    croak "invalid build_arch $opts{build_arch}"
+        if defined $opts{build_arch} and not defined 
debarch_to_debtuple($opts{build_arch});
+
+    $opts{use_arch} //= 1;
+    $opts{reduce_arch} //= 0;
+    $opts{use_profiles} //= 1;
+    $opts{reduce_profiles} //= 0;
+    $opts{reduce_restrictions} //= 0;
+    $opts{union} //= 0;
+    $opts{virtual} //= 0;
+    $opts{build_dep} //= 0;
+    $opts{tests_dep} //= 0;
+
+    if ($opts{reduce_restrictions}) {
+        $opts{reduce_arch} = 1;
+        $opts{reduce_profiles} = 1;
     }
-    if ($options{reduce_arch}) {
-        $options{host_arch} //= get_host_arch();
-        $options{build_arch} //= get_build_arch();
+    if ($opts{reduce_arch}) {
+        $opts{host_arch} //= get_host_arch();
+        $opts{build_arch} //= get_build_arch();
     }
-    if ($options{reduce_profiles}) {
-        $options{build_profiles} //= [ get_build_profiles() ];
+    if ($opts{reduce_profiles}) {
+        $opts{build_profiles} //= [ get_build_profiles() ];
     }
-    if ($options{tests_dep}) {
-        $options{build_dep} = 1;
+    if ($opts{tests_dep}) {
+        $opts{build_dep} = 1;
     }
 
     # Options for Dpkg::Deps::Simple.
     my %deps_options = (
-        host_arch => $options{host_arch},
-        build_arch => $options{build_arch},
-        build_dep => $options{build_dep},
-        tests_dep => $options{tests_dep},
+        host_arch => $opts{host_arch},
+        build_arch => $opts{build_arch},
+        build_dep => $opts{build_dep},
+        tests_dep => $opts{tests_dep},
     );
 
     # Merge in a single-line
@@ -316,21 +316,21 @@ sub deps_parse {
                warning(g_("can't parse dependency %s"), $dep_or);
                return;
            }
-            if ($options{virtual} && defined $dep_simple->{relation} &&
+            if ($opts{virtual} && defined $dep_simple->{relation} &&
                 $dep_simple->{relation} ne '=') {
                 warning(g_('virtual dependency contains invalid relation: %s'),
                         $dep_simple->output);
                 return;
             }
-           $dep_simple->{arches} = undef if not $options{use_arch};
-            if ($options{reduce_arch}) {
-               $dep_simple->reduce_arch($options{host_arch});
-               next if not $dep_simple->arch_is_concerned($options{host_arch});
+            $dep_simple->{arches} = undef if not $opts{use_arch};
+            if ($opts{reduce_arch}) {
+                $dep_simple->reduce_arch($opts{host_arch});
+                next if not $dep_simple->arch_is_concerned($opts{host_arch});
            }
-           $dep_simple->{restrictions} = undef if not $options{use_profiles};
-           if ($options{reduce_profiles}) {
-               $dep_simple->reduce_profiles($options{build_profiles});
-               next if not 
$dep_simple->profile_is_concerned($options{build_profiles});
+            $dep_simple->{restrictions} = undef if not $opts{use_profiles};
+            if ($opts{reduce_profiles}) {
+                $dep_simple->reduce_profiles($opts{build_profiles});
+                next if not 
$dep_simple->profile_is_concerned($opts{build_profiles});
            }
            push @or_list, $dep_simple;
         }
@@ -344,13 +344,13 @@ sub deps_parse {
        }
     }
     my $dep_and;
-    if ($options{union}) {
+    if ($opts{union}) {
        $dep_and = Dpkg::Deps::Union->new();
     } else {
        $dep_and = Dpkg::Deps::AND->new();
     }
     foreach my $dep (@dep_list) {
-        if ($options{union} and not $dep->isa('Dpkg::Deps::Simple')) {
+        if ($opts{union} and not $dep->isa('Dpkg::Deps::Simple')) {
             warning(g_('an union dependency can only contain simple 
dependencies'));
             return;
         }
diff --git a/scripts/Dpkg/ErrorHandling.pm b/scripts/Dpkg/ErrorHandling.pm
index 253298be0..efe3a6f99 100644
--- a/scripts/Dpkg/ErrorHandling.pm
+++ b/scripts/Dpkg/ErrorHandling.pm
@@ -134,16 +134,16 @@ my %report_mode = (
 
 sub report_options
 {
-    my (%options) = @_;
+    my (%opts) = @_;
 
-    if (exists $options{quiet_warnings}) {
-        $quiet_warnings = $options{quiet_warnings};
+    if (exists $opts{quiet_warnings}) {
+        $quiet_warnings = $opts{quiet_warnings};
     }
-    if (exists $options{debug_level}) {
-        $debug_level = $options{debug_level};
+    if (exists $opts{debug_level}) {
+        $debug_level = $opts{debug_level};
     }
-    if (exists $options{info_fh}) {
-        $info_fh = $options{info_fh};
+    if (exists $opts{info_fh}) {
+        $info_fh = $opts{info_fh};
     }
 }
 
diff --git a/scripts/Dpkg/Version.pm b/scripts/Dpkg/Version.pm
index e045ad0f1..a4b60baa6 100644
--- a/scripts/Dpkg/Version.pm
+++ b/scripts/Dpkg/Version.pm
@@ -204,7 +204,7 @@ sub _comparison {
     return version_compare_part($a->revision(), $b->revision());
 }
 
-=item "$v", $v->as_string(), $v->as_string(%options)
+=item "$v", $v->as_string(), $v->as_string(%opts)
 
 Accepts an optional option hash reference, affecting the string conversion.
 
diff --git a/scripts/t/Dpkg_Deps.t b/scripts/t/Dpkg_Deps.t
index 15c73da83..5d8b9a6db 100644
--- a/scripts/t/Dpkg_Deps.t
+++ b/scripts/t/Dpkg_Deps.t
@@ -34,12 +34,12 @@ is(deps_concat('dep-a', undef, 'dep-b'), 'dep-a, dep-b',
    'Concatenate two strings with intermixed undef');
 
 sub test_dep_parse_option {
-    my %options = @_;
+    my %opts = @_;
 
     eval {
-        my $dep_croak = deps_parse('pkg', %options);
+        my $dep_croak = deps_parse('pkg', %opts);
     };
-    my $options = join ' ', map { "$_=$options{$_}" } keys %options;
+    my $options = join ' ', map { "$_=$opts{$_}" } keys %opts;
     ok(defined $@, "Parse with bogus arch options $options");
 }
 
diff --git a/scripts/t/dpkg_buildpackage.t b/scripts/t/dpkg_buildpackage.t
index 3f8c73c96..29679640c 100644
--- a/scripts/t/dpkg_buildpackage.t
+++ b/scripts/t/dpkg_buildpackage.t
@@ -139,11 +139,11 @@ sub gen_from_tmpl
 
 sub gen_source
 {
-    my (%options) = @_;
+    my (%opts) = @_;
 
     my $substvars = Dpkg::Substvars->new();
     foreach my $var (%default_substvars) {
-        my $value = $options{$var} // $default_substvars{$var};
+        my $value = $opts{$var} // $default_substvars{$var};
 
         $substvars->set_as_auto($var, $value);
     }
diff --git a/scripts/t/dpkg_source.t b/scripts/t/dpkg_source.t
index 056aa95bd..c8ec95618 100644
--- a/scripts/t/dpkg_source.t
+++ b/scripts/t/dpkg_source.t
@@ -101,11 +101,11 @@ sub gen_from_tmpl
 
 sub gen_source
 {
-    my (%options) = @_;
+    my (%opts) = @_;
 
     my $substvars = Dpkg::Substvars->new();
-    foreach my $var ((keys %default_substvars, keys %options)) {
-        my $value = $options{$var} // $default_substvars{$var};
+    foreach my $var ((keys %default_substvars, keys %opts)) {
+        my $value = $opts{$var} // $default_substvars{$var};
 
         $substvars->set_as_auto($var, $value);
     }
@@ -120,9 +120,9 @@ sub gen_source
     gen_from_tmpl("$dirname/debian/changelog", $tmpl_changelog, $substvars);
     gen_from_tmpl("$dirname/debian/control", $tmpl_control, $substvars);
 
-    if (defined $options{'control-test'}) {
+    if (defined $opts{'control-test'}) {
         make_path("$dirname/debian/tests");
-        gen_from_tmpl("$dirname/debian/tests/control", 
$options{'control-test'}, $substvars);
+        gen_from_tmpl("$dirname/debian/tests/control", $opts{'control-test'}, 
$substvars);
     }
 
     return $dirname;

-- 
Dpkg.Org's dpkg

Reply via email to