mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-14 09:49:35 +02:00
+ Fixed sorting of stringslist
This commit is contained in:
parent
3e4f02f165
commit
be33e69df4
@ -89,11 +89,22 @@ end;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
Procedure TStrings.ReadData(Reader: TReader);
|
procedure TStrings.ReadData(Reader: TReader);
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
Reader.ReadListBegin;
|
||||||
|
BeginUpdate;
|
||||||
|
try
|
||||||
|
Clear;
|
||||||
|
while not Reader.EndOfList do
|
||||||
|
Add(Reader.ReadString);
|
||||||
|
finally
|
||||||
|
EndUpdate;
|
||||||
|
end;
|
||||||
|
Reader.ReadListEnd;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Function GetQuotedString (Var P : Pchar) : AnsiString;
|
Function GetQuotedString (Var P : Pchar) : AnsiString;
|
||||||
|
|
||||||
Var P1,L : Pchar;
|
Var P1,L : Pchar;
|
||||||
@ -189,16 +200,31 @@ end;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
Procedure TStrings.WriteData(Writer: TWriter);
|
procedure TStrings.WriteData(Writer: TWriter);
|
||||||
|
var
|
||||||
|
i: Integer;
|
||||||
begin
|
begin
|
||||||
|
Writer.WriteListBegin;
|
||||||
|
for i := 0 to Count - 1 do
|
||||||
|
Writer.WriteString(Strings[i]);
|
||||||
|
Writer.WriteListEnd;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Procedure TStrings.DefineProperties(Filer: TFiler);
|
procedure TStrings.DefineProperties(Filer: TFiler);
|
||||||
|
var
|
||||||
|
HasData: Boolean;
|
||||||
begin
|
begin
|
||||||
|
if Assigned(Filer.Ancestor) then
|
||||||
|
// Only serialize if string list is different from ancestor
|
||||||
|
if Filer.Ancestor.InheritsFrom(TStrings) then
|
||||||
|
HasData := not Equals(TStrings(Filer.Ancestor))
|
||||||
|
else
|
||||||
|
HasData := True
|
||||||
|
else
|
||||||
|
HasData := Count > 0;
|
||||||
|
Filer.DefineProperty('Strings', @ReadData, @WriteData, HasData);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -646,7 +672,7 @@ Procedure TStringList.QuickSort(L, R: Integer; CompareFn: TStringListSortCompare
|
|||||||
Var I,J, Pivot : Longint;
|
Var I,J, Pivot : Longint;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
Repeat;
|
Repeat
|
||||||
I:=L;
|
I:=L;
|
||||||
J:=R;
|
J:=R;
|
||||||
Pivot:=(L+R) div 2;
|
Pivot:=(L+R) div 2;
|
||||||
@ -656,6 +682,10 @@ begin
|
|||||||
If I<=J then
|
If I<=J then
|
||||||
begin
|
begin
|
||||||
ExchangeItems(I,J); // No check, indices are correct.
|
ExchangeItems(I,J); // No check, indices are correct.
|
||||||
|
if Pivot=I then
|
||||||
|
Pivot:=J
|
||||||
|
else if Pivot=J then
|
||||||
|
Pivot := I;
|
||||||
Inc(I);
|
Inc(I);
|
||||||
Dec(j);
|
Dec(j);
|
||||||
end;
|
end;
|
||||||
@ -889,7 +919,7 @@ begin
|
|||||||
If (Index1<0) or (Index1>=FCount) then
|
If (Index1<0) or (Index1>=FCount) then
|
||||||
Error(SListIndexError,Index1);
|
Error(SListIndexError,Index1);
|
||||||
If (Index2<0) or (Index2>=FCount) then
|
If (Index2<0) or (Index2>=FCount) then
|
||||||
Error(SListIndexError,Index1);
|
Error(SListIndexError,Index2);
|
||||||
Changing;
|
Changing;
|
||||||
ExchangeItems(Index1,Index2);
|
ExchangeItems(Index1,Index2);
|
||||||
changed;
|
changed;
|
||||||
@ -969,7 +999,7 @@ function StringListAnsiCompare(List: TStringList; Index1, Index: Integer): Integ
|
|||||||
|
|
||||||
begin
|
begin
|
||||||
Result := AnsiCompareText(List.FList^[Index1].FString,
|
Result := AnsiCompareText(List.FList^[Index1].FString,
|
||||||
List.FList^[Index1].FString);
|
List.FList^[Index].FString);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Procedure TStringList.Sort;
|
Procedure TStringList.Sort;
|
||||||
@ -980,7 +1010,10 @@ end;
|
|||||||
|
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.6 2000-12-03 22:35:09 sg
|
Revision 1.7 2001-02-23 22:24:08 michael
|
||||||
|
+ Fixed sorting of stringslist
|
||||||
|
|
||||||
|
Revision 1.6 2000/12/03 22:35:09 sg
|
||||||
* Applied patch by Markus Kaemmerer (merged):
|
* Applied patch by Markus Kaemmerer (merged):
|
||||||
- Added support for TStringList.CustomSort
|
- Added support for TStringList.CustomSort
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user