summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Jackson <ijackson@chiark.greenend.org.uk>2016-05-01 12:35:37 +0100
committerIan Jackson <ijackson@chiark.greenend.org.uk>2016-05-01 12:41:29 +0100
commitced98e3d359fbe2910913f8ff4d7a339ebf2c8d2 (patch)
treeb7df57fd39a9896c94d85e889cf8ccb5b9a498e7
parent2b5b1a7d495b3415f5f6694da6ac7139d13bced3 (diff)
update-xfonts-traditional: Factor out process_filter
We are going to want to reuse this so that we can put bdfnorm in front of every processbdf. No functional change.
-rwxr-xr-xupdate-xfonts-traditional71
1 files changed, 47 insertions, 24 deletions
diff --git a/update-xfonts-traditional b/update-xfonts-traditional
index f096177..8dccad4 100755
--- a/update-xfonts-traditional
+++ b/update-xfonts-traditional
@@ -171,22 +171,24 @@ sub loadfoundries () {
die "no foundry maps\n" unless %foundrymap;
}
+our %ch;
+
sub filter_st_isok ($) {
my ($ch) = @_;
my $st = $ch->{St};
return !$st || $ch->{SigOK}{($st & ~128)};
}
-sub processpcfgz ($$$$) {
- my ($inpcfgz,$outpcfgz,$logfh,$what) = @_;
- print $reportfh "processing $inpcfgz to $outpcfgz\n" if $verbose>=2;
- my $current = new IO::File $inpcfgz, '<' or die "$inpcfgz $!";
- my ($usread,$uswrite);
+sub process_filter ($$$$$$$$) {
+ my ($rr, $input, $output,$what,$logfh,
+ $procs, $sigpipeok, $after_hook) = @_;
my ($reader,$writer);
my @children;
- my %ch;
- foreach my $proc (['gunzip'], ['pcf2bdf'], [],
- ['bdftopcf'],['',qw(gzip -1 -n)]) {
+ my ($usread,$uswrite);
+
+ my $current = $input;
+
+ foreach my $proc (@$procs) {
my $isfinal = (@$proc && $proc->[0] eq '');
if (!$isfinal) {
$reader = new IO::Handle or die $!;
@@ -195,7 +197,7 @@ sub processpcfgz ($$$$) {
} else {
shift @$proc;
$reader = undef;
- $writer = new IO::File $outpcfgz, '>' or die "$outpcfgz $!";
+ $writer = $output;
}
if (@$proc) {
my $exe = $proc->[0];
@@ -227,13 +229,12 @@ sub processpcfgz ($$$$) {
$current = $reader;
}
}
- my $r = processbdf($usread,$uswrite,$logfh,$what);
- my $none = $r !~ m/^\d/;
+ $$rr = processbdf($usread,$uswrite,$logfh,$what);
+ my $none = $$rr !~ m/^\d/;
- $ch{'gunzip'}{SigOK}{13} = 1;
- # ... we never care if pcf2bdf didn't want all the output from gunzip
+ $ch{$_}{SigOK}{13} = 1 foreach @$sigpipeok;
- if ($none || !$r) {
+ if ($none || !$$rr) {
# We're not going to install or use this so we can kill our
# input and output filters. We kill the input filters so that
# we don't risk waiting for them. (If the input filter died
@@ -252,6 +253,7 @@ sub processpcfgz ($$$$) {
$ch{'pcf2bdf'}{SigOK}{13} = 1;
# ... we might not have read all the output from pcf2bdf, which is OK
}
+
close $uswrite or die $!;
close $usread or die $!;
@@ -261,23 +263,44 @@ sub processpcfgz ($$$$) {
$ch->{St} = $?;
}
- if ($tolerate_bad_fonts &&
- $r eq 'no bdf data' &&
- filter_st_isok($ch{'gunzip'}) &&
- ($ch{'pcf2bdf'}{St} & ~128) == 6)
- {
- $r = "pcf2bdf failed ($ch{'pcf2bdf'}{St})";
- print STDERR "warning: $r: skipping $inpcfgz\n";
- $ch{'pcf2bdf'}{SigOK}{6} = 1;
- }
+ $after_hook->();
+
foreach my $ch (@children) {
if (!filter_st_isok($ch)) {
die "update-xfonts-traditional:".
- " $ch->{Exe} [$ch->{Pid}] for $inpcfgz".
+ " $ch->{Exe} [$ch->{Pid}] for $what".
" failed $ch->{St}".
" (".(join ' ', keys %{ $ch->{SigOK} })." ok)\n";
}
}
+}
+
+sub processpcfgz ($$$$) {
+ my ($inpcfgz,$outpcfgz,$logfh,$what) = @_;
+ print $reportfh "processing $inpcfgz to $outpcfgz\n" if $verbose>=2;
+ my $input = new IO::File $inpcfgz, '<' or die "$inpcfgz $!";
+ my $output = new IO::File $outpcfgz, '>' or die "$outpcfgz $!";
+
+ my $r;
+ process_filter(\$r, $input, $output, $inpcfgz, $logfh,
+ [
+ ['gunzip'], ['pcf2bdf'],
+ [],
+ ['bdftopcf'],['',qw(gzip -1 -n)]
+ ],
+ [qw(gunzip)],
+ # ... we never care if pcf2bdf didn't want all the data
+ sub {
+ if ($tolerate_bad_fonts &&
+ $r eq 'no bdf data' &&
+ filter_st_isok($ch{'gunzip'}) &&
+ ($ch{'pcf2bdf'}{St} & ~128) == 6)
+ {
+ $r = "pcf2bdf failed ($ch{'pcf2bdf'}{St})";
+ print STDERR "warning: $r: skipping $inpcfgz\n";
+ $ch{'pcf2bdf'}{SigOK}{6} = 1;
+ }
+ });
return $r;
}