Browse Source

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.
Guillem Jover 7 years ago
parent
commit
cd64cd76c9
5 changed files with 36 additions and 34 deletions
  1. 2 0
      debian/changelog
  2. 19 19
      scripts/Dpkg/Arch.pm
  3. 8 8
      scripts/Dpkg/Compression/FileHandle.pm
  4. 4 4
      scripts/Dpkg/Exit.pm
  5. 3 3
      scripts/Dpkg/Version.pm

+ 2 - 0
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@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.

+ 19 - 19
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 {

+ 8 - 8
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});

+ 4 - 4
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
 

+ 3 - 3
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);