Code for verify=header_names_ascii
[users/heiko/exim.git] / doc / doc-docbook / OS-Fixups
1 #!/usr/bin/perl -w
2
3 use strict;
4
5 # Script to hack around xsl:import paths; ideally, the system catalogs are used.
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
12 sub filter_freebsd
13 {
14 s{"http://docbook.sourceforge.net/release/xsl/current/}
15  {"/usr/local/share/xsl/docbook/};
16 s{"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"}
17  {"/usr/local/share/xml/docbook/4.2/docbookx.dtd"};
18 }
19
20 sub filter_linux
21 {
22 # SUSE 10 with extra pkgs
23 -d "/usr/share/xml/docbook/stylesheet/nwalsh/1.71.1/" &&
24   s{"http://docbook.sourceforge.net/release/xsl/current/}
25    {"/usr/share/xml/docbook/stylesheet/nwalsh/1.71.1/};
26 # Ubuntu/Debian with standard docbook-xsl pkgs
27 -d "/usr/share/xml/docbook/stylesheet/docbook-xsl/" &&
28   s{"http://docbook.sourceforge.net/release/xsl/current/}
29    {"/usr/share/xml/docbook/stylesheet/docbook-xsl/};
30 s{"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"}
31  {"/usr/share/xml/docbook/schema/dtd/4.2/docbookx.dtd"};
32 }
33
34 sub filter_darwin
35 {
36 # NB - this uses the Mac Ports installations
37 s{"http://docbook.sourceforge.net/release/xsl/current/}
38  {"/opt/local/share/xsl/docbook-xsl/};
39 s{"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"}
40  {"/opt/local/share/xml/docbook/4.2/docbookx.dtd"};
41 }
42
43
44 # Define OS filters above.
45
46 my $os_filter;
47 $os_filter = $main::{"filter_$^O"} if exists $main::{"filter_$^O"};
48
49 unless (defined $os_filter)
50   {
51   print "No changes defined for your OS ($^O).\n";
52   exit 0;
53   }
54
55 for my $fn (<*.xsl>, <*.xml>)
56   {
57   my $orig = "$fn.orig";
58   rename($fn, $orig) or die "Failed to rename($fn, $orig): $!\n";
59   # Most portable is two-argument form, and none of our filenames are
60   # untrusted or contain whitespace.
61   open(OLD, "< $orig") or die "Failed to read-open($orig): $!\n";
62   open(NEW, "> $fn") or die "Failed to write-open($fn): $!\n";
63   while (<OLD>)
64     {
65     $os_filter->();
66     print NEW $_ or die "Write to \"$fn\" failed: $!\n";
67     }
68   close(NEW) or die "Failed to close($fn) after writing: $!\n";
69   close(OLD);
70   }