FIX: Bug [0001702] File comparison reports that files are identical when trailing bytes are different

This commit is contained in:
Alexander Koblov 2017-01-20 19:21:56 +00:00
commit 7d23d475b7
2 changed files with 16 additions and 5 deletions

View file

@ -811,7 +811,7 @@ begin
BinaryDiffIndex:= 0;
BinaryViewerLeft.Position:= PtrInt(BinaryDiffList[BinaryDiffIndex]);
if not actKeepScrolling.Checked then
BinaryViewerRight.Position:= BinaryViewerLeft.Position;
BinaryViewerRight.Position:= PtrInt(BinaryDiffList[BinaryDiffIndex]);
end;
end
else begin
@ -844,7 +844,7 @@ begin
BinaryDiffIndex:= BinaryDiffList.Count - 1;
BinaryViewerLeft.Position:= PtrInt(BinaryDiffList[BinaryDiffIndex]);
if not actKeepScrolling.Checked then
BinaryViewerRight.Position:= BinaryViewerLeft.Position;
BinaryViewerRight.Position:= PtrInt(BinaryDiffList[BinaryDiffIndex]);
end;
end
else begin
@ -878,7 +878,7 @@ begin
BinaryDiffIndex:= BinaryDiffIndex + 1;
BinaryViewerLeft.Position:= PtrInt(BinaryDiffList[BinaryDiffIndex]);
if not actKeepScrolling.Checked then
BinaryViewerRight.Position:= BinaryViewerLeft.Position;
BinaryViewerRight.Position:= PtrInt(BinaryDiffList[BinaryDiffIndex]);
end;
end
else begin
@ -917,7 +917,7 @@ begin
BinaryDiffIndex:= BinaryDiffIndex - 1;
BinaryViewerLeft.Position:= PtrInt(BinaryDiffList[BinaryDiffIndex]);
if not actKeepScrolling.Checked then
BinaryViewerRight.Position:= BinaryViewerLeft.Position;
BinaryViewerRight.Position:= PtrInt(BinaryDiffList[BinaryDiffIndex]);
end;
end
else begin

View file

@ -54,6 +54,7 @@ type
FFirst,
FSecond: PByte;
FFinish: PtrInt;
FEqual: Boolean;
FResult: TFPList;
FOnFinish: TThreadMethod;
protected
@ -198,9 +199,18 @@ begin
begin
if not CompareMem(FFirst + Position, FSecond + Position, Remain) then
begin
if Equal then FResult.Add(Pointer(Position));
if Equal then
begin
Equal:= False;
FResult.Add(Pointer(Position));
end;
end;
end;
// Different file size
if (FEqual = False) and (Equal = True) then
begin
FResult.Add(Pointer(Position + Remain))
end;
if Assigned(FOnFinish) then Synchronize(FOnFinish);
end;
@ -212,6 +222,7 @@ begin
FResult:= Result;
inherited Create(True);
FreeOnTerminate:= True;
FEqual:= (FirstSize = SecondSize);
FFinish:= Min(FirstSize, SecondSize);
end;