diff --git a/docs/changes.txt b/docs/changes.txt index 38c7e05575..516fc6a37e 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -94,6 +94,7 @@ Major new features in 2.8 release All: - Fix bug in wxFileConfig when recreating a group (Steven Van Ingelgem) +- Account for lines without newline at the end in wxExecute() - Added wxString::char_str() and wchar_str() methods for forward compatiblity with wxWidgets 3 diff --git a/src/common/utilscmn.cpp b/src/common/utilscmn.cpp index 7cf1062a5f..732b244072 100644 --- a/src/common/utilscmn.cpp +++ b/src/common/utilscmn.cpp @@ -647,24 +647,27 @@ static bool ReadAll(wxInputStream *is, wxArrayString& output) wxTextInputStream tis(*is); - bool cont = true; - while ( cont ) + for ( ;; ) { wxString line = tis.ReadLine(); - if ( is->Eof() ) - break; + // check for EOF before other errors as it's not really an error + if ( is->Eof() ) + { + // add the last, possibly incomplete, line + if ( !line.empty() ) + output.Add(line); + break; + } + + // any other error is fatal if ( !*is ) - { - cont = false; - } - else - { - output.Add(line); - } + return false; + + output.Add(line); } - return cont; + return true; } #endif // wxUSE_STREAMS