From 8bdc8a9c98bde50d25e6ecc27dd25ca147498cc9 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 30 Apr 2007 01:13:37 +0000 Subject: [PATCH] don't drop lines without trailing new line character in wxExecute() with capture git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45713 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 1 + src/common/utilscmn.cpp | 23 +++++++++++++---------- 2 files changed, 14 insertions(+), 10 deletions(-) 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(); + + // 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 -- 2.45.2