Procházet zdrojové kódy

Rename Dpkg::Compression::CompressedFile and Dpkg::Compression::Compressor

Dpkg::Compression::CompressedFile -> Dpkg::Compression::FileHandle
Dpkg::Compression::Compressor     -> Dpkg::Compression::Process

The new names are more expressive and avoid repeating "Compress".

Update all scripts and modules to use the new name.
Raphaël Hertzog před 16 roky
rodič
revize
d392c99d95

+ 21 - 21
scripts/Dpkg/Compression/CompressedFile.pm

@@ -13,13 +13,13 @@
 # You should have received a copy of the GNU General Public License
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 
-package Dpkg::Compression::CompressedFile;
+package Dpkg::Compression::FileHandle;
 
 
 use strict;
 use strict;
 use warnings;
 use warnings;
 
 
 use Dpkg::Compression;
 use Dpkg::Compression;
-use Dpkg::Compression::Compressor;
+use Dpkg::Compression::Process;
 use Dpkg::Gettext;
 use Dpkg::Gettext;
 use Dpkg::ErrorHandling;
 use Dpkg::ErrorHandling;
 use POSIX qw(WIFSIGNALED WTERMSIG SIGPIPE);
 use POSIX qw(WIFSIGNALED WTERMSIG SIGPIPE);
@@ -32,43 +32,43 @@ use base qw(FileHandle Tie::Handle);
 
 
 =head1 NAME
 =head1 NAME
 
 
-Dpkg::Compression::CompressedFile - object dealing transparently with file compression
+Dpkg::Compression::FileHandle - object dealing transparently with file compression
 
 
 =head1 SYNOPSIS
 =head1 SYNOPSIS
 
 
-    use Dpkg::Compression::CompressedFile;
+    use Dpkg::Compression::FileHandle;
 
 
-    $fh = Dpkg::Compression::CompressedFile->new(filename=>"sample.gz");
+    $fh = Dpkg::Compression::FileHandle->new(filename=>"sample.gz");
     print $fh "Something\n";
     print $fh "Something\n";
     close $fh;
     close $fh;
 
 
-    $fh = Dpkg::Compression::CompressedFile->new();
+    $fh = Dpkg::Compression::FileHandle->new();
     open($fh, ">", "sample.bz2");
     open($fh, ">", "sample.bz2");
     print $fh "Something\n";
     print $fh "Something\n";
     close $fh;
     close $fh;
 
 
-    $fh = Dpkg::Compression::CompressedFile->new();
+    $fh = Dpkg::Compression::FileHandle->new();
     $fh->open("sample.xz", "w");
     $fh->open("sample.xz", "w");
     $fh->print("Something\n");
     $fh->print("Something\n");
     $fh->close();
     $fh->close();
 
 
-    $fh = Dpkg::Compression::CompressedFile->new(filename=>"sample.gz");
+    $fh = Dpkg::Compression::FileHandle->new(filename=>"sample.gz");
     my @lines = <$fh>;
     my @lines = <$fh>;
     close $fh;
     close $fh;
 
 
-    $fh = Dpkg::Compression::CompressedFile->new();
+    $fh = Dpkg::Compression::FileHandle->new();
     open($fh, "<", "sample.bz2");
     open($fh, "<", "sample.bz2");
     my @lines = <$fh>;
     my @lines = <$fh>;
     close $fh;
     close $fh;
 
 
-    $fh = Dpkg::Compression::CompressedFile->new();
+    $fh = Dpkg::Compression::FileHandle->new();
     $fh->open("sample.xz", "r");
     $fh->open("sample.xz", "r");
     my @lines = $fh->getlines();
     my @lines = $fh->getlines();
     $fh->close();
     $fh->close();
 
 
 =head1 DESCRIPTION
 =head1 DESCRIPTION
 
 
-Dpkg::Compression::CompressedFile is an object that can be used
+Dpkg::Compression::FileHandle is an object that can be used
 like any filehandle and that deals transparently with compressed
 like any filehandle and that deals transparently with compressed
 files. By default, the compression scheme is guessed from the filename
 files. By default, the compression scheme is guessed from the filename
 but you can override this behaviour with the method C<set_compression>.
 but you can override this behaviour with the method C<set_compression>.
@@ -83,7 +83,7 @@ able to open another file.
 =head1 STANDARD FUNCTIONS
 =head1 STANDARD FUNCTIONS
 
 
 The standard functions acting on filehandles should accept a
 The standard functions acting on filehandles should accept a
-Dpkg::Compression::CompressedFile object transparently including
+Dpkg::Compression::FileHandle object transparently including
 C<open> (only when using the variant with 3 parameters), C<close>,
 C<open> (only when using the variant with 3 parameters), C<close>,
 C<binmode>, C<eof>, C<fileno>, C<getc>, C<print>, C<printf>, C<read>,
 C<binmode>, C<eof>, C<fileno>, C<getc>, C<print>, C<printf>, C<read>,
 C<sysread>, C<say>, C<write>, C<syswrite>, C<seek>, C<sysseek>, C<tell>.
 C<sysread>, C<say>, C<write>, C<syswrite>, C<seek>, C<sysseek>, C<tell>.
@@ -95,14 +95,14 @@ and you can't seek on a pipe.
 =head1 FileHandle METHODS
 =head1 FileHandle METHODS
 
 
 The object inherits from FileHandle so all methods that work on this
 The object inherits from FileHandle so all methods that work on this
-object should work for Dpkg::Compression::CompressedFile too. There
+object should work for Dpkg::Compression::FileHandle too. There
 may be exceptions though.
 may be exceptions though.
 
 
 =head1 PUBLIC METHODS
 =head1 PUBLIC METHODS
 
 
 =over 4
 =over 4
 
 
-=item my $fh = Dpkg::Compression::CompressedFile->new(%opts)
+=item my $fh = Dpkg::Compression::FileHandle->new(%opts)
 
 
 Creates a new filehandle supporting on-the-fly compression/decompression.
 Creates a new filehandle supporting on-the-fly compression/decompression.
 Supported options are "filename", "compression", "compression_level" (see
 Supported options are "filename", "compression", "compression_level" (see
@@ -124,7 +124,7 @@ sub new {
     bless $self, $class;
     bless $self, $class;
     # Initializations
     # Initializations
     *$self->{"compression"} = "auto";
     *$self->{"compression"} = "auto";
-    *$self->{"compressor"} = Dpkg::Compression::Compressor->new();
+    *$self->{"compressor"} = Dpkg::Compression::Process->new();
     *$self->{"add_comp_ext"} = $args{"add_compression_extension"} ||
     *$self->{"add_comp_ext"} = $args{"add_compression_extension"} ||
 	    $args{"add_comp_ext"} || 0;
 	    $args{"add_comp_ext"} || 0;
     *$self->{"allow_sigpipe"} = 0;
     *$self->{"allow_sigpipe"} = 0;
@@ -201,10 +201,10 @@ sub OPEN {
 	} elsif ($mode eq "<") {
 	} elsif ($mode eq "<") {
 	    $self->open_for_read();
 	    $self->open_for_read();
 	} else {
 	} else {
-	    internerr("Unsupported open mode on Dpkg::Compression::CompressedFile: $mode");
+	    internerr("Unsupported open mode on Dpkg::Compression::FileHandle: $mode");
 	}
 	}
     } else {
     } else {
-	internerr("Dpkg::Compression::CompressedFile only supports open() with 3 parameters");
+	internerr("Dpkg::Compression::FileHandle only supports open() with 3 parameters");
     }
     }
     return 1; # Always works (otherwise errors out)
     return 1; # Always works (otherwise errors out)
 }
 }
@@ -249,7 +249,7 @@ sub BINMODE {
 =item $fh->set_compression($comp)
 =item $fh->set_compression($comp)
 
 
 Defines the compression method used. $comp should one of the methods supported by
 Defines the compression method used. $comp should one of the methods supported by
-Dpkg::Compression or "none" or "auto". "none" indicates that the file is
+B<Dpkg::Compression> or "none" or "auto". "none" indicates that the file is
 uncompressed and "auto" indicates that the method must be guessed based
 uncompressed and "auto" indicates that the method must be guessed based
 on the filename extension used.
 on the filename extension used.
 
 
@@ -265,8 +265,8 @@ sub set_compression {
 
 
 =item $fh->set_compression_level($level)
 =item $fh->set_compression_level($level)
 
 
-Indicate the desired compression level. It should a value supported by
-the B<set_compression_level> method of B<Dpkg::Compression::Compressor>.
+Indicate the desired compression level. It should be a value accepted
+by the function C<compression_is_valid_level> of B<Dpkg::Compression>.
 
 
 =cut
 =cut
 
 
@@ -410,7 +410,7 @@ sub cleanup {
 =head1 DERIVED OBJECTS
 =head1 DERIVED OBJECTS
 
 
 If you want to create an object that inherits from
 If you want to create an object that inherits from
-Dpkg::Compression::CompressedFile you must be aware that
+Dpkg::Compression::FileHandle you must be aware that
 the object is a reference to a GLOB that is returned by Symbol::gensym()
 the object is a reference to a GLOB that is returned by Symbol::gensym()
 and as such it's not a HASH.
 and as such it's not a HASH.
 
 

+ 3 - 3
scripts/Dpkg/Compression/Compressor.pm

@@ -1,4 +1,4 @@
-# Copyright © 2008 Raphaël Hertzog <hertzog@debian.org>
+# Copyright © 2008-2010 Raphaël Hertzog <hertzog@debian.org>
 #
 #
 # This program is free software; you can redistribute it and/or modify
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
 # it under the terms of the GNU General Public License as published by
@@ -13,7 +13,7 @@
 # You should have received a copy of the GNU General Public License
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 
-package Dpkg::Compression::Compressor;
+package Dpkg::Compression::Process;
 
 
 use strict;
 use strict;
 use warnings;
 use warnings;
@@ -69,7 +69,7 @@ sub get_uncompress_cmdline {
 sub _sanity_check {
 sub _sanity_check {
     my ($self, %opts) = @_;
     my ($self, %opts) = @_;
     # Check for proper cleaning before new start
     # Check for proper cleaning before new start
-    error(_g("Dpkg::Compression::Compressor can only start one subprocess at a time"))
+    error(_g("Dpkg::Compression::Process can only start one subprocess at a time"))
 	    if $self->{"pid"};
 	    if $self->{"pid"};
     # Check options
     # Check options
     my $to = my $from = 0;
     my $to = my $from = 0;

+ 3 - 3
scripts/Dpkg/Index.pm

@@ -21,7 +21,7 @@ use warnings;
 use Dpkg::Gettext;
 use Dpkg::Gettext;
 use Dpkg::ErrorHandling;
 use Dpkg::ErrorHandling;
 use Dpkg::Control;
 use Dpkg::Control;
-use Dpkg::Compression::CompressedFile;
+use Dpkg::Compression::FileHandle;
 
 
 use overload
 use overload
     '@{}' => sub { return $_[0]->{'order'} },
     '@{}' => sub { return $_[0]->{'order'} },
@@ -155,7 +155,7 @@ parsed. Handles compressed files transparently based on their extensions.
 
 
 sub load {
 sub load {
     my ($self, $file) = @_;
     my ($self, $file) = @_;
-    my $cf = Dpkg::Compression::CompressedFile->new(filename => $file);
+    my $cf = Dpkg::Compression::FileHandle->new(filename => $file);
     my $res = $self->parse($cf, $file);
     my $res = $self->parse($cf, $file);
     close($cf) || syserr(_g("cannot close %s"), $file);
     close($cf) || syserr(_g("cannot close %s"), $file);
     return $res;
     return $res;
@@ -189,7 +189,7 @@ based on their extensions.
 
 
 sub save {
 sub save {
     my ($self, $file) = @_;
     my ($self, $file) = @_;
-    my $cf = Dpkg::Compression::CompressedFile->new(filename => $file);
+    my $cf = Dpkg::Compression::FileHandle->new(filename => $file);
     $self->output($cf);
     $self->output($cf);
     close($cf) || syserr(_g("cannot close %s"), $file);
     close($cf) || syserr(_g("cannot close %s"), $file);
 }
 }

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

@@ -29,7 +29,7 @@ use File::Basename qw(basename);
 use File::Spec;
 use File::Spec;
 use Cwd;
 use Cwd;
 
 
-use base 'Dpkg::Compression::CompressedFile';
+use base 'Dpkg::Compression::FileHandle';
 
 
 sub create {
 sub create {
     my ($self, %opts) = @_;
     my ($self, %opts) = @_;

+ 1 - 3
scripts/Dpkg/Source/Patch.pm

@@ -19,8 +19,6 @@ use strict;
 use warnings;
 use warnings;
 
 
 use Dpkg;
 use Dpkg;
-use Dpkg::Compression::Compressor;
-use Dpkg::Compression;
 use Dpkg::Gettext;
 use Dpkg::Gettext;
 use Dpkg::IPC;
 use Dpkg::IPC;
 use Dpkg::ErrorHandling;
 use Dpkg::ErrorHandling;
@@ -35,7 +33,7 @@ use Fcntl ':mode';
 #XXX: Needed for sub-second timestamps, require recent perl
 #XXX: Needed for sub-second timestamps, require recent perl
 #use Time::HiRes qw(stat);
 #use Time::HiRes qw(stat);
 
 
-use base 'Dpkg::Compression::CompressedFile';
+use base 'Dpkg::Compression::FileHandle';
 
 
 sub create {
 sub create {
     my ($self, %opts) = @_;
     my ($self, %opts) = @_;

+ 2 - 2
scripts/Makefile.am

@@ -61,8 +61,8 @@ nobase_dist_perllib_DATA = \
 	Dpkg/Changelog/Parse.pm \
 	Dpkg/Changelog/Parse.pm \
 	Dpkg/Checksums.pm \
 	Dpkg/Checksums.pm \
 	Dpkg/Compression.pm \
 	Dpkg/Compression.pm \
-	Dpkg/Compression/CompressedFile.pm \
-	Dpkg/Compression/Compressor.pm \
+	Dpkg/Compression/FileHandle.pm \
+	Dpkg/Compression/Process.pm \
 	Dpkg/Conf.pm \
 	Dpkg/Conf.pm \
 	Dpkg/Control.pm \
 	Dpkg/Control.pm \
 	Dpkg/Control/Changelog.pm \
 	Dpkg/Control/Changelog.pm \

+ 3 - 3
scripts/dpkg-scanpackages.pl

@@ -28,7 +28,7 @@ use Dpkg::ErrorHandling;
 use Dpkg::Control;
 use Dpkg::Control;
 use Dpkg::Version;
 use Dpkg::Version;
 use Dpkg::Checksums;
 use Dpkg::Checksums;
-use Dpkg::Compression::CompressedFile;
+use Dpkg::Compression::FileHandle;
 use Dpkg::IPC;
 use Dpkg::IPC;
 
 
 textdomain("dpkg-dev");
 textdomain("dpkg-dev");
@@ -87,7 +87,7 @@ sub set_type_udeb()
 sub load_override
 sub load_override
 {
 {
     my $override = shift;
     my $override = shift;
-    my $comp_file = Dpkg::Compression::CompressedFile->new(filename => $override);
+    my $comp_file = Dpkg::Compression::FileHandle->new(filename => $override);
 
 
     while (<$comp_file>) {
     while (<$comp_file>) {
 	s/\#.*//;
 	s/\#.*//;
@@ -133,7 +133,7 @@ sub load_override
 sub load_override_extra
 sub load_override_extra
 {
 {
     my $extra_override = shift;
     my $extra_override = shift;
-    my $comp_file = Dpkg::Compression::CompressedFile->new(filename => $extra_override);
+    my $comp_file = Dpkg::Compression::FileHandle->new(filename => $extra_override);
 
 
     while (<$comp_file>) {
     while (<$comp_file>) {
 	s/\#.*//;
 	s/\#.*//;

+ 4 - 4
scripts/dpkg-scansources.pl

@@ -27,7 +27,7 @@ use Dpkg::Gettext;
 use Dpkg::ErrorHandling;
 use Dpkg::ErrorHandling;
 use Dpkg::Control;
 use Dpkg::Control;
 use Dpkg::Checksums;
 use Dpkg::Checksums;
-use Dpkg::Compression::CompressedFile;
+use Dpkg::Compression::FileHandle;
 use Dpkg::Compression;
 use Dpkg::Compression;
 
 
 textdomain("dpkg-dev");
 textdomain("dpkg-dev");
@@ -110,7 +110,7 @@ sub load_override {
     my $file = shift;
     my $file = shift;
     local $_;
     local $_;
 
 
-    my $comp_file = Dpkg::Compression::CompressedFile->new(filename => $file);
+    my $comp_file = Dpkg::Compression::FileHandle->new(filename => $file);
     while (<$comp_file>) {
     while (<$comp_file>) {
     	s/#.*//;
     	s/#.*//;
 	next if /^\s*$/;
 	next if /^\s*$/;
@@ -175,7 +175,7 @@ sub load_src_override {
     }
     }
 
 
     debug "source override file $file";
     debug "source override file $file";
-    my $comp_file = Dpkg::Compression::CompressedFile->new(filename => $file);
+    my $comp_file = Dpkg::Compression::FileHandle->new(filename => $file);
     while (<$comp_file>) {
     while (<$comp_file>) {
     	s/#.*//;
     	s/#.*//;
 	next if /^\s*$/;
 	next if /^\s*$/;
@@ -204,7 +204,7 @@ sub load_src_override {
 sub load_override_extra
 sub load_override_extra
 {
 {
     my $extra_override = shift;
     my $extra_override = shift;
-    my $comp_file = Dpkg::Compression::CompressedFile->new(filename => $extra_override);
+    my $comp_file = Dpkg::Compression::FileHandle->new(filename => $extra_override);
 
 
     while (<$comp_file>) {
     while (<$comp_file>) {
 	s/\#.*//;
 	s/\#.*//;

+ 2 - 2
scripts/po/POTFILES.in

@@ -16,8 +16,8 @@ scripts/dpkg-source.pl
 scripts/changelog/debian.pl
 scripts/changelog/debian.pl
 scripts/Dpkg/Arch.pm
 scripts/Dpkg/Arch.pm
 scripts/Dpkg/Compression.pm
 scripts/Dpkg/Compression.pm
-scripts/Dpkg/Compression/CompressedFile.pm
-scripts/Dpkg/Compression/Compressor.pm
+scripts/Dpkg/Compression/FileHandle.pm
+scripts/Dpkg/Compression/Process.pm
 scripts/Dpkg/Changelog.pm
 scripts/Dpkg/Changelog.pm
 scripts/Dpkg/Changelog/Debian.pm
 scripts/Dpkg/Changelog/Debian.pm
 scripts/Dpkg/Changelog/Entry.pm
 scripts/Dpkg/Changelog/Entry.pm

+ 5 - 5
scripts/t/850_Dpkg_Compression.t

@@ -18,7 +18,7 @@ use Test::More tests => 9;
 use strict;
 use strict;
 use warnings;
 use warnings;
 
 
-use_ok('Dpkg::Compression::CompressedFile');
+use_ok('Dpkg::Compression::FileHandle');
 
 
 my $tmpdir = "t.tmp/850_Dpkg_Compression";
 my $tmpdir = "t.tmp/850_Dpkg_Compression";
 mkdir $tmpdir;
 mkdir $tmpdir;
@@ -28,7 +28,7 @@ my $fh;
 sub test_write {
 sub test_write {
     my ($filename, $check_result) = @_;
     my ($filename, $check_result) = @_;
 
 
-    $fh = Dpkg::Compression::CompressedFile->new();
+    $fh = Dpkg::Compression::FileHandle->new();
     open $fh, ">", $filename or die "open failed";
     open $fh, ">", $filename or die "open failed";
     print $fh $lines[0];
     print $fh $lines[0];
     syswrite($fh, $lines[1]);
     syswrite($fh, $lines[1]);
@@ -39,7 +39,7 @@ sub test_write {
 
 
     unlink $filename or die "cannot unlink $filename";
     unlink $filename or die "cannot unlink $filename";
 
 
-    $fh = Dpkg::Compression::CompressedFile->new();
+    $fh = Dpkg::Compression::FileHandle->new();
     $fh->open($filename, "w");
     $fh->open($filename, "w");
     $fh->print($lines[0]);
     $fh->print($lines[0]);
     $fh->write($lines[1], length($lines[1]));
     $fh->write($lines[1], length($lines[1]));
@@ -68,7 +68,7 @@ sub check_compressed {
 sub test_read {
 sub test_read {
     my ($filename) = @_;
     my ($filename) = @_;
 
 
-    $fh = Dpkg::Compression::CompressedFile->new();
+    $fh = Dpkg::Compression::FileHandle->new();
     open($fh, "<", $filename) or die "open failed";
     open($fh, "<", $filename) or die "open failed";
     my @read = <$fh>;
     my @read = <$fh>;
     close $fh or die "close failed";
     close $fh or die "close failed";
@@ -76,7 +76,7 @@ sub test_read {
     is_deeply(\@lines, \@read, "$filename correctly read (std functions)");
     is_deeply(\@lines, \@read, "$filename correctly read (std functions)");
 
 
     @read = ();
     @read = ();
-    $fh = Dpkg::Compression::CompressedFile->new();
+    $fh = Dpkg::Compression::FileHandle->new();
     $fh->open($filename, "r") or die "open failed";
     $fh->open($filename, "r") or die "open failed";
     @read = $fh->getlines();
     @read = $fh->getlines();
     $fh->close() or die "close failed";
     $fh->close() or die "close failed";