Author: djpig
Date: 2007-07-08 22:12:49 +0000 (Sun, 08 Jul 2007)
New Revision: 857

Modified:
   branches/dpkg-shlibdeps-buxy/scripts/Dpkg/Shlibs/Objdump.pm
   branches/dpkg-shlibdeps-buxy/scripts/Dpkg/Shlibs/SymbolFile.pm
   branches/dpkg-shlibdeps-buxy/scripts/dpkg-shlibdeps.pl
   branches/dpkg-shlibdeps-buxy/scripts/t/200_Dpkg_Shlibs.t
Log:
Dpkg::Shlibs::*: Code cleanup

Use the new Dpkg::* utility modules


Modified: branches/dpkg-shlibdeps-buxy/scripts/Dpkg/Shlibs/Objdump.pm
===================================================================
--- branches/dpkg-shlibdeps-buxy/scripts/Dpkg/Shlibs/Objdump.pm 2007-07-08 
22:11:49 UTC (rev 856)
+++ branches/dpkg-shlibdeps-buxy/scripts/Dpkg/Shlibs/Objdump.pm 2007-07-08 
22:12:49 UTC (rev 857)
@@ -16,7 +16,9 @@
 
 package Dpkg::Shlibs::Objdump;
 
-require 'dpkg-gettext.pl';
+use Dpkg::Gettext;
+use Dpkg::ErrorHandling qw(syserr subprocerr warning);
+textdomain("dpkg-dev");
 
 sub new {
     my $this = shift;
@@ -30,7 +32,7 @@
     my ($self, $file) = @_;
     local $ENV{LC_ALL} = 'C';
     open(OBJDUMP, "-|", "objdump", "-w", "-p", "-T", $file) ||
-           syserr(sprintf(_g("Can't execute objdump: %s"), $!));
+       syserr(sprintf(_g("Can't execute objdump: %s"), $!));
     my $obj = Dpkg::Shlibs::Objdump::Object->new($file);
     my $section = "none";
     while (defined($_ = <OBJDUMP>)) {
@@ -141,7 +143,7 @@
     } elsif ($line =~ /^[0-9a-f]+ (.{7})\s+(\S+)\s+[0-9a-f]+/) {
        # Same start but no version and no symbol ... just ignore
     } else {
-       main::warning(sprintf(_g("Couldn't parse one line of objdump's output: 
%s"), $line));
+       warning(sprintf(_g("Couldn't parse one line of objdump's output: %s"), 
$line));
     }
 }
 
@@ -173,7 +175,8 @@
            return $format{$file};
        } else {
            local $ENV{LC_ALL} = "C";
-           open(P, "objdump -a -- $file |") || syserr(_g("cannot fork for 
objdump"));
+           open(P, "-|", "objdump", "-a", "--", $file)
+               || syserr(_g("cannot fork for objdump"));
            while (<P>) {
                chomp;
                if (/^\s*\S+:\s*file\s+format\s+(\S+)\s*$/) {
@@ -181,14 +184,15 @@
                    return $format{$file};
                }
            }
-           close(P) or main::subprocerr(sprintf(_g("objdump on \`%s'"), 
$file));
+           close(P) or subprocerr(sprintf(_g("objdump on \`%s'"), $file));
        }
     }
 }
 
 sub is_elf {
     my ($file) = @_;
-    open(FILE, "<", $file) || main::syserr(sprintf(_g("Can't open %s for test: 
%s"), $file, $!));
+    open(FILE, "<", $file) ||
+       syserr(sprintf(_g("Can't open %s for test: %s"), $file, $!));
     my ($header, $result) = ("", 0);
     if (read(FILE, $header, 4) == 4) {
        $result = 1 if ($header =~ /^\177ELF$/);

Modified: branches/dpkg-shlibdeps-buxy/scripts/Dpkg/Shlibs/SymbolFile.pm
===================================================================
--- branches/dpkg-shlibdeps-buxy/scripts/Dpkg/Shlibs/SymbolFile.pm      
2007-07-08 22:11:49 UTC (rev 856)
+++ branches/dpkg-shlibdeps-buxy/scripts/Dpkg/Shlibs/SymbolFile.pm      
2007-07-08 22:12:49 UTC (rev 857)
@@ -16,9 +16,10 @@
 
 package Dpkg::Shlibs::SymbolFile;
 
-require 'dpkg-gettext.pl';
-
+use Dpkg::Gettext;
+use Dpkg::ErrorHandling qw(syserr warning);
 use Dpkg::Version qw(vercmp);
+textdomain("dpkg-dev");
 
 sub new {
     my $this = shift;
@@ -50,7 +51,8 @@
 sub load {
     my ($self, $file) = @_;
     $self->{file} = $file;
-    open(SYM_FILE, "<", $file) || main::syserr(sprintf(_g("Can't open %s: 
%s"), $file));
+    open(SYM_FILE, "<", $file)
+       || syserr(sprintf(_g("Can't open %s: %s"), $file));
     my ($object);
     while (defined($_ = <SYM_FILE>)) {
        chomp($_);
@@ -80,7 +82,7 @@
                'deps' => [ "$2" ]
            };
        } else {
-           main::warning(sprintf(_g("Failed to parse a line in %s: %s"), 
$file, $_));
+           warning(sprintf(_g("Failed to parse a line in %s: %s"), $file, $_));
        }
     }
     close(SYM_FILE);
@@ -93,7 +95,8 @@
     if ($file eq "-") {
        $fh = \*STDOUT;
     } else {
-       open(SYM_FILE, "> $file") || main::syserr(sprintf(_g("Can't open %s for 
writing: %s"), $file, $!));
+       open(SYM_FILE, "> $file")
+           || syserr(sprintf(_g("Can't open %s for writing: %s"), $file, $!));
        $fh = \*SYM_FILE;
     }
     $self->dump($fh);

Modified: branches/dpkg-shlibdeps-buxy/scripts/dpkg-shlibdeps.pl
===================================================================
--- branches/dpkg-shlibdeps-buxy/scripts/dpkg-shlibdeps.pl      2007-07-08 
22:11:49 UTC (rev 856)
+++ branches/dpkg-shlibdeps-buxy/scripts/dpkg-shlibdeps.pl      2007-07-08 
22:12:49 UTC (rev 857)
@@ -12,7 +12,7 @@
 
 BEGIN {
     $version="1.14.4"; # This line modified by Makefile
-    $dpkglibdir="/usr/lib/dpkg"; # This line modified by Makefile
+    $dpkglibdir="."; # This line modified by Makefile
     push(@INC,$dpkglibdir);
 }
 

Modified: branches/dpkg-shlibdeps-buxy/scripts/t/200_Dpkg_Shlibs.t
===================================================================
--- branches/dpkg-shlibdeps-buxy/scripts/t/200_Dpkg_Shlibs.t    2007-07-08 
22:11:49 UTC (rev 856)
+++ branches/dpkg-shlibdeps-buxy/scripts/t/200_Dpkg_Shlibs.t    2007-07-08 
22:12:49 UTC (rev 857)
@@ -1,9 +1,9 @@
 # -*- mode: cperl;-*-
 
-use Test::More tests => 2;
+use Test::More tests => 4;
 
+use strict;
 use warnings;
-use strict;
 
 use_ok('Dpkg::Shlibs');
 
@@ -16,3 +16,6 @@
 is_deeply([qw(/nonexistant32 /nonexistant/lib64
             /usr/local/lib /nonexistant/lib128 )],
          [EMAIL PROTECTED]::Shlibs::librarypaths, "parsed library paths");
+
+use_ok('Dpkg::Shlibs::Objdump');
+use_ok('Dpkg::Shlibs::SymbolFile');


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to