mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-22 02:59:26 +02:00
DBG: Prepare for different line endings. Issue #0021834
git-svn-id: trunk@37026 -
This commit is contained in:
parent
0a86a3e9d4
commit
9baa5f827c
@ -64,6 +64,7 @@ type
|
|||||||
function CreateDebugProcess(const AOptions: String): Boolean; virtual;
|
function CreateDebugProcess(const AOptions: String): Boolean; virtual;
|
||||||
procedure Flush; // Flushes output buffer
|
procedure Flush; // Flushes output buffer
|
||||||
function GetWaiting: Boolean; override;
|
function GetWaiting: Boolean; override;
|
||||||
|
function LineEndPos(const s: string; out LineEndLen: integer): integer; virtual;
|
||||||
function ReadLine(ATimeOut: Integer = -1): String; overload;
|
function ReadLine(ATimeOut: Integer = -1): String; overload;
|
||||||
function ReadLine(const APeek: Boolean; ATimeOut: Integer = -1): String; virtual; overload;
|
function ReadLine(const APeek: Boolean; ATimeOut: Integer = -1): String; virtual; overload;
|
||||||
procedure SendCmdLn(const ACommand: String); virtual; overload;
|
procedure SendCmdLn(const ACommand: String); virtual; overload;
|
||||||
@ -358,6 +359,23 @@ begin
|
|||||||
Result := FReading;
|
Result := FReading;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TCmdLineDebugger.LineEndPos(const s: string; out LineEndLen: integer): integer;
|
||||||
|
var
|
||||||
|
n, idx: Integer;
|
||||||
|
begin
|
||||||
|
Result := 0;
|
||||||
|
LineEndLen := 0;
|
||||||
|
for n := Low(FLineEnds) to High(FLineEnds) do
|
||||||
|
begin
|
||||||
|
idx := Pos(FLineEnds[n], FOutputBuf);
|
||||||
|
if (idx > 0) and ( (idx < Result) or (Result = 0) )
|
||||||
|
then begin
|
||||||
|
Result := idx;
|
||||||
|
LineEndLen := length(FLineEnds[n]);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
function TCmdLineDebugger.ReadLine(ATimeOut: Integer = -1): String;
|
function TCmdLineDebugger.ReadLine(ATimeOut: Integer = -1): String;
|
||||||
begin
|
begin
|
||||||
Result := ReadLine(False, ATimeOut);
|
Result := ReadLine(False, ATimeOut);
|
||||||
@ -381,7 +399,7 @@ function TCmdLineDebugger.ReadLine(const APeek: Boolean; ATimeOut: Integer = -1)
|
|||||||
var
|
var
|
||||||
WaitSet: Integer;
|
WaitSet: Integer;
|
||||||
LineEndMatch: String;
|
LineEndMatch: String;
|
||||||
n, Idx, MinIdx, PeekCount: Integer;
|
LineEndIdx, LineEndLen, PeekCount: Integer;
|
||||||
begin
|
begin
|
||||||
// WriteLN('[TCmdLineDebugger.GetOutput] Enter');
|
// WriteLN('[TCmdLineDebugger.GetOutput] Enter');
|
||||||
|
|
||||||
@ -397,21 +415,12 @@ begin
|
|||||||
repeat
|
repeat
|
||||||
if FOutputBuf <> ''
|
if FOutputBuf <> ''
|
||||||
then begin
|
then begin
|
||||||
MinIdx := MaxInt;
|
LineEndIdx := LineEndPos(FOutputBuf, LineEndLen);
|
||||||
for n := Low(FLineEnds) to High(FLineEnds) do
|
|
||||||
begin
|
if LineEndIdx > 0
|
||||||
idx := Pos(FLineEnds[n], FOutputBuf);
|
|
||||||
if (idx > 0) and (idx < MinIdx)
|
|
||||||
then begin
|
|
||||||
MinIdx := idx;
|
|
||||||
LineEndMatch := FLineEnds[n];
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
if MinIdx < MaxInt
|
|
||||||
then begin
|
then begin
|
||||||
Dec(MinIdx);
|
Dec(LineEndIdx);
|
||||||
Result := Copy(FOutputBuf, 1, MinIdx);
|
Result := Copy(FOutputBuf, 1, LineEndIdx);
|
||||||
if APeek
|
if APeek
|
||||||
then begin
|
then begin
|
||||||
if PeekCount = FPeekOffset
|
if PeekCount = FPeekOffset
|
||||||
@ -421,7 +430,7 @@ begin
|
|||||||
Continue;
|
Continue;
|
||||||
end;
|
end;
|
||||||
end
|
end
|
||||||
else Delete(FOutputBuf, 1, MinIdx + Length(LineEndMatch));
|
else Delete(FOutputBuf, 1, LineEndIdx + LineEndLen);
|
||||||
|
|
||||||
DoDbgOutput(Result);
|
DoDbgOutput(Result);
|
||||||
Break;
|
Break;
|
||||||
|
Loading…
Reference in New Issue
Block a user