-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfixdoc.pp
More file actions
52 lines (51 loc) · 979 Bytes
/
fixdoc.pp
File metadata and controls
52 lines (51 loc) · 979 Bytes
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
program fixdoc;
var
t,f : text;
s,unitname : string;
i,j : longint;
begin
if paramcount<1 then
begin
writeln('usage: fixdoc <doc>');
halt(1);
end;
assign(t,paramstr(1));
{$I-}
reset(t);
{$I+}
if ioresult<>0 then
begin
writeln('can''t open ',paramstr(1));
halt(1);
end;
assign(f,'fixdoc.tmp');
rewrite(f);
while not eof(t) do
begin
readln(t,s);
i:=pos('The ',s);
j:=pos('unit',s);
if (i>0) and (j>0) and (j>i) then
begin
unitname:=Lowercase(Copy(s,i+4,j-i-5));
i:=pos('<A NAME="',s);
if i>0 then
begin
inc(i,9);
j:=i;
while (j<length(s)) and (s[j]<>'"') do
inc(j);
if s[j+1]=' ' then
begin
Delete(s,i,j-i);
Insert(unitname,s,i);
end;
end;
end;
writeln(f,s);
end;
close(f);
close(t);
erase(t);
rename(f,paramstr(1));
end.