Quellcode durchsuchen

scripts: Use //= instead of ||= when appropriate

Replace only safe usages, i.e. those that fallback on initialization
values that evaluate to false anyway. Or when the API is explicit about
the variable being undefined.
Guillem Jover vor 12 Jahren
Ursprung
Commit
b0337f001b

+ 1 - 1
scripts/Dpkg/Compression/Process.pm

@@ -190,7 +190,7 @@ it for you.
 
 sub wait_end_process {
     my ($self, %opts) = @_;
-    $opts{cmdline} ||= $self->{cmdline};
+    $opts{cmdline} //= $self->{cmdline};
     wait_child($self->{pid}, %opts) if $self->{pid};
     delete $self->{pid};
     delete $self->{cmdline};

+ 2 - 2
scripts/Dpkg/IPC.pm

@@ -184,7 +184,7 @@ sub _sanity_check_opts {
 
 sub spawn {
     my (%opts) = _sanity_check_opts(@_);
-    $opts{close_in_child} ||= [];
+    $opts{close_in_child} //= [];
     my @prog;
     if (ref($opts{exec}) =~ /ARRAY/) {
 	push @prog, @{$opts{exec}};
@@ -340,7 +340,7 @@ with an error message.
 
 sub wait_child {
     my ($pid, %opts) = @_;
-    $opts{cmdline} ||= _g('child process');
+    $opts{cmdline} //= _g('child process');
     croak 'no PID set, cannot wait end of process' unless $pid;
     eval {
         local $SIG{ALRM} = sub { die "alarm\n" };

+ 1 - 1
scripts/Dpkg/Shlibs/Objdump.pm

@@ -173,7 +173,7 @@ sub reset {
 sub analyze {
     my ($self, $file) = @_;
 
-    $file ||= $self->{file};
+    $file //= $self->{file};
     return unless $file;
 
     $self->reset;

+ 4 - 4
scripts/Dpkg/Source/Archive.pm

@@ -35,7 +35,7 @@ use parent qw(Dpkg::Compression::FileHandle);
 
 sub create {
     my ($self, %opts) = @_;
-    $opts{options} ||= [];
+    $opts{options} //= [];
     my %spawn_opts;
     # Possibly run tar from another directory
     if ($opts{chdir}) {
@@ -99,9 +99,9 @@ sub finish {
 
 sub extract {
     my ($self, $dest, %opts) = @_;
-    $opts{options} ||= [];
-    $opts{in_place} ||= 0;
-    $opts{no_fixperms} ||= 0;
+    $opts{options} //= [];
+    $opts{in_place} //= 0;
+    $opts{no_fixperms} //= 0;
     my %spawn_opts = (wait_child => 1);
 
     # Prepare destination

+ 2 - 2
scripts/Dpkg/Source/Package.pm

@@ -212,7 +212,7 @@ sub init_options {
     my ($self) = @_;
     # Use full ignore list by default
     # note: this function is not called by V1 packages
-    $self->{options}{diff_ignore_regex} ||= $diff_ignore_default_regex;
+    $self->{options}{diff_ignore_regex} //= $diff_ignore_default_regex;
     $self->{options}{diff_ignore_regex} .= '|(?:^|/)debian/source/local-.*$';
     if (defined $self->{options}{tar_ignore}) {
         $self->{options}{tar_ignore} = [ @tar_ignore_default_pattern ]
@@ -224,7 +224,7 @@ sub init_options {
          'debian/source/local-patch-header';
     # Skip debianization while specific to some formats has an impact
     # on code common to all formats
-    $self->{options}{skip_debianization} ||= 0;
+    $self->{options}{skip_debianization} //= 0;
 
     # Set default compressor for new formats.
     $self->{options}{compression} //= 'xz';

+ 4 - 4
scripts/Dpkg/Source/Package/V1.pm

@@ -51,10 +51,10 @@ sub init_options {
     }
     push @{$self->{options}{tar_ignore}}, 'debian/source/local-options',
          'debian/source/local-patch-header';
-    $self->{options}{sourcestyle} ||= 'X';
-    $self->{options}{skip_debianization} ||= 0;
-    $self->{options}{ignore_bad_version} ||= 0;
-    $self->{options}{abort_on_upstream_changes} ||= 0;
+    $self->{options}{sourcestyle} //= 'X';
+    $self->{options}{skip_debianization} //= 0;
+    $self->{options}{ignore_bad_version} //= 0;
+    $self->{options}{abort_on_upstream_changes} //= 0;
 
     # V1.0 only supports gzip compression.
     $self->{options}{compression} //= 'gzip';

+ 5 - 5
scripts/Dpkg/Source/Patch.pm

@@ -551,9 +551,9 @@ sub apply {
     $opts{force_timestamp} //= 1;
     $opts{remove_backup} //= 1;
     $opts{create_dirs} //= 1;
-    $opts{options} ||= [ '-t', '-F', '0', '-N', '-p1', '-u',
+    $opts{options} //= [ '-t', '-F', '0', '-N', '-p1', '-u',
             '-V', 'never', '-g0', '-b', '-z', '.dpkg-orig'];
-    $opts{add_options} ||= [];
+    $opts{add_options} //= [];
     push @{$opts{options}}, @{$opts{add_options}};
     # Check the diff and create missing directories
     my $analysis = $self->analyze($destdir, %opts);
@@ -583,7 +583,7 @@ sub apply {
     # and remove .dpkg-orig files
     my @files = keys %{$analysis->{filepatched}};
     my $now = $opts{timestamp};
-    $now ||= fs_time($files[0]) if $opts{force_timestamp} && scalar @files;
+    $now //= fs_time($files[0]) if $opts{force_timestamp} && scalar @files;
     foreach my $fn (@files) {
 	if ($opts{force_timestamp}) {
 	    utime($now, $now, $fn) or $! == ENOENT
@@ -602,9 +602,9 @@ sub check_apply {
     my ($self, $destdir, %opts) = @_;
     # Set default values to options
     $opts{create_dirs} //= 1;
-    $opts{options} ||= [ '--dry-run', '-s', '-t', '-F', '0', '-N', '-p1', '-u',
+    $opts{options} //= [ '--dry-run', '-s', '-t', '-F', '0', '-N', '-p1', '-u',
             '-V', 'never', '-g0', '-b', '-z', '.dpkg-orig'];
-    $opts{add_options} ||= [];
+    $opts{add_options} //= [];
     push @{$opts{options}}, @{$opts{add_options}};
     # Check the diff and create missing directories
     my $analysis = $self->analyze($destdir, %opts);

+ 1 - 1
scripts/Dpkg/Substvars.pm

@@ -223,7 +223,7 @@ sub set_version_substvars {
     my ($self, $sourceversion, $binaryversion) = @_;
 
     # Handle old function signature taking only one argument.
-    $binaryversion ||= $sourceversion;
+    $binaryversion //= $sourceversion;
 
     # For backwards compatibility on binNMUs that do not use the Binary-Only
     # field on the changelog, always fix up the source version.

+ 2 - 2
scripts/changelog/debian.pl

@@ -119,8 +119,8 @@ if (@ARGV) {
     $file = $ARGV[0];
 }
 
-$file ||= $default_file;
-$label ||= $file;
+$file //= $default_file;
+$label //= $file;
 unless (defined($since) or defined($until) or defined($from) or
         defined($to) or defined($offset) or defined($count) or
         defined($all))

+ 1 - 1
scripts/dpkg-buildpackage.pl

@@ -362,7 +362,7 @@ if (defined $parallel) {
         chomp $parallel;
     }
     $parallel = $build_opts->get('parallel') if $build_opts->has('parallel');
-    $ENV{MAKEFLAGS} ||= '';
+    $ENV{MAKEFLAGS} //= '';
     $ENV{MAKEFLAGS} .= " -j$parallel";
     $build_opts->set('parallel', $parallel);
     $build_opts->export();

+ 1 - 1
scripts/dpkg-genchanges.pl

@@ -249,7 +249,7 @@ if (not is_sourceonly) {
 
     foreach my $file ($dist->get_files()) {
         if (defined $file->{package} && $file->{package_type} =~ m/^u?deb$/) {
-            $p2f{$file->{package}} ||= [];
+            $p2f{$file->{package}} //= [];
             push @{$p2f{$file->{package}}}, $file->{filename};
         }