dbertoni 01/02/28 10:52:53
Modified: c/src/PlatformSupport StdBinInputStream.cpp
Log:
Fixed bug where one too many characters was read.
Revision Changes Path
1.6 +33 -9 xml-xalan/c/src/PlatformSupport/StdBinInputStream.cpp
Index: StdBinInputStream.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/PlatformSupport/StdBinInputStream.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- StdBinInputStream.cpp 2000/11/30 14:37:27 1.5
+++ StdBinInputStream.cpp 2001/02/28 18:52:47 1.6
@@ -93,18 +93,42 @@
XMLByte* const toFill,
const unsigned int maxToRead)
{
-#if !defined(XALAN_NO_NAMESPACES)
- using std::istream;
+#if !defined(XALAN_OLD_STREAM_HEADERS)
+#if defined(XALAN_NO_NAMESPACES)
+ typedef char_traits<char> CharTraitsType;
+#else
+ typedef std::char_traits<char> CharTraitsType;
#endif
-
- unsigned long i = 0;
+#endif
- while(i < maxToRead && m_stream)
+ if (!m_stream)
{
- toFill[i] = XMLByte(m_stream.get());
-
- ++i;
+ return 0;
}
+ else
+ {
+ unsigned long i = 0;
+
+ while(i < maxToRead)
+ {
+ const int ch = m_stream.get();
- return i;
+#if defined(XALAN_OLD_STREAM_HEADERS)
+ if (ch == EOF)
+#else
+ if (ch == CharTraitsType::eof())
+#endif
+ {
+ break;
+ }
+ else
+ {
+ toFill[i] = XMLByte(ch);
+
+ ++i;
+ }
+ }
+
+ return i;
+ }
}