mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-12-05 16:17:18 +01:00
LazUtils: Fix compilation with FPC 3.0.4. Add functions StartsStr and EndsStr.
git-svn-id: trunk@64514 -
This commit is contained in:
parent
a693251026
commit
db235fb49a
@ -37,6 +37,10 @@ type
|
||||
const
|
||||
EndOfLine: shortstring = LineEnding;
|
||||
|
||||
{$IF FPC_FULLVERSION=30004}
|
||||
function StartsStr(const ASubText, AText: string): Boolean;
|
||||
function EndsStr(const ASubText, AText: string): Boolean;
|
||||
{$ENDIF}
|
||||
function PosI(const SubStr, S: string): integer;
|
||||
function LazStartsText(const ASubText, AText: string): Boolean;
|
||||
function LazEndsText(const ASubText, AText: string): Boolean;
|
||||
@ -114,6 +118,25 @@ const
|
||||
|
||||
implementation
|
||||
|
||||
{$IF FPC_FULLVERSION=30004} // Is found in versions > 3.0.4
|
||||
function StartsStr(const ASubText, AText: string): Boolean;
|
||||
begin
|
||||
if (Length(AText) >= Length(ASubText)) and (ASubText <> '') then
|
||||
Result := StrLComp(PChar(ASubText), PChar(AText), Length(ASubText)) = 0
|
||||
else
|
||||
Result := False;
|
||||
end;
|
||||
|
||||
function EndsStr(const ASubText, AText: string): Boolean;
|
||||
begin
|
||||
if Length(AText) >= Length(ASubText) then
|
||||
Result := StrLComp(PChar(ASubText),
|
||||
PChar(AText) + Length(AText) - Length(ASubText), Length(ASubText)) = 0
|
||||
else
|
||||
Result := False;
|
||||
end;
|
||||
{$ENDIF}
|
||||
|
||||
function PosI(const SubStr, S: string): integer;
|
||||
// A case-insensitive version of Pos().
|
||||
// Note: StrUtils has ContainsText but its implementation is VERY slow.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user