blob: f1503eaeb6754e906b6bd19f9cf96287c10b9329 (
plain)
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
%
% This file belongs to the MFTOEPS package.
%
% TeX file approximately emulating the following AWK program:
% BEGIN {N=""}
% $0 ~ /^:EPS FILE NAME: / {
% if (NF==3) {N="vicar.eps"} else {N=$NF ".eps"} print "extracting " N}
% $0 ~ /^:PS: / {print substr($0,6) > N}
% (see SPLITEPS.AWK)
%
% REMARK: it was a suggestion of Phil Taylor to use TeX instead of AWK.
\ifx\inputname\undefined \errmessage{\noexpand\inputname NOT DEFINED}\fi
\newread\currentinput \immediate\openin\currentinput\inputname\relax
\ifeof\currentinput \errmessage{FILE \inputname\space NOT FOUND}\fi
\newwrite\currentoutput
\newif\ifcontinueloop
\newif\ifoutputopen \outputopenfalse
\def\EPSfirstline{EPS FILE NAME}
\def\EPSline{PS}
\def\gobblespace#1{#1}
\def\truncatekey#1:#2:#3\relax{%
\def\linecontents{#3}%
\ifx\linecontents\empty
\else
\edef\linecontents{\expandafter\gobblespace\linecontents}%
\fi}
\long\def\getkey#1:#2:{\gdef\prekey{#1}\gdef\key{#2}}
\def\getline{%
\immediate\read\currentinput to \currentline \edef\currentline{\currentline}%
\setbox0\hbox{\expandafter\getkey\currentline::}}
\def\fixnewoutputname{%
\expandafter\truncatekey\currentline\relax
\edef\outputname{\linecontents}%
\ifx\outputname\empty \edef\outputname{vicar.eps }%
\else \edef\outputname{\outputname.eps }\fi
\immediate\write16{extracting \outputname}}
\def\optionallyopenout{%
\ifx\key\EPSfirstline
\optionallycloseout \fixnewoutputname
\immediate\openout\currentoutput\outputname\relax
\ifeof\currentoutput
\errmessage{CANNOT OPEN \outputname FOR WRITING}\global\outputopenfalse
\else
\global\outputopentrue
\fi
\fi}
\def\optionallycloseout{\ifoutputopen \immediate\closeout\currentoutput \fi}
\def\optionallyputline{%
\ifx\key\EPSline
\expandafter\truncatekey\currentline\relax
\immediate\write\currentoutput{\linecontents}%
\fi}
\def\checklooping{\continuelooptrue\ifeof\currentinput\continueloopfalse\fi}
\def\neutralizecatcodes{%
\catcode`\\12 \catcode`\%12 \catcode`\&12 \catcode`\_12
\catcode`\^12 \catcode`\{12 \catcode`\}12 \catcode`\/12 }
\def\getlines{%
\begingroup
\endlinechar=-1
\neutralizecatcodes
\loop
\getline \ifx\prekey\empty \optionallyopenout \optionallyputline \fi
\checklooping \ifcontinueloop \repeat
\endgroup
\optionallycloseout}
\getlines
\end
|