]> git.saurik.com Git - wxWidgets.git/commitdiff
Change GetC to return an int so that it can return wxEOF on error.
authorMichael Wetherell <mike.wetherell@ntlworld.com>
Sun, 29 Oct 2006 17:00:07 +0000 (17:00 +0000)
committerMichael Wetherell <mike.wetherell@ntlworld.com>
Sun, 29 Oct 2006 17:00:07 +0000 (17:00 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@42623 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/stream.h
src/common/stream.cpp

index 62dced04473ba7f5ddaa730d8547d98e2a39cafb..24522440603e95ef2438a0b721d49cb1ff6cd7c0 100644 (file)
@@ -42,6 +42,8 @@ enum wxStreamError
     wxSTREAM_READ_ERROR         // generic read error
 };
 
+const int wxEOF = -1;
+
 // ============================================================================
 // base stream classes: wxInputStream and wxOutputStream
 // ============================================================================
@@ -106,11 +108,11 @@ public:
     // undefined), otherwise 1
     virtual char Peek();
 
-    // return one character from the stream, blocking until it appears if
+    // return one byte from the stream, blocking until it appears if
     // necessary
     //
-    // if EOF, return value is undefined and LastRead() will return 0 and not 1
-    char GetC();
+    // on success returns a value between 0 - 255, or wxEOF on EOF or error.
+    int GetC();
 
     // read at most the given number of bytes from the stream
     //
index 83c302f5d1309dcdfad49b58097eb36a17919b99..8ae48e1605d3f02aaf1af5efd3f27d1ba890060a 100644 (file)
@@ -809,11 +809,11 @@ bool wxInputStream::Ungetch(char c)
     return Ungetch(&c, sizeof(c)) != 0;
 }
 
-char wxInputStream::GetC()
+int wxInputStream::GetC()
 {
-    char c;
+    unsigned char c;
     Read(&c, sizeof(c));
-    return c;
+    return LastRead() ? c : wxEOF;
 }
 
 wxInputStream& wxInputStream::Read(void *buf, size_t size)