2
# psmerge: merge PostScript files produced by same application and setup
3
# usage: psmerge [-oout.ps] [-thorough] file1.ps file2.ps ...
5
# Copyright (C) Angus J. C. Duggan 1991-1995
6
# See file LICENSE for details.
8
$prog = ($0 =~ s=.*/==);
10
while ($ARGV[0] =~ /^-/) {
13
if (!close(STDOUT) || !open(STDOUT, ">$1")) {
14
print STDERR "$prog: can't open $1 for output\n";
17
} elsif (/^-t(horough)?$/) {
20
print STDERR "Usage: $prog [-oout] [-thorough] file...\n";
42
if (/^%%BeginFont:/ || /^%%BeginResource:/ || /^%%BeginProcSet:/) {
45
} elsif ($inresource) {
47
$inresource = 0 if /^%%EndFont/ || /^%%EndResource/ || /^%%EndProcSet/;
48
} elsif (/^%%Page:/ && $nesting == 0) {
49
$header = $trailer = 0;
50
push(@pages, join("", @body)) if @body;
52
@body = ("%%Page: ($page) $page\n");
53
} elsif (/^%%Trailer/ && $nesting == 0) {
55
push(@pages, join("", @body)) if @body;
61
push(@pages, join("", @body)) if @body;
66
if (/^%!/ || /%%EOF/) {
67
$trailer = $first = 0;
71
} elsif (/^%%BeginDocument/ || /^%%BeginBinary/ || /^%%BeginFile/) {
74
} elsif (/^%%EndDocument/ || /^%%EndBinary/ || /^%%EndFile/) {