Boyer-Moore string search: Difference between revisions
m
→{{header|Pascal}}: cosmetic
(added Pascal example) |
m (→{{header|Pascal}}: cosmetic) |
||
Line 581:
var
Needle: rawbytestring;
const▼
begin
if aPattern <> '' then begin
Line 593 ⟶ 591:
Result := function(const aHaystack: rawbytestring): TIntArray
var
pNeedle: PByte absolute Needle;
pHaystack: PByte absolute aHaystack;
I, J, NeedleLast,
▲ const
OutInitLen = 4;
begin
if (Needle = '') or (Length(aHaystack) < Length(Needle)) then exit
SetLength(
NeedleLast := Pred(Length(Needle));
I := NeedleLast;
Line 611 ⟶ 610:
end;
if J < OldPfxEnd then begin
if
Inc(
Inc(I, Succ(GsTable[0] - OldPfxEnd));
OldPfxEnd := Length(Needle)*2 - GsTable[0];
Line 621 ⟶ 620:
end;
end;
SetLength(
end;
end;
|