X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/830f8f11bca5c0892ae767ba14790c8b5b59011f..80a779275ae04443c568dca919adb26cf6f5002c:/src/common/textfile.cpp?ds=sidebyside diff --git a/src/common/textfile.cpp b/src/common/textfile.cpp index 3334375b44..f61220dc06 100644 --- a/src/common/textfile.cpp +++ b/src/common/textfile.cpp @@ -157,7 +157,15 @@ bool wxTextFile::OnRead(const wxMBConv& conv) // could be a DOS or Unix EOL 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 { @@ -182,7 +190,15 @@ bool wxTextFile::OnRead(const wxMBConv& conv) if ( chLast == '\r' ) { // 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; } }