]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/textfile.cpp
adding common search field file
[wxWidgets.git] / src / common / textfile.cpp
index 3334375b44ccc6027877a82873e99fab621035e6..1d033f87db1f4f4a99c49d203601b93f396ab50d 100644 (file)
@@ -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;
                 }
         }