mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-23 00:09:31 +02:00
* Patch from Bart B to improve Slice(). Fixes issue #41068
This commit is contained in:
parent
76e2ee9970
commit
73287c1fa8
@ -1048,8 +1048,10 @@ type
|
||||
procedure SaveToStream(Stream: TStream; IgnoreEncoding : Boolean); overload;
|
||||
procedure SaveToStream(Stream: TStream; AEncoding: TEncoding); overload; virtual;
|
||||
function Shift : String;
|
||||
Procedure Slice(fromIndex: integer; aList : TStrings);
|
||||
Function Slice(fromIndex: integer) : TStrings;
|
||||
Procedure Slice(fromIndex: integer; aList : TStrings); overload;
|
||||
Procedure Slice(fromIndex, toIndex: integer; aList : TStrings); overload;
|
||||
Function Slice(fromIndex: integer) : TStrings; overload;
|
||||
Function Slice(fromIndex, toIndex: integer) : TStrings; overload;
|
||||
procedure SetText(TheText: PChar); virtual;
|
||||
property AlwaysQuote: Boolean read FAlwaysQuote write FAlwaysQuote;
|
||||
property Capacity: Integer read GetCapacity write SetCapacity;
|
||||
|
@ -430,28 +430,42 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
Procedure TStrings.Slice(fromIndex: integer; aList : TStrings);
|
||||
Procedure TStrings.Slice(fromIndex, toIndex: integer; aList : TStrings);
|
||||
|
||||
var
|
||||
i: integer;
|
||||
|
||||
begin
|
||||
for i:=fromIndex to Count-1 do
|
||||
for i:=fromIndex to toIndex do
|
||||
aList.Add(Self[i]);
|
||||
end;
|
||||
|
||||
Function TStrings.Slice(fromIndex: integer) : TStrings;
|
||||
|
||||
Procedure TStrings.Slice(fromIndex: integer; aList : TStrings);
|
||||
|
||||
begin
|
||||
Slice(fromIndex,Count-1,aList);
|
||||
end;
|
||||
|
||||
Function TStrings.Slice(fromIndex, toIndex: integer) : TStrings;
|
||||
|
||||
begin
|
||||
Result:=TStringsClass(Self.ClassType).Create;
|
||||
try
|
||||
Slice(FromIndex,Result);
|
||||
Slice(FromIndex, toIndex,Result);
|
||||
except
|
||||
FreeAndNil(Result);
|
||||
Raise;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
Function TStrings.Slice(fromIndex: integer) : TStrings;
|
||||
|
||||
begin
|
||||
Result := Slice(fromIndex,Count-1);
|
||||
end;
|
||||
|
||||
function TStrings.GetName(Index: Integer): string;
|
||||
|
||||
Var
|
||||
|
Loading…
Reference in New Issue
Block a user