File: MergePCBPS

package info (click to toggle)
pcb 20080202-2
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 22,684 kB
  • ctags: 10,254
  • sloc: ansic: 81,609; sh: 5,803; yacc: 5,032; pascal: 3,999; makefile: 1,322; lex: 410; perl: 308; awk: 158; tcl: 63; xml: 20
file content (49 lines) | stat: -rwxr-xr-x 788 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/sh
#
# $Id: MergePCBPS,v 1.2 2004/02/09 04:06:30 danmc Exp $
#
# merges PostScript files created by pcb (version >= 1.4.2) into
# a single file for backward compatibility
#
# Usage: name files...
#
# by Thomas Nau 9/96
#

if [ $# -eq 0 ]; then
	echo "Usage: `basename $0` files..." >&2
	exit 1
fi

# some system need nawk
#
case `uname` in
	SunOS)	AWK=nawk;;
	*)		AWK=awk;;
esac

$AWK '
	BEGIN								{ filecount = 0; }
	/^%!PS/								{ filecount++; }
	/^%!PS/,/^% PCBENDDATA/				{
		if (filecount == 1)
		{
			if (index($0, "%%Title:") == 1)
				sub(",.*$", ", merged layouts");
			print $0;
			next;
		}
	}
	/^% PCBSTARTDATA/,/^% PCBENDDATA/	{
		if (filecount > 1)
		{
			print $0;
			next;
		}
	}
										{ next; }
	END									{
		print "showpage";
		print "%%EOF";
	}
' $@