diff options
author | Guillem Jover <guillem@debian.org> | 2014-07-28 05:26:05 +0200 |
---|---|---|
committer | Guillem Jover <guillem@debian.org> | 2014-08-09 23:04:37 +0200 |
commit | 53ab15cf80df8727026cee31cb8dc7899f2488e8 (patch) | |
tree | 6b119947af0b625579be52567f1894bedc7c71a6 | |
parent | b0337f001bee1f3791cb87505b1330c9bf83e2be (diff) | |
download | dpkg-53ab15cf80df8727026cee31cb8dc7899f2488e8.tar.gz |
scripts: Use // instead of || where 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.
-rw-r--r-- | scripts/Dpkg/Arch.pm | 2 | ||||
-rw-r--r-- | scripts/Dpkg/Changelog.pm | 22 | ||||
-rw-r--r-- | scripts/Dpkg/Changelog/Entry.pm | 2 | ||||
-rw-r--r-- | scripts/Dpkg/Compression/FileHandle.pm | 2 | ||||
-rw-r--r-- | scripts/Dpkg/Deps.pm | 4 | ||||
-rw-r--r-- | scripts/Dpkg/Package.pm | 2 | ||||
-rw-r--r-- | scripts/Dpkg/Shlibs/Objdump.pm | 2 | ||||
-rw-r--r-- | scripts/Dpkg/Shlibs/Symbol.pm | 4 | ||||
-rw-r--r-- | scripts/Dpkg/Source/Patch.pm | 4 | ||||
-rw-r--r-- | scripts/Dpkg/Vendor/Ubuntu.pm | 2 | ||||
-rwxr-xr-x | scripts/dpkg-checkbuilddeps.pl | 2 | ||||
-rwxr-xr-x | scripts/dpkg-genchanges.pl | 2 |
12 files changed, 25 insertions, 25 deletions
diff --git a/scripts/Dpkg/Arch.pm b/scripts/Dpkg/Arch.pm index 33a669d83..dfab39f41 100644 --- a/scripts/Dpkg/Arch.pm +++ b/scripts/Dpkg/Arch.pm @@ -389,7 +389,7 @@ sub debarch_to_cpuattrs($) if (defined($cpu)) { abitable_load(); - return ($abibits{$abi} || $cpubits{$cpu}, $cpuendian{$cpu}); + return ($abibits{$abi} // $cpubits{$cpu}, $cpuendian{$cpu}); } else { return; } diff --git a/scripts/Dpkg/Changelog.pm b/scripts/Dpkg/Changelog.pm index 609cad343..233f8cccb 100644 --- a/scripts/Dpkg/Changelog.pm +++ b/scripts/Dpkg/Changelog.pm @@ -362,7 +362,7 @@ sub _data_range { my ($start, $end); if (defined($range->{count})) { - my $offset = $range->{offset} || 0; + my $offset = $range->{offset} // 0; my $count = $range->{count}; # Convert count/offset in start/end if ($offset > 0) { @@ -416,8 +416,8 @@ sub abort_early { my $data = $self->{data} or return; my $r = $self->{range} or return; - my $count = $r->{count} || 0; - my $offset = $r->{offset} || 0; + my $count = $r->{count} // 0; + my $offset = $r->{offset} // 0; return if $self->_is_full_range($r); return if $offset < 0 or $count < 0; @@ -537,8 +537,8 @@ sub dpkg { $f->{Source} = $src->get_source() || 'unknown'; $f->{Version} = $src->get_version() // 'unknown'; $f->{Distribution} = join(' ', $src->get_distributions()); - $f->{Maintainer} = $src->get_maintainer() || ''; - $f->{Date} = $src->get_timestamp() || ''; + $f->{Maintainer} = $src->get_maintainer() // ''; + $f->{Date} = $src->get_timestamp() // ''; $f->{Changes} = $src->get_dpkg_changes(); # handle optional fields @@ -554,10 +554,10 @@ sub dpkg { } foreach my $bin (@data) { - my $oldurg = $f->{Urgency} || ''; - my $oldurgn = $URGENCIES{$f->{Urgency}} || -1; - my $newurg = $bin->get_urgency() || ''; - my $newurgn = $URGENCIES{$newurg} || -1; + my $oldurg = $f->{Urgency} // ''; + my $oldurgn = $URGENCIES{$f->{Urgency}} // -1; + my $newurg = $bin->get_urgency() // ''; + my $newurgn = $URGENCIES{$newurg} // -1; $f->{Urgency} = ($newurgn > $oldurgn) ? $newurg : $oldurg; $f->{Changes} .= "\n" . $bin->get_dpkg_changes(); @@ -602,8 +602,8 @@ sub rfc822 { $f->{Source} = $entry->get_source() || 'unknown'; $f->{Version} = $entry->get_version() // 'unknown'; $f->{Distribution} = join(' ', $entry->get_distributions()); - $f->{Maintainer} = $entry->get_maintainer() || ''; - $f->{Date} = $entry->get_timestamp() || ''; + $f->{Maintainer} = $entry->get_maintainer() // ''; + $f->{Date} = $entry->get_timestamp() // ''; $f->{Changes} = $entry->get_dpkg_changes(); # handle optional fields diff --git a/scripts/Dpkg/Changelog/Entry.pm b/scripts/Dpkg/Changelog/Entry.pm index 3277ab656..6a25da778 100644 --- a/scripts/Dpkg/Changelog/Entry.pm +++ b/scripts/Dpkg/Changelog/Entry.pm @@ -290,7 +290,7 @@ in the output format of C<dpkg-parsechangelog>. sub get_dpkg_changes { my ($self) = @_; - my $header = $self->get_part('header') || ''; + my $header = $self->get_part('header') // ''; $header =~ s/\s+$//; return "\n$header\n\n" . join("\n", @{$self->get_part('changes')}); } diff --git a/scripts/Dpkg/Compression/FileHandle.pm b/scripts/Dpkg/Compression/FileHandle.pm index 391728c26..87393932d 100644 --- a/scripts/Dpkg/Compression/FileHandle.pm +++ b/scripts/Dpkg/Compression/FileHandle.pm @@ -419,7 +419,7 @@ sub open_for_read { sub cleanup { my ($self) = @_; - my $cmdline = *$self->{compressor}{cmdline} || ''; + my $cmdline = *$self->{compressor}{cmdline} // ''; *$self->{compressor}->wait_end_process(nocheck => *$self->{allow_sigpipe}); if (*$self->{allow_sigpipe}) { unless (($? == 0) || (WIFSIGNALED($?) && (WTERMSIG($?) == SIGPIPE))) { diff --git a/scripts/Dpkg/Deps.pm b/scripts/Dpkg/Deps.pm index 30ccff523..fe25defb6 100644 --- a/scripts/Dpkg/Deps.pm +++ b/scripts/Dpkg/Deps.pm @@ -523,7 +523,7 @@ sub new { $self->reset(); $self->{host_arch} = $opts{host_arch} || Dpkg::Arch::get_host_arch(); $self->{build_arch} = $opts{build_arch} || Dpkg::Arch::get_build_arch(); - $self->{build_dep} = $opts{build_dep} || 0; + $self->{build_dep} = $opts{build_dep} // 0; $self->parse_string($arg) if defined($arg); return $self; } @@ -1348,7 +1348,7 @@ sub add_installed_package { package => $pkg, version => $ver, architecture => $arch, - multiarch => $multiarch || 'no', + multiarch => $multiarch // 'no', }; $self->{pkg}{"$pkg:$arch"} = $p if defined $arch; push @{$self->{pkg}{$pkg}}, $p; diff --git a/scripts/Dpkg/Package.pm b/scripts/Dpkg/Package.pm index cf5771ee3..8fa0c1027 100644 --- a/scripts/Dpkg/Package.pm +++ b/scripts/Dpkg/Package.pm @@ -27,7 +27,7 @@ use Exporter qw(import); our @EXPORT = qw(pkg_name_is_illegal); sub pkg_name_is_illegal($) { - my $name = shift || ''; + my $name = shift // ''; if ($name eq '') { return _g('may not be empty string'); diff --git a/scripts/Dpkg/Shlibs/Objdump.pm b/scripts/Dpkg/Shlibs/Objdump.pm index cb0cc46ee..72fa7025a 100644 --- a/scripts/Dpkg/Shlibs/Objdump.pm +++ b/scripts/Dpkg/Shlibs/Objdump.pm @@ -138,7 +138,7 @@ use Dpkg::ErrorHandling; sub new { my $this = shift; - my $file = shift || ''; + my $file = shift // ''; my $class = ref($this) || $this; my $self = {}; bless $self, $class; diff --git a/scripts/Dpkg/Shlibs/Symbol.pm b/scripts/Dpkg/Shlibs/Symbol.pm index 98e6cdebe..b959cc9ea 100644 --- a/scripts/Dpkg/Shlibs/Symbol.pm +++ b/scripts/Dpkg/Shlibs/Symbol.pm @@ -328,7 +328,7 @@ sub is_pattern { # Get pattern type if this symbol is a pattern. sub get_pattern_type { - return $_[0]->{pattern}{type} || ''; + return $_[0]->{pattern}{type} // ''; } # Get (sub)type of the alias pattern. Returns empty string if current @@ -410,7 +410,7 @@ sub get_symbolspec { if ($template_mode) { if ($self->has_tags()) { $spec .= sprintf('%s%3$s%s%3$s', $self->get_tagspec(), - $self->get_symboltempl(), $self->{symbol_quoted} || ''); + $self->get_symboltempl(), $self->{symbol_quoted} // ''); } else { $spec .= $self->get_symboltempl(); } diff --git a/scripts/Dpkg/Source/Patch.pm b/scripts/Dpkg/Source/Patch.pm index ab4fb79de..d780a0672 100644 --- a/scripts/Dpkg/Source/Patch.pm +++ b/scripts/Dpkg/Source/Patch.pm @@ -65,7 +65,7 @@ sub set_header { sub add_diff_file { my ($self, $old, $new, %opts) = @_; $opts{include_timestamp} //= 0; - my $handle_binary = $opts{handle_binary_func} || sub { + my $handle_binary = $opts{handle_binary_func} // sub { my ($self, $old, $new, %opts) = @_; my $file = $opts{filename}; $self->_fail_with_msg($file, _g('binary file contents changed')); @@ -148,7 +148,7 @@ sub add_diff_directory { # TODO: make this function more configurable # - offer to disable some checks my $basedir = $opts{basedirname} || basename($new); - my $inc_removal = $opts{include_removal} || 0; + my $inc_removal = $opts{include_removal} // 0; my $diff_ignore; if ($opts{diff_ignore_func}) { $diff_ignore = $opts{diff_ignore_func}; diff --git a/scripts/Dpkg/Vendor/Ubuntu.pm b/scripts/Dpkg/Vendor/Ubuntu.pm index 68ac7c0d4..0da91cc1a 100644 --- a/scripts/Dpkg/Vendor/Ubuntu.pm +++ b/scripts/Dpkg/Vendor/Ubuntu.pm @@ -88,7 +88,7 @@ sub run_hook { my $fields = shift @params; # Add Launchpad-Bugs-Fixed field - my $bugs = find_launchpad_closes($fields->{'Changes'} || ''); + my $bugs = find_launchpad_closes($fields->{'Changes'} // ''); if (scalar(@$bugs)) { $fields->{'Launchpad-Bugs-Fixed'} = join(' ', @$bugs); } diff --git a/scripts/dpkg-checkbuilddeps.pl b/scripts/dpkg-checkbuilddeps.pl index fdb6dd0d7..3feba3a50 100755 --- a/scripts/dpkg-checkbuilddeps.pl +++ b/scripts/dpkg-checkbuilddeps.pl @@ -89,7 +89,7 @@ my @options_spec = ( set_build_profiles(split(/,/, $bp_value)) if ($bp_value); my @build_profiles = get_build_profiles(); -my $controlfile = shift || 'debian/control'; +my $controlfile = shift // 'debian/control'; my $control = Dpkg::Control::Info->new($controlfile); my $fields = $control->get_source(); diff --git a/scripts/dpkg-genchanges.pl b/scripts/dpkg-genchanges.pl index 429094c45..df4a8ef64 100755 --- a/scripts/dpkg-genchanges.pl +++ b/scripts/dpkg-genchanges.pl @@ -276,7 +276,7 @@ foreach (keys %{$src_fields}) { # Scan control info of all binary packages foreach my $pkg ($control->get_packages()) { my $p = $pkg->{'Package'}; - my $a = $pkg->{'Architecture'} || ''; + my $a = $pkg->{'Architecture'} // ''; my $d = $pkg->{'Description'} || 'no description available'; $d = $1 if $d =~ /^(.*)\n/; my $pkg_type = $pkg->{'Package-Type'} || |