summaryrefslogtreecommitdiffabout
authorSergey Poznyakoff <gray@gnu.org.ua>2013-08-06 13:05:08 (GMT)
committer Sergey Poznyakoff <gray@gnu.org.ua>2013-08-06 13:05:08 (GMT)
commitd5a7bec01733d3fa72578a1a01c8e9d62252847b (patch) (side-by-side diff)
tree97cb62d233cc4c9fdb8b2a453352dedf6245ddc1
parent71f215659046de3dfe63c4a84ae92d92d5213044 (diff)
downloadmansrv-d5a7bec01733d3fa72578a1a01c8e9d62252847b.tar.gz
mansrv-d5a7bec01733d3fa72578a1a01c8e9d62252847b.tar.bz2
Select decompressor based on the file suffix.
Diffstat (more/less context) (ignore whitespace changes)
-rwxr-xr-xmansrv14
1 files changed, 11 insertions, 3 deletions
diff --git a/mansrv b/mansrv
index e42c689..100df80 100755
--- a/mansrv
+++ b/mansrv
@@ -38,6 +38,14 @@ 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");
@@ -245,9 +253,9 @@ unless (-e $cachefile && checkdeps($cachefile)) {
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;
}

Return to:

Send suggestions and report system problems to the System administrator.