I tried to convert FF2 and was partially successful but met with the following difficulty regarding (IN FPC 2.6.4) the pred(SomeWordVar) that is not evaluated the same in DELPHI and FPC 2.6.4.
The following program illustrates the problem
program project_pred;
{ Same program for BDS2006 and FPC 2.6.4}
{$ifdef FPC}
{$mode DELPHI}
{$else}
{$APPTYPE CONSOLE}
{$endif FPC}
var
ix: integer;
// ixEnd: CARDINAL; // <-Ok
ixEnd: word; // <-unsigned causing some trouble in for...loops
begin
ixEnd := 0;
writeln('Pred(ixEnd)=',Pred(ixEnd)); // FPC 2.6.4=65535<>BDS2006=-1
writeln('for ix:=0 to Pred(ixEnd) do ...');
for ix := 0 to Pred(ixEnd) do begin // Delphi wont enter for...loop but FPC will
writeln(ix); // loop to 65535
if ix > ixEnd then // avoid too many iteration
break;
end;
writeln;
writeln('for ix:=0 to ixEnd-1 do ...');
for ix := 0 to ixEnd - 1 do begin // <-- probably FPC casts ixEnd-1 to an Integer
writeln(ix); // prior to testing the end loop condition
if ix > ixEnd then
break;
end;
writeln;
writeln('Finished, hit enter');
readln;
end.
Output for FPC and DBS2006 :
FPC 2.6.4
Pred(ixEnd)=65535
for ix:=0 to Pred(ixEnd) do ...
0
1
for ix:=0 to ixEnd-1 do ...
Finished, hit enter
BDS 2006
Pred(ixEnd)=-1
for ix:=0 to Pred(ixEnd) do ...
for ix:=0 to ixEnd-1 do ...
Finished, hit enter
What are your results for that simple program and what version of FPC do you use ?
This has influence on iterations on many arrays in FlashFiler where indexes overflows, for example in
procedure TffDataDictionary.BindIndexHelpers;
IndexCount is a Word and if it is equal to 0 you'll have an overflow. In some other cases, the WORD variable is assigned to a local integer prior to for loops, thus not showing this behavior.
If of any use I join my FF2_FPC.lrs file with the glyphs for the Lazarus 1.4.4 component pallette.
I found also (in DELPHI/FastMM4) that there are memory leaks when executing SQL from a client, some FF2 objects being not freed. Probably that would be solvable.