[Reproducible-commits] [dpkg] 23/33: Dpkg: Rename various private methods and functions

Mattia Rizzolo mattia at debian.org
Mon Aug 1 10:26:00 UTC 2016


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

mattia pushed a commit to branch master
in repository dpkg.

commit cd64cd76c924070a2c1f57bac817216e705b6b52
Author: Guillem Jover <guillem at debian.org>
Date:   Fri Jul 29 21:32:34 2016 +0200

    Dpkg: Rename various private methods and functions
    
    Rename private functions names, so that they have an underscore and
    more uniform names. This way it is made explicit that those functions
    are not expected to be used by external modules, and provide no
    guarantees on their API stability.
---
 debian/changelog                       |  2 ++
 scripts/Dpkg/Arch.pm                   | 38 +++++++++++++++++-----------------
 scripts/Dpkg/Compression/FileHandle.pm | 16 +++++++-------
 scripts/Dpkg/Exit.pm                   |  8 +++----
 scripts/Dpkg/Version.pm                |  6 +++---
 5 files changed, 36 insertions(+), 34 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index c5fafdd..d616e45 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -14,6 +14,8 @@ dpkg (1.18.10) UNRELEASED; urgency=medium
       in source packages has an mtime later than the changelog entry time.
     - Enable fixdebugpath build flag feature by default.
       Thanks to Mattia Rizzolo <mattia at debian.org>. Closes: #832179
+    - Rename various private methods and functions with an underscore prefix
+      and unified names.
   * Documentation:
     - Document Testsuite-Triggers in dsc(5).
     - Fix deb-changes(5) description to talk about .changes instead of .dsc.
diff --git a/scripts/Dpkg/Arch.pm b/scripts/Dpkg/Arch.pm
index 969d2e8..972b217 100644
--- a/scripts/Dpkg/Arch.pm
+++ b/scripts/Dpkg/Arch.pm
@@ -204,8 +204,8 @@ Get an array with all currently known Debian architectures.
 
 sub get_valid_arches()
 {
-    read_cputable();
-    read_ostable();
+    _load_cputable();
+    _load_ostable();
 
     my @arches;
 
@@ -220,7 +220,7 @@ sub get_valid_arches()
 }
 
 my %table_loaded;
-sub load_table
+sub _load_table
 {
     my ($table, $loader) = @_;
 
@@ -239,9 +239,9 @@ sub load_table
     $table_loaded{$table} = 1;
 }
 
-sub read_cputable
+sub _load_cputable
 {
-    load_table('cputable', sub {
+    _load_table('cputable', sub {
 	if (m/^(?!\#)(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)/) {
 	    $cputable{$1} = $2;
 	    $cputable_re{$1} = $3;
@@ -252,9 +252,9 @@ sub read_cputable
     });
 }
 
-sub read_ostable
+sub _load_ostable
 {
-    load_table('ostable', sub {
+    _load_table('ostable', sub {
 	if (m/^(?!\#)(\S+)\s+(\S+)\s+(\S+)/) {
 	    $ostable{$1} = $2;
 	    $ostable_re{$1} = $3;
@@ -263,20 +263,20 @@ sub read_ostable
     });
 }
 
-sub abitable_load()
+sub _load_abitable()
 {
-    load_table('abitable', sub {
+    _load_table('abitable', sub {
         if (m/^(?!\#)(\S+)\s+(\S+)/) {
             $abibits{$1} = $2;
         }
     });
 }
 
-sub read_triplettable()
+sub _load_triplettable()
 {
-    read_cputable();
+    _load_cputable();
 
-    load_table('triplettable', sub {
+    _load_table('triplettable', sub {
 	if (m/^(?!\#)(\S+)\s+(\S+)/) {
 	    my $debtriplet = $1;
 	    my $debarch = $2;
@@ -304,8 +304,8 @@ sub debtriplet_to_gnutriplet(@)
 {
     my ($abi, $os, $cpu) = @_;
 
-    read_cputable();
-    read_ostable();
+    _load_cputable();
+    _load_ostable();
 
     return unless defined($abi) && defined($os) && defined($cpu) &&
         exists($cputable{$cpu}) && exists($ostable{"$abi-$os"});
@@ -319,8 +319,8 @@ sub gnutriplet_to_debtriplet($)
     my ($gnu_cpu, $gnu_os) = split(/-/, $gnu, 2);
     return unless defined($gnu_cpu) && defined($gnu_os);
 
-    read_cputable();
-    read_ostable();
+    _load_cputable();
+    _load_ostable();
 
     my ($os, $cpu);
 
@@ -377,7 +377,7 @@ sub debtriplet_to_debarch(@)
 {
     my ($abi, $os, $cpu) = @_;
 
-    read_triplettable();
+    _load_triplettable();
 
     if (!defined($abi) || !defined($os) || !defined($cpu)) {
 	return;
@@ -394,7 +394,7 @@ sub debarch_to_debtriplet($)
 
     return if not defined $arch;
 
-    read_triplettable();
+    _load_triplettable();
 
     if ($arch =~ /^linux-([^-]*)/) {
 	# XXX: Might disappear in the future, not sure yet.
@@ -460,7 +460,7 @@ sub debarch_to_cpuattrs($)
     my ($abi, $os, $cpu) = debarch_to_debtriplet($arch);
 
     if (defined($cpu)) {
-        abitable_load();
+        _load_abitable();
 
         return ($abibits{$abi} // $cpubits{$cpu}, $cpuendian{$cpu});
     } else {
diff --git a/scripts/Dpkg/Compression/FileHandle.pm b/scripts/Dpkg/Compression/FileHandle.pm
index 9d91b77..9ce717c 100644
--- a/scripts/Dpkg/Compression/FileHandle.pm
+++ b/scripts/Dpkg/Compression/FileHandle.pm
@@ -171,9 +171,9 @@ sub ensure_open {
 	delete $opts{to_file};
 
 	if ($mode eq 'w') {
-	    $self->open_for_write(%opts);
+	    $self->_open_for_write(%opts);
 	} elsif ($mode eq 'r') {
-	    $self->open_for_read(%opts);
+	    $self->_open_for_read(%opts);
 	} else {
 	    croak "invalid mode in ensure_open: $mode";
 	}
@@ -213,9 +213,9 @@ sub OPEN {
 	my ($mode, $filename) = @_;
 	$self->set_filename($filename);
 	if ($mode eq '>') {
-	    $self->open_for_write();
+	    $self->_open_for_write();
 	} elsif ($mode eq '<') {
-	    $self->open_for_read();
+	    $self->_open_for_read();
 	} else {
 	    croak 'Dpkg::Compression::FileHandle does not support ' .
 	          "open() mode $mode";
@@ -235,7 +235,7 @@ sub CLOSE {
     } else {
 	$ret = 0;
     }
-    $self->cleanup();
+    $self->_cleanup();
     return $ret;
 }
 
@@ -390,7 +390,7 @@ sub get_filehandle {
 
 ## INTERNAL METHODS
 
-sub open_for_write {
+sub _open_for_write {
     my ($self, %opts) = @_;
     my $filehandle;
 
@@ -408,7 +408,7 @@ sub open_for_write {
     *$self->{file} = $filehandle;
 }
 
-sub open_for_read {
+sub _open_for_read {
     my ($self, %opts) = @_;
     my $filehandle;
 
@@ -427,7 +427,7 @@ sub open_for_read {
     *$self->{file} = $filehandle;
 }
 
-sub cleanup {
+sub _cleanup {
     my $self = shift;
     my $cmdline = *$self->{compressor}{cmdline} // '';
     *$self->{compressor}->wait_end_process(nocheck => *$self->{allow_sigpipe});
diff --git a/scripts/Dpkg/Exit.pm b/scripts/Dpkg/Exit.pm
index 1861de7..b98b949 100644
--- a/scripts/Dpkg/Exit.pm
+++ b/scripts/Dpkg/Exit.pm
@@ -78,14 +78,14 @@ sub run_exit_handlers {
     &$_() foreach (reverse @handlers);
 }
 
-sub exit_handler {
+sub _exit_handler {
     run_exit_handlers();
     exit(127);
 }
 
-$SIG{INT} = \&exit_handler;
-$SIG{HUP} = \&exit_handler;
-$SIG{QUIT} = \&exit_handler;
+$SIG{INT} = \&_exit_handler;
+$SIG{HUP} = \&_exit_handler;
+$SIG{QUIT} = \&_exit_handler;
 
 =back
 
diff --git a/scripts/Dpkg/Version.pm b/scripts/Dpkg/Version.pm
index ec91a3d..f043e0f 100644
--- a/scripts/Dpkg/Version.pm
+++ b/scripts/Dpkg/Version.pm
@@ -52,8 +52,8 @@ use constant {
 };
 
 use overload
-    '<=>' => \&comparison,
-    'cmp' => \&comparison,
+    '<=>' => \&_comparison,
+    'cmp' => \&_comparison,
     '""'  => sub { return $_[0]->as_string(); },
     'bool' => sub { return $_[0]->as_string() if $_[0]->is_valid(); },
     'fallback' => 1;
@@ -175,7 +175,7 @@ its string representation is a version number.
 
 =cut
 
-sub comparison {
+sub _comparison {
     my ($a, $b, $inverted) = @_;
     if (not ref($b) or not $b->isa('Dpkg::Version')) {
         $b = Dpkg::Version->new($b);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/dpkg.git



More information about the Reproducible-commits mailing list