/
armdictohack.Mod
207 lines (167 loc) · 5.06 KB
/
armdictohack.Mod
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
MODULE armdictohack;
IMPORT Files, Out := Console, SYSTEM,
ArmsciiUTF;
CONST maindat = "maintest.dat";
outtxt = "out.tab";
PROCEDURE WriteChar(VAR r : Files.Rider; ch : CHAR);
BEGIN
Files.WriteByte(r, SHORT(ORD(ch))); (* write ascii character *)
Out.Char(ch);
END WriteChar;
PROCEDURE WriteString(VAR r : Files.Rider; str : ArmsciiUTF.string);
BEGIN
Files.WriteBytes(r, str^, LEN(str^)-1);
Out.String(str^);
END WriteString;
PROCEDURE Fix(VAR r : Files.Rider; VAR f : Files.File);
VAR WrongYev, RightYev, WrongExclam, RightExclam : CHAR;
i : LONGINT;
ch, lch : CHAR;
BEGIN
WrongYev := 0A8X;
RightYev := 0A2X; (* https://web.archive.org/web/20010118220400/http://www.freenet.am/armnls/fonts.htm see The EV problem *)
WrongExclam := 07EX; (* ~ *)
RightExclam := 0AFX;
i := 0; lch := ' ';
Files.Set(r, f, i);
WHILE ~ r.eof DO
Files.Set(r, f, i);
Files.Read(r, ch);
IF ch = WrongYev THEN
Files.Set(r, f, i);
Files.WriteByte(r, RightYev);
(*Files.Set(r, f, i+1);*)
END;
IF (ch = WrongExclam) & (lch > 0A2X) THEN
Files.Set(r, f, i);
Files.WriteByte(r, RightExclam);
(*Files.Set(r, f, i+1); *)
END;
lch := ch;
INC(i);
END;
Files.Set(r, f, 2191531); (* 002170AB is 2191531 *)
Files.WriteByte(r, 111); (* replace errorneus armscii-8 o with latin o *)
Files.Set(r, f, 2999763); (* 002dc5d3 is 2999763 *)
Files.WriteByte(r, 111); (* same here, armscii-8 "o" letter in English word should be latin *)
Files.Set(r, f, 1815116);
Files.WriteByte(r, 0);
(* wrong translation of "lentil", it is "սուպ" instead of "ոսպ" *)
Files.Set(r, f, 2782295);
Files.WriteByte(r, (*225*)0E1X); (* ո *)
Files.Set(r, f, 2782296);
Files.WriteByte(r, (*235*)0EBX); (* ս *)
Files.Set(r, f, 2782297);
Files.WriteByte(r, (*229*)0E5X); (* պ *)
Files.Set(r, f, 2782298);
Files.WriteByte(r, 0); (* nothing *)
Files.Set(r, f, 1341611); (* fix latin h in word ահաւոր with armenian *)
Files.WriteByte(r, 0D1X);
(* fix "battery" translation, there should be not վիրարորանք but վիրավորանք *)
Files.Set(r, f, 5158573);
Files.WriteByte(r, 0EDX);
(* fix "shell" translation, should be not կեղեվ but կեղեւ *)
Files.Set(r, f, 4046995);
Files.WriteByte(r, 0F5X);
Files.Set(r, f, 4047026);
Files.WriteByte(r, 0F5X); (* նոյնից *)
(*
Files.Set(r, f, 2245510); (* fix "hello" translation at address 00224386H *)
Files.WriteByte(r, 0A2X); (* af is ՜ in armscii-8 *)
Files.Set(r, f, 5465087);
Files.WriteByte(r, 0A2X);
*)
END Fix;
PROCEDURE Go;
VAR f, fo : Files.File;
r, ro : Files.Rider;
ch : CHAR;
ord, i: INTEGER;
str : ArmsciiUTF.string;
last : BOOLEAN;
BEGIN
f := Files.Old(maindat);
IF f # NIL THEN
Fix(r, f);
Files.Set(r, f, 0);
fo := Files.New(outtxt);
IF fo # NIL THEN
Files.Set(ro, fo, 0);
last := FALSE;
WHILE ~ r.eof DO
(* expecting zeros *)
REPEAT
Files.Read(r, ch);
ord := ORD(ch);
UNTIL (ord # 0) OR r.eof;
IF ~r.eof THEN
WriteChar(ro, ch);
(* expecting English word *)
REPEAT
Files.Read(r, ch);
ord := ORD(ch);
IF ord # 0 THEN
WriteChar(ro, ch);
END;
UNTIL ord = 0;
WriteChar(ro, 9X); (* write tab *)
(* expecting zeros *)
REPEAT
Files.Read(r, ch);
ord := ORD(ch);
UNTIL ord >= 162;
(* expecting Armenian *)
REPEAT
IF ord < 162 THEN
WriteChar(ro, ch);
ELSE
str := ArmsciiUTF.A2U(ch);
WriteString(ro, str);
END;
IF ord = 44 (* comma *) THEN
Files.Read(r, ch);
ord := ORD(ch);
IF ord # 0 THEN
IF ch # ' ' THEN
WriteChar(ro, ' ');
ord := ORD(ch);
IF ord >= 162 THEN
str := ArmsciiUTF.A2U(ch);
WriteString(ro, str)
ELSE
WriteChar(ro, ch);
END
ELSE
WriteChar(ro, ' ');
END
END
END;
IF ord # 0 THEN
Files.Read(r, ch);
ord := ORD(ch);
END;
IF ord = 0 THEN (* skip everything before three zeros *)
i := 0;
REPEAT
Files.Read(r, ch);
ord := ORD(ch);
IF ord = 0 THEN INC(i) ELSE IF i >0 THEN DEC(i) END END;
UNTIL i = 10;
END
UNTIL ord = 0;
WriteChar(ro, 0AX);
END;
END;
WriteChar(ro, 0AX);
WriteChar(ro, 0AX);
Files.Register(fo);
ELSE
Out.String(outtxt); Out.String("cannot be created, check permissions"); Out.Ln
END
ELSE
Out.String(maindat); Out.String (" not found in current directory"); Out.Ln
END
END Go;
BEGIN
Go;
END armdictohack.