I found some problem with my logfile.txt when opening it with Notepad++, shows:
As you can see, there are double line endings(CR
+ CRLF
), then I found it's introduced when parsing the string. The code:
File: \src\TortoiseProc\ProgressDlg.cpp
Func: void CProgressDlg::WriteLog() const
Line: 650
while (*psz_string)
{
if (*psz_string == '\r')
{
++psz_string;
continue;
}
size_t i_len = wcscspn(psz_string, L"\n");
logfile.AddLine(CString(psz_string, (int)i_len));
psz_string += i_len;
if (*psz_string == '\n')
++psz_string;
}
If the original string is line1\r\nline2
, the first line to be added into line list is line1\r
. The extra CR
is introduced.
This fixing does 2 things:
- Make sure the string does't include CR or LF before calling AddLine() by correct
i_len
value. - Just simply strip a pair
CR + LF
orLF + CR
if any.
And I just found the older log, even worst:
Empty line is strip! I can't reproduce it for now.