2 # $Cambridge: exim/doc/doc-scripts/JoinPS,v 1.1 2004/10/07 15:04:35 ph10 Exp $
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.
10 printf(OUT "%%%%Page: %s %d\nxpage\n\n", $title, $pagenumber++);
14 @roman = ("i", "ii", "iii", "iv", "v", "vi", "vii", "viii", "ix", "x",
15 "xi", "xii", "xiii", "xiv", "xv", "xvi", "xvii", "xviii", "xix");
19 system("sgtops z-gcode -to z-ps") && die "sgtops run failed\n";
21 open(SPEC, "z-ps") || die "Can't open z-ps\n";
22 open(CONTS, "zc-ps") || die "Can't open zc-ps\n";
23 open(INDEX, "zi-ps") || die "Can't open zi-ps\n";
24 open(OUT, ">spec.ps") || die "Can't open spec.ps\n";
26 # Copy spec headings etc.
30 last if (/^%%Page:/) ;
34 # Copy the first two pages - the title page, and its blank verso
36 for ($i = 1; $i < 3; $i++)
38 printf(OUT "%%%%Page: title%s %d\n", ($i == 1)? "" : "-verso", $pagenumber++);
41 last if (/^%%Page:/) ;
46 # Skip the contents heading
50 last if (/^%%Page:/) ;
53 # Output the contents pages - fudge the roman numerals as we know there
54 # won't be a vast number of them.
59 printf(OUT "%%%%Page: %s %d\n", $roman[$subpagenumber++], $pagenumber++);
62 next if (/^%%Pages:/);
63 next if (/^%%Trailer/);
64 last if (/^%%Page:/) ;
70 # If contents was an odd number of pages, insert a blank page
72 &blank_page("contents-pad") if ($pagenumber & 1) == 0;
74 # Copy the rest of the main file
80 printf(OUT "%%%%Page: %d %d\n", $subpagenumber++, $pagenumber++);
83 next if (/^%%Pages:/);
84 next if (/^%%Trailer/);
85 last if (/^%%Page:/) ;
91 # If contents was an odd number of pages, insert a blank page
93 &blank_page("body-pad") if ($pagenumber & 1) == 0;
95 # Skip the index heading
99 last if (/^%%Page:/) ;
102 # Copy the index pages
108 printf(OUT "%%%%Page: I%d %d\n", $subpagenumber++, $pagenumber++);
111 next if (/^%%Pages:/);
112 next if (/^%%Trailer/);
113 last if (/^%%Page:/) ;
120 printf(OUT "%%%%Trailer\n");
121 printf(OUT "%%%%Pages: %d\n", $pagenumber-1);