mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-07 22:58:14 +02:00
LCL-GTK2: Move function ComparePChar to LazStringUtils as SamePChar.
git-svn-id: trunk@62464 -
This commit is contained in:
parent
a6e4bb8d92
commit
ec99bd95e2
@ -93,7 +93,10 @@ function SwapCase(Const S: String): String;
|
||||
function StringCase(const AString: String; const ACase: array of String {; const AIgnoreCase = False, APartial = false: Boolean}): Integer; overload;
|
||||
function StringCase(const AString: String; const ACase: array of String; const AIgnoreCase, APartial: Boolean): Integer; overload;
|
||||
|
||||
// Test over a string
|
||||
// PChar
|
||||
function SamePChar(P1, P2: PChar): boolean;
|
||||
|
||||
// Like IsValidIdent() in FPC 3.1.
|
||||
function LazIsValidIdent(const Ident: string; AllowDots: Boolean = False;
|
||||
StrictDots: Boolean = False): Boolean;
|
||||
|
||||
@ -1238,6 +1241,20 @@ begin
|
||||
Result := -1;
|
||||
end;
|
||||
|
||||
function SamePChar(P1, P2: PChar): boolean;
|
||||
// Return True if P1 and P2 have the same contents.
|
||||
begin
|
||||
if (P1=P2) then Exit(True);
|
||||
if (P1=nil) or (P2=nil) then Exit(False);
|
||||
while P1^=P2^ do
|
||||
begin
|
||||
if P1^=#0 then Exit(True);
|
||||
inc(P1);
|
||||
inc(P2);
|
||||
end;
|
||||
Result:=False;
|
||||
end;
|
||||
|
||||
function LazIsValidIdent(const Ident: string; AllowDots: Boolean = False;
|
||||
StrictDots: Boolean = False): Boolean;
|
||||
// This is a copy of IsValidIdent from FPC 3.1.
|
||||
|
@ -293,44 +293,14 @@ end;
|
||||
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
function CreatePChar(const s: string): PChar;
|
||||
|
||||
Allocates a new PChar
|
||||
------------------------------------------------------------------------------}
|
||||
------------------------------------------------------------------------------
|
||||
function CreatePChar(const s: string): PChar;
|
||||
begin
|
||||
Result:=StrAlloc(length(s) + 1);
|
||||
StrPCopy(Result, s);
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
function ComparePChar(P1, P2: PChar): boolean;
|
||||
|
||||
Checks if P1 and P2 have the same content.
|
||||
------------------------------------------------------------------------------}
|
||||
function ComparePChar(P1, P2: PChar): boolean;
|
||||
begin
|
||||
if (P1<>P2) then begin
|
||||
if (P1<>nil) and (P2<>nil) then begin
|
||||
while (P1^=P2^) do begin
|
||||
if P1^<>#0 then begin
|
||||
inc(P1);
|
||||
inc(P2);
|
||||
end else begin
|
||||
Result:=true;
|
||||
exit;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
Result:=false;
|
||||
end else begin
|
||||
Result:=true;
|
||||
end;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
function FindChar(c: char; p:PChar; Max: integer): integer;
|
||||
------------------------------------------------------------------------------}
|
||||
}
|
||||
function FindChar(c: char; p:PChar; Max: integer): integer;
|
||||
begin
|
||||
Result:=0;
|
||||
@ -4973,7 +4943,7 @@ end;
|
||||
function DesignSignalNameToType(Name: PChar; After: boolean): TDesignSignalType;
|
||||
begin
|
||||
for Result:=Low(TDesignSignalType) to High(TDesignSignalType) do
|
||||
if ComparePChar(DesignSignalNames[Result],Name)
|
||||
if SamePChar(DesignSignalNames[Result],Name)
|
||||
and (DesignSignalAfter[Result]=After) then exit;
|
||||
Result:=dstUnknown;
|
||||
end;
|
||||
|
@ -47,9 +47,10 @@ uses
|
||||
glib, gdk, gtk, gdkpixbuf,
|
||||
{$ENDIF}
|
||||
Math, // Math after gtk to get the correct Float type
|
||||
LazUTF8, LMessages, LCLMessageGlue, LCLProc, LCLStrConsts, LCLIntf, LCLType,
|
||||
DynHashArray, Masks, GraphType, GraphMath, Graphics, Controls, Forms, Menus,
|
||||
StdCtrls, ComCtrls, ExtCtrls, Dialogs, ExtDlgs, FileUtil, LazFileUtils,
|
||||
Masks, LazUTF8, FileUtil, LazFileUtils, LazStringUtils, DynHashArray,
|
||||
LMessages, LCLMessageGlue, LCLProc, LCLStrConsts, LCLIntf, LCLType,
|
||||
GraphType, GraphMath, Graphics, Controls, Forms, Menus,
|
||||
StdCtrls, ComCtrls, ExtCtrls, Dialogs, ExtDlgs,
|
||||
ImgList, GtkFontCache, GTKGlobals, GtkDef, GtkExtra, GtkDebug;
|
||||
|
||||
const
|
||||
@ -301,7 +302,6 @@ procedure BeginGDKErrorTrap;
|
||||
procedure EndGDKErrorTrap;
|
||||
function dbgGRect(const ARect: PGDKRectangle): string; overload;
|
||||
|
||||
|
||||
// gtk resources
|
||||
procedure Set_RC_Name(Sender: TObject; AWidget: PGtkWidget);
|
||||
|
||||
@ -310,8 +310,7 @@ function DeliverPostMessage(const Target: Pointer; var TheMessage): GBoolean;
|
||||
function DeliverMessage(const Target: Pointer; var AMessage): PtrInt;
|
||||
|
||||
// PChar
|
||||
function CreatePChar(const s: string): PChar;
|
||||
function ComparePChar(P1, P2: PChar): boolean;
|
||||
//function CreatePChar(const s: string): PChar;
|
||||
function FindChar(c: char; p:PChar; Max: integer): integer;
|
||||
function FindLineLen(p:PChar; Max: integer): integer;
|
||||
|
||||
|
@ -269,69 +269,33 @@ end;
|
||||
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
function CreatePChar(const s: string): PChar;
|
||||
|
||||
Allocates a new PChar
|
||||
------------------------------------------------------------------------------}
|
||||
------------------------------------------------------------------------------
|
||||
function CreatePChar(const s: string): PChar;
|
||||
begin
|
||||
Result:=StrAlloc(length(s) + 1);
|
||||
StrPCopy(Result, s);
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
function ComparePChar(P1, P2: PChar): boolean;
|
||||
|
||||
Checks if P1 and P2 have the same content.
|
||||
------------------------------------------------------------------------------}
|
||||
function ComparePChar(P1, P2: PChar): boolean;
|
||||
begin
|
||||
if (P1<>P2) then begin
|
||||
if (P1<>nil) and (P2<>nil) then begin
|
||||
while (P1^=P2^) do begin
|
||||
if P1^<>#0 then begin
|
||||
inc(P1);
|
||||
inc(P2);
|
||||
end else begin
|
||||
Result:=true;
|
||||
exit;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
Result:=false;
|
||||
end else begin
|
||||
Result:=true;
|
||||
end;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
function FindChar(c: char; p:PChar; Max: integer): integer;
|
||||
------------------------------------------------------------------------------}
|
||||
}
|
||||
function FindChar(c: char; p:PChar; Max: integer): integer;
|
||||
begin
|
||||
Result:=0;
|
||||
while (Result<Max) do begin
|
||||
if p[Result]<>c then
|
||||
inc(Result)
|
||||
else
|
||||
exit;
|
||||
while Result<Max do begin
|
||||
if p[Result]=c then exit;
|
||||
inc(Result);
|
||||
end;
|
||||
Result:=-1;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
function FindLineLen(p: PChar; Max: integer): integer;
|
||||
|
||||
Find line end
|
||||
------------------------------------------------------------------------------}
|
||||
function FindLineLen(p: PChar; Max: integer): integer;
|
||||
begin
|
||||
Result:=0;
|
||||
while (Result<Max) do begin
|
||||
if not (p[Result] in [#10,#13]) then
|
||||
inc(Result)
|
||||
else
|
||||
exit;
|
||||
while Result<Max do begin
|
||||
if p[Result] in [#10,#13] then exit;
|
||||
inc(Result);
|
||||
end;
|
||||
Result:=-1;
|
||||
end;
|
||||
@ -4987,7 +4951,7 @@ end;
|
||||
function DesignSignalNameToType(Name: PChar; After: boolean): TDesignSignalType;
|
||||
begin
|
||||
for Result:=Low(TDesignSignalType) to High(TDesignSignalType) do
|
||||
if ComparePChar(DesignSignalNames[Result],Name)
|
||||
if SamePChar(DesignSignalNames[Result],Name)
|
||||
and (DesignSignalAfter[Result]=After) then exit;
|
||||
Result:=dstUnknown;
|
||||
end;
|
||||
|
@ -49,7 +49,7 @@ uses
|
||||
LResources, Controls, Forms, Buttons, Menus, StdCtrls, ComCtrls, ExtCtrls,
|
||||
Dialogs, ExtDlgs, ImgList, LCLMessageGlue,
|
||||
// LazUtils
|
||||
Masks, FileUtil, LazFileUtils, LazLoggerBase, LazUTF8, DynHashArray,
|
||||
Masks, FileUtil, LazFileUtils, LazStringUtils, LazLoggerBase, LazUTF8, DynHashArray,
|
||||
// Gtk2
|
||||
Gtk2FontCache, Gtk2Globals, Gtk2Def, Gtk2Extra, {%H-}Gtk2Debug;
|
||||
|
||||
@ -311,8 +311,7 @@ function DeliverPostMessage(const Target: Pointer; var TheMessage): GBoolean;
|
||||
function DeliverMessage(const Target: Pointer; var AMessage): PtrInt;
|
||||
|
||||
// PChar
|
||||
function CreatePChar(const s: string): PChar;
|
||||
function ComparePChar(P1, P2: PChar): boolean;
|
||||
//function CreatePChar(const s: string): PChar;
|
||||
function FindChar(c: char; p:PChar; Max: integer): integer;
|
||||
function FindLineLen(p:PChar; Max: integer): integer;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user