forked from erkyrath/infocom-zcode-terps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfixer.mud
61 lines (57 loc) · 1.94 KB
/
fixer.mud
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
<SETG ASC-CTJ <ASCII 10>>
<SETG ASC-CTM <ASCII 13>>
<SETG ASC-CTP <ASCII 16>>
<SETG ASC-TAB <ASCII 9>>
<SETG ASC-ESC <ASCII 27>>
<SETG ASC-PRN !\(>
<MANIFEST ASC-CTJ ASC-CTM ASC-CTP ASC-TAB ASC-ESC ASC-PRN>
<SETG END-READ <STRING <ASCII 27>>>
<GDECL (END-READ) STRING>
<DEFINE CVT (INFILE OUTFILE "AUX" INCH OUCH)
#DECL ((INFILE OUTFILE) STRING (INCH OUCH) <OR CHANNEL FALSE>)
<COND (<NOT <SET INCH <OPEN "READ" .INFILE>>> .INCH)
(<NOT <SET OUCH <OPEN "PRINT" .OUTFILE>>> .OUCH)
(ELSE
<REPEAT (CHR CHR1 CHR2) #DECL ((CHR CHR1 CHR2) CHARACTER)
<SET CHR <READCHR .INCH '<RETURN>>>
<COND (<==? .CHR ,ASC-CTM>
<SET CHR1 <READCHR .INCH '<RETURN>>>
<COND (<==? .CHR1 ,ASC-CTP>
<SET CHR2 <READCHR .INCH '<RETURN>>>
<PRINC ,ASC-CTM .OUCH>
<PRINC ,ASC-CTJ .OUCH>
<COND (<==? .CHR2 ,ASC-PRN>
<PRINC ,ASC-TAB .OUCH>)
(ELSE <PRINC .CHR2 .OUCH>)>)
(ELSE
<PRINC .CHR .OUCH>
<PRINC .CHR1 .OUCH>)>)
(ELSE <PRINC .CHR .OUCH>)>>
<CLOSE .INCH>
<CLOSE .OUCH>)>>
<DEFINE INIT-CVT ("AUX" INLNT OUTLNT INFILE OUTFILE
(INCHAN .INCHAN) (OUTCHAN .OUTCHAN))
#DECL ((INLNT OUTLNT) FIX (INFILE OUTFILE) STRING
(INCHAN OUTCHAN) CHANNEL)
<REPEAT ()
<READCHR .INCHAN>
<PRINC "Input File: " .OUTCHAN>
<SET INLNT
<READSTRING <SET INFILE <ISTRING 30>> .INCHAN ,END-READ>>
<COND (<0? .INLNT> <QUIT>)
(ELSE <SET INFILE <SUBSTRUC .INFILE 0 .INLNT>>)>
<PRINC !\[ .OUTCHAN>
<PRINC .INFILE .OUTCHAN>
<PRINC !\] .OUTCHAN>
<CRLF .OUTCHAN>
<PRINC "Output File: " .OUTCHAN>
<SET OUTLNT
<READSTRING <SET OUTFILE <ISTRING 30>> .INCHAN ,END-READ>>
<COND (<0? .OUTLNT> <SET OUTFILE .INFILE>)
(ELSE <SET OUTFILE <SUBSTRUC .OUTFILE 0 .OUTLNT>>)>
<PRINC !\[ .OUTCHAN>
<PRINC .OUTFILE .OUTCHAN>
<PRINC !\] .OUTCHAN>
<CRLF .OUTCHAN>
<CVT .INFILE .OUTFILE>>>
<OR <LOOKUP "COMPILE" <ROOT>> <INIT-CVT>>