Changelog updated with details of the eximstats changes.
[exim.git] / doc / doc-scripts / JoinPS
CommitLineData
495ae4b0
PH
1#!/usr/bin/perl
2# $Cambridge: exim/doc/doc-scripts/JoinPS,v 1.1 2004/10/07 15:04:35 ph10 Exp $
3
4# Make the basic PostScript file for the Exim spec from the gcode file, then
5# join it together with the contents and the index, to make a single
6# PostScript file, suitable for double-sided printing.
7
8sub blank_page {
9my($title) = shift @_;
10printf(OUT "%%%%Page: %s %d\nxpage\n\n", $title, $pagenumber++);
11}
12
13
14@roman = ("i", "ii", "iii", "iv", "v", "vi", "vii", "viii", "ix", "x",
15 "xi", "xii", "xiii", "xiv", "xv", "xvi", "xvii", "xviii", "xix");
16
17$pagenumber = 1;
18
19system("sgtops z-gcode -to z-ps") && die "sgtops run failed\n";
20
21open(SPEC, "z-ps") || die "Can't open z-ps\n";
22open(CONTS, "zc-ps") || die "Can't open zc-ps\n";
23open(INDEX, "zi-ps") || die "Can't open zi-ps\n";
24open(OUT, ">spec.ps") || die "Can't open spec.ps\n";
25
26# Copy spec headings etc.
27
28while (<SPEC>)
29 {
30 last if (/^%%Page:/) ;
31 print OUT;
32 }
33
34# Copy the first two pages - the title page, and its blank verso
35
36for ($i = 1; $i < 3; $i++)
37 {
38 printf(OUT "%%%%Page: title%s %d\n", ($i == 1)? "" : "-verso", $pagenumber++);
39 while (<SPEC>)
40 {
41 last if (/^%%Page:/) ;
42 print OUT;
43 }
44 }
45
46# Skip the contents heading
47
48while (<CONTS>)
49 {
50 last if (/^%%Page:/) ;
51 }
52
53# Output the contents pages - fudge the roman numerals as we know there
54# won't be a vast number of them.
55
56$subpagenumber = 0;
57while (!eof CONTS)
58 {
59 printf(OUT "%%%%Page: %s %d\n", $roman[$subpagenumber++], $pagenumber++);
60 while (<CONTS>)
61 {
62 next if (/^%%Pages:/);
63 next if (/^%%Trailer/);
64 last if (/^%%Page:/) ;
65 print OUT;
66 }
67 }
68printf(OUT "\n");
69
70# If contents was an odd number of pages, insert a blank page
71
72&blank_page("contents-pad") if ($pagenumber & 1) == 0;
73
74# Copy the rest of the main file
75
76$subpagenumber = 1;
77
78while (!eof SPEC)
79 {
80 printf(OUT "%%%%Page: %d %d\n", $subpagenumber++, $pagenumber++);
81 while (<SPEC>)
82 {
83 next if (/^%%Pages:/);
84 next if (/^%%Trailer/);
85 last if (/^%%Page:/) ;
86 print OUT;
87 }
88 }
89printf(OUT "\n");
90
91# If contents was an odd number of pages, insert a blank page
92
93&blank_page("body-pad") if ($pagenumber & 1) == 0;
94
95# Skip the index heading
96
97while (<INDEX>)
98 {
99 last if (/^%%Page:/) ;
100 }
101
102# Copy the index pages
103
104$subpagenumber = 1;
105
106while (!eof INDEX)
107 {
108 printf(OUT "%%%%Page: I%d %d\n", $subpagenumber++, $pagenumber++);
109 while (<INDEX>)
110 {
111 next if (/^%%Pages:/);
112 next if (/^%%Trailer/);
113 last if (/^%%Page:/) ;
114 print OUT;
115 }
116 }
117
118# Add final comments
119
120printf(OUT "%%%%Trailer\n");
121printf(OUT "%%%%Pages: %d\n", $pagenumber-1);
122
123# That's it
124
125close(SPEC);
126close(CONTS);
127close(INDEX);
128close(OUT);
129
130# End