Re: [fpc-devel] Fwd: bug report

2005-06-01 Thread Gerhard Scholz
I tried this example, but it does compile! No problem!

- Original Message -
From: 
To: fpc bug
Sent: Saturday, May 21, 2005 4:10 AM
Subject: [fpc-devel] Fwd: bug report


fpc 2.0.0 win32


problem:
  I can't see pi in proceudre pre but I can see it in procedure kmp.
  pre is a procedure belonging to kmp.
  I found that I could only see  vars in this proceudre/function and main
program, but I couldn't see vars in the procedure that this procedure
belongs to.

code:

var
  t,p:string;
procedure kmp(t,p:string);
  var
n,m,q,i:integer;
pi,match:array[1..255] of integer;
  procedure pre(p:string);
var
  k,q:integer;
begin
  pi[1]:=0;
  k:=0;
  for q:=2 to m do begin
while (k0) and (p[k+1]p[q]) do k:=pi[k];
if p[k+1]=p[q] then k:=k+1;
pi[q]:=k;
  end;
end;
  begin
n:=length(t);
m:=length(p);
q:=0;
pre(p);
fillchar(match,sizeof(match),0);
for i:=1 to n do begin
  while (q0) and (p[q+1]t[i]) do begin
match[i-q]:=q;
q:=pi[q];
  end;
  if p[q+1]=t[i] then q:=q+1;
  if q=m then begin
match[i-q+1]:=q;
q:=pi[q];
  end;
end;
write(match[1]);
for i:=2 to n do write(' ',match[i]);
writeln;
  end;
begin
  readln(t);
  readln(p);
  kmp(t,p);
end.


[EMAIL PROTECTED]





Do You Yahoo!?
150MP3

1G1000



___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


[fpc-devel] Fwd: bug report

2005-05-29 Thread 杨哲

fpc 2.0.0 win32
problem:
 I can't see pi in proceudre pre but I can see it in procedure kmp.
 pre is a procedure belongingto kmp.
 I found that I could only seevars in this proceudre/function and main program, but I couldn't see vars in the procedure that this procedure belongs to.

code:

var t,p:string;procedure kmp(t,p:string); var n,m,q,i:integer; pi,match:array[1..255] of integer; procedure pre(p:string); var k,q:integer; begin pi[1]:=0; k:=0; for q:=2 to m do begin while (k0) and (p[k+1]p[q]) do k:=pi[k]; if p[k+1]=p[q] then k:=k+1; pi[q]:=k; end; end; begin n:=length(t); m:=length(p); q:=0; pre(p); fillchar(match,sizeof(match),0); for i:=1 to n do
 begin while (q0) and (p[q+1]t[i]) do begin match[i-q]:=q; q:=pi[q]; end; if p[q+1]=t[i] then q:=q+1; if q=m then begin match[i-q+1]:=q; q:=pi[q]; end; end; write(match[1]); for i:=2 to n do write(' ',match[i]); writeln; end;begin readln(t); readln(p); kmp(t,p);end.[EMAIL PROTECTED]Do You Yahoo!?
150MP3
1G1000___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel