Recent

Author Topic: Range Check Error in SynEditMarks.CompareSynEditMarks  (Read 7943 times)

Pascal

  • Hero Member
  • *****
  • Posts: 932
Re: Range Check Error in SynEditMarks.CompareSynEditMarks
« Reply #15 on: June 26, 2017, 11:08:27 am »
Well what you try to measure is distance.
No, it's a compare function and if all aspects of the types are identical a "fallback" is to compare the pointers directly.

Code: Pascal  [Select][+][-]
  1. function CompareSynEditMarks(Mark1, Mark2: Pointer): Integer;
  2. var
  3.   m1: TSynEditMark absolute Mark1;
  4.   m2: TSynEditMark absolute Mark2;
  5. begin
  6.   case m1.MarkLine.FCurrentSort1 of
  7.     smsoColumn:        Result := m2.Column - m1.Column;
  8.     smsoPriority:      Result := m2.Priority - m1.Priority;
  9.     smsoBookmarkFirst:
  10.       if (m1.IsBookmark) and (not m2.IsBookmark) then Result := -1
  11.       else if (not m1.IsBookmark) and (m2.IsBookmark) then Result := 1
  12.       else Result := 0;
  13.     smsoBookMarkLast:
  14.       if (m1.IsBookmark) and (not m2.IsBookmark) then Result := 1
  15.       else if (not m1.IsBookmark) and (m2.IsBookmark) then Result := -1
  16.       else Result := 0;
  17.     else
  18.       Result := 0;
  19.   end;
  20.   if Result <> 0 then
  21.     exit;
  22.  
  23.   case m1.MarkLine.FCurrentSort2 of
  24.     smsoColumn:        Result := m2.Column - m1.Column;
  25.     smsoPriority:      Result := m2.Priority - m1.Priority;
  26.     smsoBookmarkFirst:
  27.       if (m1.IsBookmark) and (not m2.IsBookmark) then Result := -1
  28.       else if (not m1.IsBookmark) and (m2.IsBookmark) then Result := 1
  29.       else Result := 0;
  30.     smsoBookMarkLast:
  31.       if (m1.IsBookmark) and (not m2.IsBookmark) then Result := 1
  32.       else if (not m1.IsBookmark) and (m2.IsBookmark) then Result := -1
  33.       else Result := 0;
  34.     else
  35.       Result := 0;
  36.   end;
  37.   if Result <> 0 then
  38.     exit;
  39.  
  40.   Result := m2.Column - m1.Column;
  41.   if Result <> 0 then
  42.     exit;
  43.  
  44.   Result := m2.Priority - m1.Priority;
  45.   if Result <> 0 then
  46.     exit;
  47.  
  48.   Result := PtrInt(m2) - PtrInt(m1); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  49. end;
  50.  
laz trunk x64 - fpc trunk i386 (cross x64) - Windows 10 Pro x64 (21H2)

 

TinyPortal © 2005-2018