瀏覽代碼

Fix many syserr(), warning(), error() and subprocerr() calls in Dpkg::Shlibs::*

Raphael Hertzog 18 年之前
父節點
當前提交
1d7b9b78dc
共有 4 個文件被更改,包括 19 次插入13 次删除
  1. 8 0
      ChangeLog
  2. 2 3
      scripts/Dpkg/Shlibs.pm
  3. 5 6
      scripts/Dpkg/Shlibs/Objdump.pm
  4. 4 4
      scripts/Dpkg/Shlibs/SymbolFile.pm

+ 8 - 0
ChangeLog

@@ -1,3 +1,11 @@
+2008-01-18  Raphael Hertzog  <hertzog@debian.org>
+
+	* scripts/Dpkg/Shlibs/SymbolFile.pm,
+	scripts/Dpkg/Shlibs/Objdump.pm, scripts/Dpkg/Shlibs.pm: Update and
+	fix many syserr(), error(), warning() and subprocerr() calls to
+	the new style where the sprintf call is integrated. Uniformize
+	some error messages at the same time.
+
 2008-01-18  Raphael Hertzog  <hertzog@debian.org>
 
 	* scripts/Dpkg/Shlibs/SymbolFile.pm (load): Parse *@<version>

+ 2 - 3
scripts/Dpkg/Shlibs.pm

@@ -48,8 +48,7 @@ parse_ldso_conf("/etc/ld.so.conf") if -e "/etc/ld.so.conf";
 my %visited;
 sub parse_ldso_conf {
     my $file = shift;
-    open my $fh, "<", $file
-	or syserr(sprintf(_g("couldn't open %s"), $file));
+    open my $fh, "<", $file or syserr(_g("cannot open %s"), $file);
     $visited{$file}++;
     while (<$fh>) {
 	next if /^\s*$/;
@@ -68,7 +67,7 @@ sub parse_ldso_conf {
 	    }
 	}
     }
-    close $fh or syserr(sprintf(_g("couldn't close %s"), $file));;
+    close $fh;
 }
 
 # find_library ($soname, \@rpath, $format, $root)

+ 5 - 6
scripts/Dpkg/Shlibs/Objdump.pm

@@ -79,15 +79,14 @@ sub get_object {
 		    return $format{$file};
 		}
 	    }
-	    close(P) or subprocerr(sprintf(_g("objdump on \`%s'"), $file));
+	    close(P) or subprocerr(_g("objdump on \`%s'"), $file);
 	}
     }
 }
 
 sub is_elf {
     my ($file) = @_;
-    open(FILE, "<", $file) ||
-	syserr(sprintf(_g("Can't open %s for test: %s"), $file, $!));
+    open(FILE, "<", $file) || syserr(_g("cannot read %s"), $file);
     my ($header, $result) = ("", 0);
     if (read(FILE, $header, 4) == 4) {
 	$result = 1 if ($header =~ /^\177ELF$/);
@@ -146,7 +145,7 @@ sub _read {
 
     local $ENV{LC_ALL} = 'C';
     open(my $objdump, "-|", "objdump", "-w", "-f", "-p", "-T", "-R", $file)
-	|| syserr(sprintf(_g("Can't execute objdump: %s"), $!));
+	|| syserr(_g("cannot fork %s"), "objdump");
     my $ret = $self->_parse($objdump);
     close($objdump);
     return $ret;
@@ -187,7 +186,7 @@ sub _parse {
 	    if (/^\S+\s+(\S+)\s+(\S+)\s*$/) {
 		$self->{dynrelocs}{$2} = $1;
 	    } else {
-		warning(sprintf(_g("Couldn't parse dynamic relocation record: %s"), $_));
+		warning(_g("Couldn't parse dynamic relocation record: %s"), $_);
 	    }
 	} elsif ($section eq "dyninfo") {
 	    if (/^\s*NEEDED\s+(\S+)/) {
@@ -297,7 +296,7 @@ sub parse_dynamic_symbol {
 	# Ignore some s390-specific output like
 	# REG_G6           g     R *UND*      0000000000000000              #scratch
     } else {
-	warning(sprintf(_g("Couldn't parse dynamic symbol definition: %s"), $line));
+	warning(_g("Couldn't parse dynamic symbol definition: %s"), $line);
     }
 }
 

+ 4 - 4
scripts/Dpkg/Shlibs/SymbolFile.pm

@@ -102,13 +102,13 @@ sub load {
     $seen->{$file} = 1;
 
     open(my $sym_file, "<", $file)
-	|| syserr(sprintf(_g("Can't open %s: %s"), $file));
+	|| syserr(_g("cannot open %s"), $file);
     my $object = $current_object;
     while (defined($_ = <$sym_file>)) {
 	chomp($_);
 	if (/^\s+(\S+)\s(\S+)(?:\s(\d+))?/) {
 	    if (not defined ($object)) {
-		error(sprintf(_g("Symbol information must be preceded by a header (file %s, line %s).", $file, $.)));
+		error(_g("Symbol information must be preceded by a header (file %s, line %s)."), $file, $.);
 	    }
 	    my $name = $1;
 	    # New symbol
@@ -154,7 +154,7 @@ sub load {
 		$self->create_object($object, "$2");
 	    }
 	} else {
-	    warning(sprintf(_g("Failed to parse a line in %s: %s"), $file, $_));
+	    warning(_g("Failed to parse a line in %s: %s"), $file, $_);
 	}
     }
     close($sym_file);
@@ -168,7 +168,7 @@ sub save {
 	$fh = \*STDOUT;
     } else {
 	open($fh, ">", $file)
-	    || syserr(sprintf(_g("Can't open %s for writing: %s"), $file, $!));
+	    || syserr(_g("cannot write %s"), $file);
     }
     $self->dump($fh, $with_deprecated);
     close($fh) if ($file ne "-");