From: Frank Lichtenheld Date: Thu, 6 Dec 2007 02:41:28 +0000 (+0100) Subject: dpkg-parsechangelog: Clean-up X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7a970d3d153565ffcdf1bf22e62e6999337dee70;p=dpkg dpkg-parsechangelog: Clean-up use English error handling fixes use newer open syntax --- diff --git a/scripts/dpkg-parsechangelog.pl b/scripts/dpkg-parsechangelog.pl index 64340c06..be4db979 100755 --- a/scripts/dpkg-parsechangelog.pl +++ b/scripts/dpkg-parsechangelog.pl @@ -3,6 +3,7 @@ use strict; use warnings; +use English; use POSIX; use POSIX qw(:errno_h); use Dpkg; @@ -51,24 +52,23 @@ my @ap = (); while (@ARGV) { last unless $ARGV[0] =~ m/^-/; $_= shift(@ARGV); - if (m/^-L/ && length($_)>2) { $libdir=$'; next; } + if (m/^-L/ && length($_)>2) { $libdir=$POSTMATCH; next; } if (m/^-F([0-9a-z]+)$/) { $force=1; $format=$1; next; } push(@ap,$_); - if (m/^-l/ && length($_)>2) { $changelogfile=$'; next; } + if (m/^-l/ && length($_)>2) { $changelogfile=$POSTMATCH; next; } m/^--$/ && last; m/^-v/ && next; if (m/^-(h|-help)$/) { &usage; exit(0); } if (m/^--version$/) { &version; exit(0); } - &usageerr("unknown option \`$_'"); + &usageerr(_g("unknown option \`%s'"), $_); } @ARGV && usageerr(_g("%s takes no non-option arguments"), $progname); -$changelogfile= "./$changelogfile" if $changelogfile =~ m/^\s/; if (not $force and $changelogfile ne "-") { - open(STDIN,"< $changelogfile") || - error(_g("cannot open %s to find format: %s"), $changelogfile, $!); - open(P,"tail -n 40 |") || die sprintf(_g("cannot fork: %s"), $!)."\n"; + open(STDIN,"<", $changelogfile) || + syserr(_g("cannot open %s to find format"), $changelogfile); + open(P,"-|","tail","-n",40) || syserr(_g("cannot fork")); while(

) { next unless m/\schangelog-format:\s+([0-9a-z]+)\W/; $format=$1; @@ -90,11 +90,12 @@ for my $pd (@parserpath) { last; } } - + defined($pf) || error(_g("format %s unknown"), $pa); if ($changelogfile ne "-") { - open(STDIN,"< $changelogfile") || die sprintf(_g("cannot open %s: %s"), $changelogfile, $!)."\n"; + open(STDIN,"<", $changelogfile) + || syserr(_g("cannot open %s: %s"), $changelogfile); } -exec($pf,@ap); die sprintf(_g("cannot exec format parser: %s"), $!)."\n"; +exec($pf,@ap) || syserr(_g("cannot exec format parser: %s"));