+ wxInputStream *self = (wxInputStream *)this; // const_cast
+
+ char c;
+ self->Read(&c, 1);
+ if ( GetLastError() == wxSTREAM_EOF )
+ {
+ return TRUE;
+ }
+
+ self->Ungetch(c);
+
+ return FALSE;
+}
+
+char *wxInputStream::AllocSpaceWBack(size_t needed_size)
+{
+ /* get number of bytes left from previous wback buffer */
+ size_t toget = m_wbacksize - m_wbackcur;
+
+ /* allocate a buffer large enough to hold prev + new data */
+ char *temp_b = (char *) malloc(needed_size + toget);
+
+ if (!temp_b)
+ return NULL;
+
+ /* copy previous data (and free old buffer) if needed */
+ if (m_wback)
+ {
+ memmove(temp_b + needed_size, m_wback + m_wbackcur, toget);
+ free(m_wback);
+ }
+
+ /* done */
+ m_wback = temp_b;
+ m_wbackcur = 0;
+ m_wbacksize = needed_size + toget;
+
+ return (char *) m_wback;
+}
+
+size_t wxInputStream::GetWBack(char *buf, size_t bsize)
+{
+ size_t s_toget = m_wbacksize-m_wbackcur;
+
+ if (!m_wback)
+ return 0;
+
+ if (bsize < s_toget)
+ s_toget = bsize;
+
+ memcpy(buf, (m_wback+m_wbackcur), s_toget);
+
+ m_wbackcur += s_toget;
+ if (m_wbackcur == m_wbacksize)
+ {
+ free(m_wback);
+ m_wback = (char *)NULL;
+ m_wbacksize = 0;
+ m_wbackcur = 0;
+ }
+
+ return s_toget;
+}
+
+size_t wxInputStream::Ungetch(const void *buf, size_t bufsize)
+{
+ char *ptrback = AllocSpaceWBack(bufsize);
+ if (!ptrback)
+ return 0;
+
+ memcpy(ptrback, buf, bufsize);
+ return bufsize;
+}
+
+bool wxInputStream::Ungetch(char c)
+{
+ char * ptrback = AllocSpaceWBack(1);
+ if (!ptrback)
+ return FALSE;
+
+ *ptrback = c;
+ return TRUE;