[Oberon] Degeneration via proprietry software
Chris Burrows
chris at cfbsoftware.com
Tue Jan 3 08:29:08 CET 2012
>-----Original Message-----
>From: Chris Glur [mailto:easlab at absamail.co.za]
>Sent: Tuesday, 3 January 2012 10:30 AM
>To: oberon at lists.inf.ethz.ch
>Cc: crglur at gmail.com
>Subject: [Oberon] Degeneration via proprietry software
>
...
...
...
>Pasting the code verbatim:--
>VAR tF: TextFrames.Frame;
>....
> Texts.OpenReader(R, text, beg); <-read
>the selected pattern into sPat[i]
> i := 0; pos := beg;
> REPEAT Texts.Read(R, sPat[i]); INC(i);
>INC(pos) UNTIL (i = MaxPatLen) OR (pos = end);
> sPatLen := i; CalcDispVec(time) (*
>calculate displacement vector *) <-what's this?!
> END;
> IF tF.car > 0 THEN pos := tF.carloc.pos ELSE
>pos := 0 END;
> IF SPatFound(tF, tF.text, pos) THEN MarkPatPos(tF, pos)
>-----
> PROCEDURE CalcDispVec(time: LONGINT);
> VAR i, j, d: INTEGER;
> BEGIN
> lTime := time;
> i := 1; d := 1; (* calculate displacement vector *)
> WHILE i <= sPatLen DO
> j := 0; WHILE (j + d < sPatLen) &
>(sPat[j] = sPat[j + d]) DO INC(j) END;
> WHILE i <= j + d DO sDv[i] := d; INC(i) END;
> INC(d)
> END
> END CalcDispVec;
>-----
>
>Can someone point me to an explanation of this algorithm?
>
Just guessing, but it reminds me of the Boyer-Moore fast string search
algorithm. The time parameter is probably just a remnant from some
performance checking runs.
Regards,
Chris
Chris Burrows
Astrobe v4: ARM Oberon Development for Embedded Systems
http://www.astrobe.com
More information about the Oberon
mailing list