Pārlūkot izejas kodu

* moved the code from the libgdb.a interface for setting maximum width and then
restoring it from InternalGetValue to new methods (MaxWidth and NormWidth), so
they can be reused by other methods as well.

git-svn-id: trunk@30298 -

nickysn 10 gadi atpakaļ
vecāks
revīzija
aece198492
1 mainītis faili ar 50 papildinājumiem un 30 dzēšanām
  1. 50 30
      packages/gdbint/src/gdbcon.pp

+ 50 - 30
packages/gdbint/src/gdbcon.pp

@@ -32,6 +32,10 @@ type
   PGDBController=^TGDBController;
   TGDBController=object(TGDBInterface)
   private
+    SavedWindowWidth : longint;
+    { width }
+    procedure MaxWidth;
+    procedure NormWidth;
     { print }
     function InternalGetValue(Const expr : string) : AnsiString;
   public
@@ -441,28 +445,11 @@ begin
   SetCommand:=true;
 end;
 
-{ print }
-
-function TrimEnd(s: AnsiString): AnsiString;
-var
-  I: LongInt;
-begin
-  if (s<>'') and (s[Length(s)]=#10) then
-  begin
-    I:=Length(s);
-    while (i>1) and ((s[i-1]=' ') or (s[i-1]=#9)) do
-      dec(i);
-	delete(s,i,Length(s)-i+1);
-  end;
-  TrimEnd:=s;
-end;
+{ width }
 
-function TGDBController.InternalGetValue(Const expr : string) : AnsiString;
+procedure TGDBController.MaxWidth;
 var
   p,p2,p3 : pchar;
-  st : string;
-  WindowWidth : longint;
-  saved_got_error: Boolean;
 begin
   Command('show width');
   p:=GetOutput;
@@ -484,12 +471,49 @@ begin
   p3:=strpos(p,'.');
   if assigned(p3) then
     p3^:=#0;
-  WindowWidth:=-1;
-  val(strpas(p),WindowWidth);
-  if WindowWidth<>-1 then
+  SavedWindowWidth:=-1;
+  val(strpas(p),SavedWindowWidth);
+  if SavedWindowWidth<>-1 then
     Command('set width 0xffffffff');
-  Command('p '+expr);
+end;
+
+procedure TGDBController.NormWidth;
+var
+  st : string;
+  saved_got_error : boolean;
+begin
   saved_got_error:=got_error;
+  if SavedWindowWidth<>-1 then
+    begin
+      str(SavedWindowWidth,st);
+      Command('set width '+St);
+    end;
+  got_error:=saved_got_error;
+end;
+
+{ print }
+
+function TrimEnd(s: AnsiString): AnsiString;
+var
+  I: LongInt;
+begin
+  if (s<>'') and (s[Length(s)]=#10) then
+  begin
+    I:=Length(s);
+    while (i>1) and ((s[i-1]=' ') or (s[i-1]=#9)) do
+      dec(i);
+	delete(s,i,Length(s)-i+1);
+  end;
+  TrimEnd:=s;
+end;
+
+function TGDBController.InternalGetValue(Const expr : string) : AnsiString;
+var
+  p,p2 : pchar;
+begin
+  MaxWidth;
+
+  Command('p '+expr);
   p:=GetOutput;
   if assigned(p) then
     p2:=strpos(p,'=')
@@ -504,16 +528,12 @@ begin
     p:=strpos(p,')')+1;
   while p^ in [' ',#9] do
     inc(p);
-  if assigned(p) and not saved_got_error then
+  if assigned(p) and not got_error then
     InternalGetValue:=TrimEnd(AnsiString(p))
   else
     InternalGetValue:=TrimEnd(AnsiString(GetError));
-  if WindowWidth<>-1 then
-    begin
-      str(WindowWidth,st);
-      Command('set width '+St);
-    end;
-  got_error:=saved_got_error;
+
+  NormWidth;
 end;