Browse Source

+ GetPChar to avoid nil pointer problems

pierre 26 years ago
parent
commit
9e0008da48
2 changed files with 22 additions and 11 deletions
  1. 12 9
      ide/text/fpdebug.pas
  2. 10 2
      ide/text/wutils.pas

+ 12 - 9
ide/text/fpdebug.pas

@@ -603,7 +603,7 @@ begin
          (PB^.typ<>bt_file_line) and (PB^.typ<>bt_function) then
         begin
            Command('p '+GetStr(PB^.Name));
-           S:=StrPas(GetOutput);
+           S:=GetPChar(GetOutput);
            got_error:=false;
            If Pos('=',S)>0 then
              S:=Copy(S,Pos('=',S)+1,255);
@@ -1783,9 +1783,9 @@ begin
         S:=' '+GetStr(PW^.Expr)+' <Unknown value>'
       else if not assigned(PW^.last_value) or
         (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
-        S:='!'+GetStr(PW^.Expr)+'!'+StrPas(PW^.Current_value);
+        S:='!'+GetStr(PW^.Expr)+'!'+GetPchar(PW^.Current_value);
       GetIndentedText:=Copy(S,Indent,MaxLen);
     end
   else
@@ -1794,7 +1794,7 @@ begin
          (StrLen(PW^.Current_value)<Indent-Valoffset) then
         S:=''
       else
-        S:=StrPas(@(PW^.Current_Value[Indent-Valoffset]));
+        S:=GetStr(@(PW^.Current_Value[Indent-Valoffset]));
       GetIndentedText:=Copy(S,1,MaxLen);
    end;
 end;
@@ -2097,12 +2097,12 @@ begin
   NameIL^.SetData(S1);
 
   if assigned(Watch^.Current_value) then
-    S1:=StrPas(Watch^.Current_value)
+    S1:=GetPChar(Watch^.Current_value)
   else
     S1:='';
 
   if assigned(Watch^.Last_value) then
-    S2:=StrPas(Watch^.Last_value)
+    S2:=GetPChar(Watch^.Last_value)
   else
     S2:='';
 
@@ -2156,8 +2156,8 @@ end;
         begin
           with Debugger^.frames[i]^ do
             begin
-              AddItem(new(PMessageItem,init(0,StrPas(function_name)+StrPas(args),
-                AddModuleName(StrPas(file_name)),line_number,1)));
+              AddItem(new(PMessageItem,init(0,GetPChar(function_name)+GetPChar(args),
+                AddModuleName(GetPChar(file_name)),line_number,1)));
             end;
         end;
       if List^.Count > 0 then
@@ -2373,7 +2373,10 @@ end.
 
 {
   $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
     + WatchesCollection and BreakpointsCollection stored in desk file
     * Syntax highlighting was broken

+ 10 - 2
ide/text/wutils.pas

@@ -82,6 +82,7 @@ function Trim(const S: string): string;
 function IntToStr(L: longint): string;
 function StrToInt(const S: string): longint;
 function GetStr(P: PString): string;
+function GetPChar(P: PChar): string;
 
 function DirOf(const S: string): string;
 function ExtOf(const S: string): string;
@@ -99,7 +100,7 @@ const LastStrToIntResult : integer = 0;
 implementation
 
 uses
-  Dos;
+  Strings, Dos;
 
 {$ifdef TPUNIXLF}
   procedure readln(var t:text;var s:string);
@@ -265,6 +266,10 @@ begin
   if P=nil then GetStr:='' else GetStr:=P^;
 end;
 
+function GetPChar(P: PChar): string;
+begin
+  if P=nil then GetPChar:='' else GetPChar:=StrPas(P);
+end;
 
 function DirOf(const S: string): string;
 var D: DirStr; E: ExtStr; N: NameStr;
@@ -443,7 +448,10 @@ end;
 END.
 {
   $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
 
   Revision 1.6  1999/08/24 22:01:48  pierre