From 577d26b290b9ad0d5a862083f074020dc6aee17c Mon Sep 17 00:00:00 2001 From: florian Date: Fri, 2 May 2008 18:43:43 +0000 Subject: [PATCH] * better handling of error output for gui programs git-svn-id: trunk@10867 - --- rtl/win32/system.pp | 45 ++++++++++++++++++--------------------------- 1 file changed, 18 insertions(+), 27 deletions(-) diff --git a/rtl/win32/system.pp b/rtl/win32/system.pp index 40d7b2e5c0..3dabf90f22 100644 --- a/rtl/win32/system.pp +++ b/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 - begin - dec(p); - if not(p^ in [#10,#13]) then - break; - end; - end; - if ErrorLen=ErrorBufferLength then - i:=4; - if (i=4) then + while F.BufPos>0 do begin - MessageBox(0,@ErrorBuf,pchar('Error'),0); - ErrorLen:=0; + 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=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,'');