]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/xpmdecod.cpp
print session additions
[wxWidgets.git] / src / common / xpmdecod.cpp
index 73ce1f5d4b769336ba6abb3a98944d25bc9c88aa..1dc78c95d2618d020eb10f9e580f3490cecf4994 100644 (file)
@@ -115,9 +115,7 @@ license is as follows:
 #include "wx/intl.h"
 #include <string.h>
 
-#ifdef __VISUALC__
 #include <ctype.h>
-#endif
 
 #include "wx/xpmdecod.h"
 
@@ -126,10 +124,12 @@ bool wxXPMDecoder::CanRead(wxInputStream& stream)
 {
     unsigned char buf[9];
 
-    stream.Read(buf, 9);
-    stream.SeekI(-9, wxFromCurrent);
+    if ( !stream.Read(buf, WXSIZEOF(buf)) )
+        return FALSE;
+
+    stream.SeekI(-(off_t)WXSIZEOF(buf), wxFromCurrent);
 
-    return (memcmp(buf, "/* XPM */", 9) == 0);
+    return memcmp(buf, "/* XPM */", WXSIZEOF(buf)) == 0;
 }
 
 wxImage wxXPMDecoder::ReadFile(wxInputStream& stream)
@@ -143,7 +143,7 @@ wxImage wxXPMDecoder::ReadFile(wxInputStream& stream)
     wxCharBuffer buffer(length);
 
     char *xpm_buffer = (char *)buffer.data();
-    if ( stream.Read(xpm_buffer, length).LastError() == wxSTREAM_READ_ERROR )
+    if ( stream.Read(xpm_buffer, length).GetLastError() == wxSTREAM_READ_ERROR )
         return wxNullImage;
     xpm_buffer[length] = '\0';