diff --git a/docs/changes.txt b/docs/changes.txt index 0caac1a61c..a03f1d283b 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -151,6 +151,7 @@ wxX11: All: - Fix bug in wxFileConfig when recreating a group (Steven Van Ingelgem) +- Account for lines without newline at the end in wxExecute() All (Unix): diff --git a/src/common/utilscmn.cpp b/src/common/utilscmn.cpp index 0f9a147fe3..0b2f8a28d3 100644 --- a/src/common/utilscmn.cpp +++ b/src/common/utilscmn.cpp @@ -556,24 +556,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