+ GetPChar to avoid nil pointer problems

This commit is contained in:
pierre 1999-10-25 16:39:03 +00:00
parent b538616087
commit 9e0008da48
2 changed files with 22 additions and 11 deletions

View File

@ -603,7 +603,7 @@ begin
(PB^.typ<>bt_file_line) and (PB^.typ<>bt_function) then (PB^.typ<>bt_file_line) and (PB^.typ<>bt_function) then
begin begin
Command('p '+GetStr(PB^.Name)); Command('p '+GetStr(PB^.Name));
S:=StrPas(GetOutput); S:=GetPChar(GetOutput);
got_error:=false; got_error:=false;
If Pos('=',S)>0 then If Pos('=',S)>0 then
S:=Copy(S,Pos('=',S)+1,255); S:=Copy(S,Pos('=',S)+1,255);
@ -1783,9 +1783,9 @@ begin
S:=' '+GetStr(PW^.Expr)+' <Unknown value>' S:=' '+GetStr(PW^.Expr)+' <Unknown value>'
else if not assigned(PW^.last_value) or else if not assigned(PW^.last_value) or
(strcomp(PW^.Last_value,PW^.Current_value)=0) then (strcomp(PW^.Last_value,PW^.Current_value)=0) then
S:=' '+GetStr(PW^.Expr)+' '+StrPas(PW^.Current_value) S:=' '+GetStr(PW^.Expr)+' '+GetPChar(PW^.Current_value)
else else
S:='!'+GetStr(PW^.Expr)+'!'+StrPas(PW^.Current_value); S:='!'+GetStr(PW^.Expr)+'!'+GetPchar(PW^.Current_value);
GetIndentedText:=Copy(S,Indent,MaxLen); GetIndentedText:=Copy(S,Indent,MaxLen);
end end
else else
@ -1794,7 +1794,7 @@ begin
(StrLen(PW^.Current_value)<Indent-Valoffset) then (StrLen(PW^.Current_value)<Indent-Valoffset) then
S:='' S:=''
else else
S:=StrPas(@(PW^.Current_Value[Indent-Valoffset])); S:=GetStr(@(PW^.Current_Value[Indent-Valoffset]));
GetIndentedText:=Copy(S,1,MaxLen); GetIndentedText:=Copy(S,1,MaxLen);
end; end;
end; end;
@ -2097,12 +2097,12 @@ begin
NameIL^.SetData(S1); NameIL^.SetData(S1);
if assigned(Watch^.Current_value) then if assigned(Watch^.Current_value) then
S1:=StrPas(Watch^.Current_value) S1:=GetPChar(Watch^.Current_value)
else else
S1:=''; S1:='';
if assigned(Watch^.Last_value) then if assigned(Watch^.Last_value) then
S2:=StrPas(Watch^.Last_value) S2:=GetPChar(Watch^.Last_value)
else else
S2:=''; S2:='';
@ -2156,8 +2156,8 @@ end;
begin begin
with Debugger^.frames[i]^ do with Debugger^.frames[i]^ do
begin begin
AddItem(new(PMessageItem,init(0,StrPas(function_name)+StrPas(args), AddItem(new(PMessageItem,init(0,GetPChar(function_name)+GetPChar(args),
AddModuleName(StrPas(file_name)),line_number,1))); AddModuleName(GetPChar(file_name)),line_number,1)));
end; end;
end; end;
if List^.Count > 0 then if List^.Count > 0 then
@ -2373,7 +2373,10 @@ end.
{ {
$Log$ $Log$
Revision 1.32 1999-09-16 14:34:57 pierre Revision 1.33 1999-10-25 16:39:03 pierre
+ GetPChar to avoid nil pointer problems
Revision 1.32 1999/09/16 14:34:57 pierre
+ TBreakpoint and TWatch registering + TBreakpoint and TWatch registering
+ WatchesCollection and BreakpointsCollection stored in desk file + WatchesCollection and BreakpointsCollection stored in desk file
* Syntax highlighting was broken * Syntax highlighting was broken

View File

@ -82,6 +82,7 @@ function Trim(const S: string): string;
function IntToStr(L: longint): string; function IntToStr(L: longint): string;
function StrToInt(const S: string): longint; function StrToInt(const S: string): longint;
function GetStr(P: PString): string; function GetStr(P: PString): string;
function GetPChar(P: PChar): string;
function DirOf(const S: string): string; function DirOf(const S: string): string;
function ExtOf(const S: string): string; function ExtOf(const S: string): string;
@ -99,7 +100,7 @@ const LastStrToIntResult : integer = 0;
implementation implementation
uses uses
Dos; Strings, Dos;
{$ifdef TPUNIXLF} {$ifdef TPUNIXLF}
procedure readln(var t:text;var s:string); procedure readln(var t:text;var s:string);
@ -265,6 +266,10 @@ begin
if P=nil then GetStr:='' else GetStr:=P^; if P=nil then GetStr:='' else GetStr:=P^;
end; end;
function GetPChar(P: PChar): string;
begin
if P=nil then GetPChar:='' else GetPChar:=StrPas(P);
end;
function DirOf(const S: string): string; function DirOf(const S: string): string;
var D: DirStr; E: ExtStr; N: NameStr; var D: DirStr; E: ExtStr; N: NameStr;
@ -443,7 +448,10 @@ end;
END. END.
{ {
$Log$ $Log$
Revision 1.7 1999-09-13 11:44:00 peter Revision 1.8 1999-10-25 16:39:03 pierre
+ GetPChar to avoid nil pointer problems
Revision 1.7 1999/09/13 11:44:00 peter
* fixes from gabor, idle event, html fix * fixes from gabor, idle event, html fix
Revision 1.6 1999/08/24 22:01:48 pierre Revision 1.6 1999/08/24 22:01:48 pierre