mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-22 10:19:38 +02:00
lazlogger: added dbgstr for pchars
git-svn-id: trunk@35488 -
This commit is contained in:
parent
358b10b13b
commit
b1eb78dbdf
@ -120,6 +120,8 @@ function DbgS(const m: TMethod): string; overload;
|
||||
function DbgSName(const p: TObject): string; overload;
|
||||
function DbgSName(const p: TClass): string; overload;
|
||||
function DbgStr(const StringWithSpecialChars: string): string; overload;
|
||||
function DbgStr(const StringWithSpecialChars: string; StartPos, Len: PtrInt): string; overload;
|
||||
function DbgStr(const p: PChar; Len: PtrInt): string; overload;
|
||||
function DbgWideStr(const StringWithSpecialChars: widestring): string; overload;
|
||||
function dbgMemRange(P: Pointer; Count: integer; Width: integer = 0): string; overload;
|
||||
function dbgMemStream(MemStream: TCustomMemoryStream; Count: integer): string; overload;
|
||||
@ -698,6 +700,56 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function DbgStr(const StringWithSpecialChars: string; StartPos, Len: PtrInt
|
||||
): string;
|
||||
begin
|
||||
Result:=dbgstr(copy(StringWithSpecialChars,StartPos,Len));
|
||||
end;
|
||||
|
||||
function DbgStr(const p: PChar; Len: PtrInt): string;
|
||||
const
|
||||
Hex: array[0..15] of char='0123456789ABCDEF';
|
||||
var
|
||||
UsedLen: PtrUInt;
|
||||
ResultLen: PtrUInt;
|
||||
Src: PChar;
|
||||
Dest: PChar;
|
||||
c: Char;
|
||||
begin
|
||||
if (p=nil) or (p^=#0) or (Len<=0) then exit('');
|
||||
UsedLen:=0;
|
||||
ResultLen:=0;
|
||||
Src:=p;
|
||||
while Src^<>#0 do begin
|
||||
inc(UsedLen);
|
||||
if Src^ in [' '..#126] then
|
||||
inc(ResultLen)
|
||||
else
|
||||
inc(ResultLen,3);
|
||||
if UsedLen>=Len then break;
|
||||
inc(Src);
|
||||
end;
|
||||
SetLength(Result,ResultLen);
|
||||
Src:=p;
|
||||
Dest:=PChar(Result);
|
||||
while UsedLen>0 do begin
|
||||
dec(UsedLen);
|
||||
c:=Src^;
|
||||
if c in [' '..#126] then begin
|
||||
Dest^:=c;
|
||||
inc(Dest);
|
||||
end else begin
|
||||
Dest^:='#';
|
||||
inc(Dest);
|
||||
Dest^:=Hex[ord(c) shr 4];
|
||||
inc(Dest);
|
||||
Dest^:=Hex[ord(c) and $f];
|
||||
inc(Dest);
|
||||
end;
|
||||
inc(Src);
|
||||
end;
|
||||
end;
|
||||
|
||||
function DbgWideStr(const StringWithSpecialChars: widestring): string;
|
||||
var
|
||||
s: String;
|
||||
|
Loading…
Reference in New Issue
Block a user