]> mj.ucw.cz Git - misc.git/blob - censor.p
Added xclipcat.
[misc.git] / censor.p
1 program censor;
2
3 var w0,s01,w1,s12,w2,s23:string[255];
4     c:char;
5
6 procedure shift;
7 var i,j,k:integer;
8     t:string[255];
9 begin
10    t:=w1;
11    for i:=1 to length(t) do
12       if t[i]='o' then begin
13          if w0='' then
14             j:=length(w2)
15          else if (w2='') or (length(w0)<length(w2)) then
16             j:=length(w0)
17          else
18             j:=length(w2);
19          for k:=0 to j do begin
20             if k<i then w1[i-k]:='*'
21             else if w0<>'' then w0[length(w0)-(k-i)]:='*';
22             if k<=length(w1)-i then w1[i+k]:='*'
23             else if w2<>'' then w2[k-(length(w1)-i)]:='*';
24          end;
25       end;
26    write(w0);
27    for i:=1 to length(s01) do
28       if s01[i]='n' then writeln
29                     else write(s01[i]);
30    w0:=w1; s01:=s12; w1:=w2; s12:=s23;
31    w2:=''; s23:='';
32 end;
33
34 begin
35    w0:=''; s01:=''; w1:=''; s12:=''; w2:=''; s23:='';
36    while not eof(input) do begin
37       if eoln(input) then begin
38          readln;
39          s23:=s23+'n';
40       end else begin
41          read(c);
42          if (c >= 'a') and (c <= 'z') or (c >= 'A') and (c <= 'Z') then begin
43             if s23<>'' then shift;
44             w2 := w2+c;
45          end else
46             s23 := s23+c;
47       end;
48    end;
49    shift; shift; shift;
50 end.