Explorar o código

* better handling of error output for gui programs

git-svn-id: trunk@10867 -
florian %!s(int64=17) %!d(string=hai) anos
pai
achega
577d26b290
Modificáronse 1 ficheiros con 17 adicións e 26 borrados
  1. 17 26
      rtl/win32/system.pp

+ 17 - 26
rtl/win32/system.pp

@@ -1017,34 +1017,24 @@ var
   p : pchar;
   i : longint;
 Begin
-  if F.BufPos>0 then
-   begin
-     if F.BufPos+ErrorLen>ErrorBufferLength then
-       i:=ErrorBufferLength-ErrorLen
-     else
-       i:=F.BufPos;
-     Move(F.BufPtr^,ErrorBuf[ErrorLen],i);
-     inc(ErrorLen,i);
-     ErrorBuf[ErrorLen]:=#0;
-   end;
-  if ErrorLen>3 then
-   begin
-     p:=@ErrorBuf[ErrorLen];
-     for i:=1 to 4 do
+  while F.BufPos>0 do
+    begin
       begin
-        dec(p);
-        if not(p^ in [#10,#13]) then
-         break;
+        if F.BufPos+ErrorLen>ErrorBufferLength then
+          i:=ErrorBufferLength-ErrorLen
+        else
+          i:=F.BufPos;
+        Move(F.BufPtr^,ErrorBuf[ErrorLen],i);
+        inc(ErrorLen,i);
+        ErrorBuf[ErrorLen]:=#0;
       end;
-   end;
-   if ErrorLen=ErrorBufferLength then
-     i:=4;
-   if (i=4) then
-    begin
-      MessageBox(0,@ErrorBuf,pchar('Error'),0);
-      ErrorLen:=0;
+      if ErrorLen=ErrorBufferLength then
+        begin
+          MessageBox(0,@ErrorBuf,pchar('Error'),0);
+          ErrorLen:=0;
+        end;
+      Dec(F.BufPos,i);
     end;
-  F.BufPos:=0;
   ErrorWrite:=0;
 End;
 
@@ -1066,6 +1056,7 @@ Begin
   TextRec(F).InOutFunc:=@ErrorWrite;
   TextRec(F).FlushFunc:=@ErrorWrite;
   TextRec(F).CloseFunc:=@ErrorClose;
+  ErrorLen:=0;
   ErrorOpen:=0;
 End;
 
@@ -1088,7 +1079,7 @@ begin
   if not IsConsole then
    begin
      AssignError(stderr);
-     AssignError(stdout);
+     AssignError(StdOut);
      Assign(Output,'');
      Assign(Input,'');
      Assign(ErrOutput,'');