diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2013-08-06 16:05:08 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2013-08-06 16:05:08 +0300 |
commit | d5a7bec01733d3fa72578a1a01c8e9d62252847b (patch) | |
tree | 97cb62d233cc4c9fdb8b2a453352dedf6245ddc1 | |
parent | 71f215659046de3dfe63c4a84ae92d92d5213044 (diff) | |
download | mansrv-d5a7bec01733d3fa72578a1a01c8e9d62252847b.tar.gz mansrv-d5a7bec01733d3fa72578a1a01c8e9d62252847b.tar.bz2 |
Select decompressor based on the file suffix.
-rwxr-xr-x | mansrv | 14 |
1 files changed, 11 insertions, 3 deletions
@@ -35,12 +35,20 @@ our $incfilesuf; my @deps = ( $0 ); my @grohtml_opts; my $tempcachefile; my $mansep; +my %decomp = ( + 'gz' => 'gzip -d -c', + 'bz2' => 'bzip2 -d -c', + 'z' => 'compress -d -c', + 'Z' => 'compress -d -c' +); + + sub syserror { my $s = shift; syslog("LOG_ERR", "$s"); print "<h1>ABEND</h1>\n"; # Let them guess... exit 1; } @@ -242,15 +250,15 @@ unless (-e $cachefile && checkdeps($cachefile)) { if ($includepath) { $groffcmd .= join(' ',map { "-I $_" } split(/:/,$includepath)) . " "; } if ($#grohtml_opts >= 0) { $groffcmd .= join(' ', @grohtml_opts) . " "; } - - if ($file =~ /\.gz$/) { - $groffcmd = "gzip -d -c $file | $groffcmd -"; + + if ($file =~ /.*\.([^.]+)$/ && exists($decomp{$1})) { + $groffcmd = "$decomp{$1} $file | $groffcmd -"; } else { $groffcmd .= $file; } open(my $p, "-|", $groffcmd) or syserror("running \"$groffcmd\": $!"); |