mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-16 18:39:19 +02:00
* Fix bug #30869, introduce CheckIndex in TStringList
git-svn-id: trunk@34817 -
This commit is contained in:
parent
a27b07b342
commit
9926d37dda
@ -763,6 +763,7 @@ type
|
|||||||
procedure SetCaseSensitive(b : boolean);
|
procedure SetCaseSensitive(b : boolean);
|
||||||
procedure SetSortStyle(AValue: TStringsSortStyle);
|
procedure SetSortStyle(AValue: TStringsSortStyle);
|
||||||
protected
|
protected
|
||||||
|
Procedure CheckIndex(AIndex : Integer); inline;
|
||||||
procedure ExchangeItems(Index1, Index2: Integer); virtual;
|
procedure ExchangeItems(Index1, Index2: Integer); virtual;
|
||||||
procedure Changed; virtual;
|
procedure Changed; virtual;
|
||||||
procedure Changing; virtual;
|
procedure Changing; virtual;
|
||||||
|
@ -1358,8 +1358,7 @@ end;
|
|||||||
function TStringList.Get(Index: Integer): string;
|
function TStringList.Get(Index: Integer): string;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
If (Index<0) or (INdex>=Fcount) then
|
CheckIndex(Index);
|
||||||
Error (SListIndexError,Index);
|
|
||||||
Result:=Flist^[Index].FString;
|
Result:=Flist^[Index].FString;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1384,8 +1383,7 @@ end;
|
|||||||
function TStringList.GetObject(Index: Integer): TObject;
|
function TStringList.GetObject(Index: Integer): TObject;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
If (Index<0) or (INdex>=Fcount) then
|
CheckIndex(Index);
|
||||||
Error (SListIndexError,Index);
|
|
||||||
Result:=Flist^[Index].FObject;
|
Result:=Flist^[Index].FObject;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1396,8 +1394,7 @@ procedure TStringList.Put(Index: Integer; const S: string);
|
|||||||
begin
|
begin
|
||||||
If Sorted then
|
If Sorted then
|
||||||
Error(SSortedListError,0);
|
Error(SSortedListError,0);
|
||||||
If (Index<0) or (INdex>=Fcount) then
|
CheckIndex(Index);
|
||||||
Error (SListIndexError,Index);
|
|
||||||
Changing;
|
Changing;
|
||||||
Flist^[Index].FString:=S;
|
Flist^[Index].FString:=S;
|
||||||
Changed;
|
Changed;
|
||||||
@ -1408,8 +1405,7 @@ end;
|
|||||||
procedure TStringList.PutObject(Index: Integer; AObject: TObject);
|
procedure TStringList.PutObject(Index: Integer; AObject: TObject);
|
||||||
|
|
||||||
begin
|
begin
|
||||||
If (Index<0) or (INdex>=Fcount) then
|
CheckIndex(Index);
|
||||||
Error (SListIndexError,Index);
|
|
||||||
Changing;
|
Changing;
|
||||||
Flist^[Index].FObject:=AObject;
|
Flist^[Index].FObject:=AObject;
|
||||||
Changed;
|
Changed;
|
||||||
@ -1508,8 +1504,7 @@ end;
|
|||||||
procedure TStringList.Delete(Index: Integer);
|
procedure TStringList.Delete(Index: Integer);
|
||||||
|
|
||||||
begin
|
begin
|
||||||
If (Index<0) or (Index>=FCount) then
|
CheckIndex(Index);
|
||||||
Error(SlistINdexError,Index);
|
|
||||||
Changing;
|
Changing;
|
||||||
Flist^[Index].FString:='';
|
Flist^[Index].FString:='';
|
||||||
if FOwnsObjects then
|
if FOwnsObjects then
|
||||||
@ -1527,10 +1522,8 @@ end;
|
|||||||
procedure TStringList.Exchange(Index1, Index2: Integer);
|
procedure TStringList.Exchange(Index1, Index2: Integer);
|
||||||
|
|
||||||
begin
|
begin
|
||||||
If (Index1<0) or (Index1>=FCount) then
|
CheckIndex(Index1);
|
||||||
Error(SListIndexError,Index1);
|
CheckIndex(Index2);
|
||||||
If (Index2<0) or (Index2>=FCount) then
|
|
||||||
Error(SListIndexError,Index2);
|
|
||||||
Changing;
|
Changing;
|
||||||
ExchangeItemsInt(Index1,Index2);
|
ExchangeItemsInt(Index1,Index2);
|
||||||
changed;
|
changed;
|
||||||
@ -1561,6 +1554,12 @@ begin
|
|||||||
FSortStyle:=AValue;
|
FSortStyle:=AValue;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TStringList.CheckIndex(AIndex: Integer);
|
||||||
|
begin
|
||||||
|
If (AIndex<0) or (AIndex>=FCount) then
|
||||||
|
Error(SListIndexError,AIndex);
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
function TStringList.DoCompareText(const s1, s2: string): PtrInt;
|
function TStringList.DoCompareText(const s1, s2: string): PtrInt;
|
||||||
begin
|
begin
|
||||||
@ -1629,10 +1628,10 @@ begin
|
|||||||
If SortStyle=sslAuto then
|
If SortStyle=sslAuto then
|
||||||
Error (SSortedListError,0)
|
Error (SSortedListError,0)
|
||||||
else
|
else
|
||||||
If (Index<0) or (Index>FCount) then
|
begin
|
||||||
Error (SListIndexError,Index)
|
CheckIndex(Index);
|
||||||
else
|
InsertItem (Index,S);
|
||||||
InsertItem (Index,S);
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user