don't crash on weird line endings like \r\r\n
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@41829 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -157,7 +157,15 @@ bool wxTextFile::OnRead(const wxMBConv& conv)
|
|||||||
// could be a DOS or Unix EOL
|
// could be a DOS or Unix EOL
|
||||||
if ( chLast == '\r' )
|
if ( chLast == '\r' )
|
||||||
{
|
{
|
||||||
AddLine(wxString(lineStart, p - 1), wxTextFileType_Dos);
|
if ( p - 1 >= lineStart )
|
||||||
|
{
|
||||||
|
AddLine(wxString(lineStart, p - 1), wxTextFileType_Dos);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// there were two line endings, so add an empty line:
|
||||||
|
AddLine(wxEmptyString, wxTextFileType_Dos);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else // bare '\n', Unix style
|
else // bare '\n', Unix style
|
||||||
{
|
{
|
||||||
@@ -182,7 +190,15 @@ bool wxTextFile::OnRead(const wxMBConv& conv)
|
|||||||
if ( chLast == '\r' )
|
if ( chLast == '\r' )
|
||||||
{
|
{
|
||||||
// Mac line termination
|
// Mac line termination
|
||||||
AddLine(wxString(lineStart, p - 1), wxTextFileType_Mac);
|
if ( p - 1 >= lineStart )
|
||||||
|
{
|
||||||
|
AddLine(wxString(lineStart, p - 1), wxTextFileType_Mac);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// there were two line endings, so add an empty line:
|
||||||
|
AddLine(wxEmptyString, wxTextFileType_Mac);
|
||||||
|
}
|
||||||
lineStart = p;
|
lineStart = p;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user