Skip to content

Commit

Permalink
7zMain.c always sends #10 as newline but its call to FormatMessage ca…
Browse files Browse the repository at this point in the history
…n cause #13#10 anyway.
  • Loading branch information
martijnlaan committed Oct 5, 2024
1 parent b602cb7 commit b6b5c41
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Projects/Src/Compression.SevenZipDecoder.pas
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,10 @@ function __fputs(str: PAnsiChar; unused: Pointer): Integer; cdecl;

function FindNewLine(const S: AnsiString): Integer;
begin
{ 7-Zip never sends #13 so this only checks for #10 }
{ 7zMain.c always sends #10 as newline but its call to FormatMessage can cause #13#10 anyway }
var N := Length(S);
for var I := 1 to N do
if S[I] = #10 then
if CharInSet(S[I], [#13, #10]) then
Exit(I);
Result := 0;
end;
Expand All @@ -180,6 +180,8 @@ function __fputs(str: PAnsiChar; unused: Pointer): Integer; cdecl;
var P := FindNewLine(LogBuffer);
while P <> 0 do begin
Log(Copy(LogBuffer, 1, P-1));
if (LogBuffer[P] = #13) and (P < Length(LogBuffer)) and (LogBuffer[P+1] = #10) then
Inc(P);
Delete(LogBuffer, 1, P);
P := FindNewLine(LogBuffer);
end;
Expand Down

0 comments on commit b6b5c41

Please sign in to comment.