From 42a3aedbcee394eba28bc8bd1e9400f1efc42ef8 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 12 Jul 2002 14:41:55 +0000 Subject: [PATCH] fixed bug in Ungetch() which was preventing wxExecute() from working: this method must clear the EOF flag! git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@16144 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/stream.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/common/stream.cpp b/src/common/stream.cpp index c3c66e9e50..957dd933fe 100644 --- a/src/common/stream.cpp +++ b/src/common/stream.cpp @@ -763,22 +763,27 @@ size_t wxInputStream::GetWBack(void *buf, size_t bsize) size_t wxInputStream::Ungetch(const void *buf, size_t bufsize) { + if ( m_lasterror != wxSTREAM_NO_ERROR && m_lasterror != wxSTREAM_EOF ) + { + // can't operate on this stream until the error is cleared + return 0; + } + char *ptrback = AllocSpaceWBack(bufsize); if (!ptrback) return 0; + // Eof() shouldn't return TRUE any longer + if ( m_lasterror == wxSTREAM_EOF ) + m_lasterror = wxSTREAM_NO_ERROR; + memcpy(ptrback, buf, bufsize); return bufsize; } bool wxInputStream::Ungetch(char c) { - void *ptrback = AllocSpaceWBack(1); - if (!ptrback) - return FALSE; - - *(char *)ptrback = c; - return TRUE; + return Ungetch(&c, sizeof(char)) != 0; } char wxInputStream::GetC() -- 2.47.2