Make SUN compiler happy. Fixes #902
[exim.git] / doc / doc-docbook / OS-Fixups
... / ...
CommitLineData
1#!/usr/bin/perl -w
2# $Cambridge: exim/doc/doc-docbook/OS-Fixups,v 1.1 2009/10/16 10:36:52 nm4 Exp $
3use strict;
4
5# Script to hack around using absolute paths in xsl:import with fixups.
6# Let every OS define its own manipulations.
7# Uses the Perl $^O values to identify the current OS.
8#
9# Define filter_$^O to do substitutions, will be called for every line of
10# every .xsl file.
11
12sub filter_freebsd
13{
14s{"/usr/share/sgml/docbook/xsl-stylesheets-1.70.1/}
15 {"/usr/local/share/xsl/docbook/};
16s{"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"}
17 {"/usr/local/share/xml/docbook/4.2/docbookx.dtd"};
18}
19
20# Define OS filters above.
21
22my $os_filter;
23$os_filter = $main::{"filter_$^O"} if exists $main::{"filter_$^O"};
24
25unless (defined $os_filter)
26 {
27 print "No changes defined for your OS ($^O).\n";
28 exit 0;
29 }
30
31for my $fn (<*.xsl>, <*.xml>)
32 {
33 my $orig = "$fn.orig";
34 rename($fn, $orig) or die "Failed to rename($fn, $orig): $!\n";
35 # Most portable is two-argument form, and none of our filenames are
36 # untrusted or contain whitespace.
37 open(OLD, "< $orig") or die "Failed to read-open($orig): $!\n";
38 open(NEW, "> $fn") or die "Failed to write-open($fn): $!\n";
39 while (<OLD>)
40 {
41 $os_filter->();
42 print NEW $_ or die "Write to \"$fn\" failed: $!\n";
43 }
44 close(NEW) or die "Failed to close($fn) after writing: $!\n";
45 close(OLD);
46 }