|
@@ -937,10 +937,34 @@ begin
|
|
|
end;
|
|
|
|
|
|
|
|
|
-function TStringHelper.LastIndexOf(const AValue: string; AStartIndex: Integer;
|
|
|
- ACount: Integer): Integer;
|
|
|
+function TStringHelper.LastIndexOf(const AValue: string; AStartIndex: Integer; ACount: Integer): Integer;
|
|
|
+
|
|
|
+var
|
|
|
+ I,L,LS,M : Integer;
|
|
|
+ S : String;
|
|
|
+ P : PChar;
|
|
|
+
|
|
|
begin
|
|
|
- Result:=LastIndexOf(AValue,AStartIndex,AStartIndex+1);
|
|
|
+ Result:=-1;
|
|
|
+ LS:=system.Length(Self);
|
|
|
+ L:=system.Length(AValue);
|
|
|
+ if (L=0) or (L>LS) then
|
|
|
+ Exit;
|
|
|
+ P:=PChar(AValue);
|
|
|
+ S:=Self;
|
|
|
+ I:=AStartIndex+1; // 1 based
|
|
|
+ if (I>LS) then
|
|
|
+ I:=LS;
|
|
|
+ I:=I-L+1;
|
|
|
+ M:=AStartIndex-ACount+1; // 1 based
|
|
|
+ if M<1 then
|
|
|
+ M:=1;
|
|
|
+ while (Result=-1) and (I>=M) do
|
|
|
+ begin
|
|
|
+ if (0=StrLComp(PChar(@S[I]),P,L)) then
|
|
|
+ Result:=I-1;
|
|
|
+ Dec(I);
|
|
|
+ end;
|
|
|
end;
|
|
|
|
|
|
|