X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/830f8f11bca5c0892ae767ba14790c8b5b59011f..be13a2677509304e1ccebbc678da8633028ecd14:/src/common/textfile.cpp diff --git a/src/common/textfile.cpp b/src/common/textfile.cpp index 3334375b44..1d033f87db 100644 --- a/src/common/textfile.cpp +++ b/src/common/textfile.cpp @@ -132,7 +132,7 @@ bool wxTextFile::OnRead(const wxMBConv& conv) #if wxUSE_UNICODE if ( bufSize > 4 && str.empty() ) { - wxLogError(_("Failed to convert file contents to Unicode.")); + wxLogError(_("Failed to convert file \"%s\" to Unicode."), GetName()); return false; } #endif // wxUSE_UNICODE @@ -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; } }