Rename folder name from german to english
[ccbib.git] / psutils / psmerge.pl
bloba1a9db7c08650a847353824d31ce2ca74362526d
1 @PERL@
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] =~ /^-/) {
11 $_ = shift;
12 if (/^-o(.+)/) {
13 if (!close(STDOUT) || !open(STDOUT, ">$1")) {
14 print STDERR "$prog: can't open $1 for output\n";
15 exit 1;
17 } elsif (/^-t(horough)?$/) {
18 $thorough = 1;
19 } else {
20 print STDERR "Usage: $prog [-oout] [-thorough] file...\n";
21 exit 1;
25 $page = 0;
26 $first = 1;
27 $nesting = 0;
29 @header = ();
30 $header = 1;
32 @trailer = ();
33 $trailer = 0;
35 @pages = ();
36 @body = ();
38 @resources = ();
39 $inresource = 0;
41 while (<>) {
42 if (/^%%BeginFont:/ || /^%%BeginResource:/ || /^%%BeginProcSet:/) {
43 $inresource = 1;
44 push(@resources, $_);
45 } elsif ($inresource) {
46 push(@resources, $_);
47 $inresource = 0 if /^%%EndFont/ || /^%%EndResource/ || /^%%EndProcSet/;
48 } elsif (/^%%Page:/ && $nesting == 0) {
49 $header = $trailer = 0;
50 push(@pages, join("", @body)) if @body;
51 $page++;
52 @body = ("%%Page: ($page) $page\n");
53 } elsif (/^%%Trailer/ && $nesting == 0) {
54 push(@trailer, $_);
55 push(@pages, join("", @body)) if @body;
56 @body = ();
57 $trailer = 1;
58 $header = 0;
59 } elsif ($header) {
60 push(@trailer, $_);
61 push(@pages, join("", @body)) if @body;
62 @body = ();
63 $trailer = 1;
64 $header = 0;
65 } elsif ($trailer) {
66 if (/^%!/ || /%%EOF/) {
67 $trailer = $first = 0;
68 } elsif ($first) {
69 push(@trailer, $_);
71 } elsif (/^%%BeginDocument/ || /^%%BeginBinary/ || /^%%BeginFile/) {
72 push(@body, $_);
73 $nesting++;
74 } elsif (/^%%EndDocument/ || /^%%EndBinary/ || /^%%EndFile/) {
75 push(@body, $_);
76 $nesting--;
77 } else {
78 print $_ if $print;
82 print @trailer;
84 exit 0;
85 @END@