Update of /cvsroot/boost/boost/boost/iostreams
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv19574/boost/iostreams
Modified Files:
char_traits.hpp checked_operations.hpp code_converter.hpp
compose.hpp restrict.hpp
Log Message:
Added Kim Barrett's patches that merge the changes from 1.33.1 into cvs HEAD.
Index: char_traits.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/iostreams/char_traits.hpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- char_traits.hpp 19 Nov 2005 19:52:07 -0000 1.4
+++ char_traits.hpp 26 May 2007 12:42:42 -0000 1.5
@@ -27,10 +27,12 @@
namespace boost { namespace iostreams {
-// Dinkumware that comes with QNX Momentics 6.3.0, 4.0.2, incorrectly defines
the
-// EOF and WEOF macros to not std:: qualify the wint_t type.
-// Fix by placing the def in this scope.
-#if defined(__QNX__) && defined(BOOST_DINKUMWARE_STDLIB)
+// Dinkumware that comes with QNX Momentics 6.3.0, 4.0.2, incorrectly defines
+// the EOF and WEOF macros to not std:: qualify the wint_t type (and so does
+// Sun C++ 5.8 + STLport 4). Fix by placing the def in this scope.
+// NOTE: Use BOOST_WORKAROUND?
+#if (defined(__QNX__) && defined(BOOST_DINKUMWARE_STDLIB)) \
+ || defined(__SUNPRO_CC)
using ::std::wint_t;
#endif
Index: checked_operations.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/iostreams/checked_operations.hpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- checked_operations.hpp 20 May 2005 05:28:13 -0000 1.3
+++ checked_operations.hpp 26 May 2007 12:42:42 -0000 1.4
@@ -127,7 +127,7 @@
template<>
struct seek_if_impl<random_access> {
template<typename T>
- static stream_offset
+ static std::streampos
seek( T& t, stream_offset off, BOOST_IOS::seekdir way,
BOOST_IOS::openmode which )
{ return iostreams::seek(t, off, way, which); }
@@ -136,7 +136,7 @@
template<>
struct seek_if_impl<any_tag> {
template<typename T>
- static stream_offset
+ static std::streampos
seek(T&, stream_offset, BOOST_IOS::seekdir, BOOST_IOS::openmode)
{ throw cant_seek(); }
};
Index: code_converter.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/iostreams/code_converter.hpp,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -d -r1.31 -r1.32
--- code_converter.hpp 3 Jun 2005 22:42:43 -0000 1.31
+++ code_converter.hpp 26 May 2007 12:42:42 -0000 1.32
@@ -23,7 +23,7 @@
#include <algorithm> // max.
#include <cstring> // memcpy.
#include <exception>
-#include <boost/config.hpp> // DEDUCED_TYPENAME.
+#include <boost/config.hpp> // DEDUCED_TYPENAME,
#include <boost/iostreams/char_traits.hpp>
#include <boost/iostreams/constants.hpp> // default_filter_buffer_size.
#include <boost/iostreams/detail/adapter/concept_adapter.hpp>
@@ -57,6 +57,32 @@
namespace detail {
+//--------------Definition of
strncpy_if_same---------------------------------//
+
+// Helper template for strncpy_if_same, below.
+template<bool B>
+struct strncpy_if_same_impl;
+
+template<>
+struct strncpy_if_same_impl<true> {
+ template<typename Ch>
+ static Ch* copy(Ch* tgt, const Ch* src, std::streamsize n)
+ { return BOOST_IOSTREAMS_CHAR_TRAITS(Ch)::copy(tgt, src, n); }
+};
+
+template<>
+struct strncpy_if_same_impl<false> {
+ template<typename Src, typename Tgt>
+ static Tgt* copy(Tgt* tgt, const Src*, std::streamsize) { return tgt; }
+};
+
+template<typename Src, typename Tgt>
+Tgt* strncpy_if_same(Tgt* tgt, const Src* src, std::streamsize n)
+{
+ typedef strncpy_if_same_impl<is_same<Src, Tgt>::value> impl;
+ return impl::copy(tgt, src, n);
+}
+
//--------------Definition of
conversion_buffer-------------------------------//
// Buffer and conversion state for reading.
@@ -169,7 +195,7 @@
policy_type& dev() { return **dev_; }
- enum {
+ enum flag_type {
f_open = 1,
f_input_closed = f_open << 1,
f_output_closed = f_input_closed << 1
@@ -311,16 +337,18 @@
break;
case codecvt_base::ok:
break;
- case codecvt_base::error:
- buf.state() = state_type();
- throw code_conversion_error();
case codecvt_base::noconv:
+ {
+ streamsize amt =
+ std::min<streamsize>(next - buf.ptr(), n - total);
+ detail::strncpy_if_same(s + total, buf.ptr(), amt);
+ total += amt;
+ }
+ break;
+ case codecvt_base::error:
default:
buf.state() = state_type();
- intern_type c = intern_type();
- memcpy(&c, (const void*) buf.ptr(), sizeof(extern_type));
- s[total++] = c;
- break;
+ throw code_conversion_error();
}
} while (total < n && status != EOF && status != WOULD_BLOCK);
@@ -362,24 +390,19 @@
case codecvt_base::ok:
total = static_cast<streamsize>(nint - s);
break;
- case codecvt_base::error:
- buf.state() = state_type();
- throw code_conversion_error();
case codecvt_base::noconv:
{
- // This can be shortened to two memcpy's.
- const char* c = (const char*) (s + total);
- for ( std::size_t index = 0;
- index < sizeof(intern_type);
- index += sizeof(extern_type),
- ++buf.ptr() )
- {
- memcpy(buf.ptr(), c + index, sizeof(extern_type));
- if (buf.eptr() == buf.end())
- buf.flush(dev());
- }
- ++total;
+ streamsize amt =
+ std::min<streamsize>( nint - total - s,
+ buf.end() - buf.eptr() );
+ detail::strncpy_if_same(buf.eptr(), s + total, amt);
+ total += amt;
}
+ break;
+ case codecvt_base::error:
+ default:
+ buf.state() = state_type();
+ throw code_conversion_error();
}
}
return total;
Index: compose.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/iostreams/compose.hpp,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- compose.hpp 30 May 2005 07:29:56 -0000 1.15
+++ compose.hpp 26 May 2007 12:42:42 -0000 1.16
@@ -78,9 +78,9 @@
composite_device(const Filter& flt, param_type dev);
std::streamsize read(char_type* s, std::streamsize n);
std::streamsize write(const char_type* s, std::streamsize n);
- stream_offset seek( stream_offset off, BOOST_IOS::seekdir way,
- BOOST_IOS::openmode which =
- BOOST_IOS::in | BOOST_IOS::out );
+ std::streampos seek( stream_offset off, BOOST_IOS::seekdir way,
+ BOOST_IOS::openmode which =
+ BOOST_IOS::in | BOOST_IOS::out );
void close();
void close(BOOST_IOS::openmode which);
@@ -142,9 +142,9 @@
}
template<typename Device>
- stream_offset seek( Device& dev, stream_offset off, BOOST_IOS::seekdir way,
- BOOST_IOS::openmode which =
- BOOST_IOS::in | BOOST_IOS::out )
+ std::streampos seek( Device& dev, stream_offset off, BOOST_IOS::seekdir
way,
+ BOOST_IOS::openmode which =
+ BOOST_IOS::in | BOOST_IOS::out )
{
composite_device<filter_ref, Device> cmp(boost::ref(filter2_), dev);
return iostreams::seek(filter1_, cmp, off, way, which);
@@ -325,7 +325,7 @@
{ return iostreams::write(filter_, device_, s, n); }
template<typename Filter, typename Device, typename Mode>
-stream_offset composite_device<Filter, Device, Mode>::seek
+std::streampos composite_device<Filter, Device, Mode>::seek
(stream_offset off, BOOST_IOS::seekdir way, BOOST_IOS::openmode which)
{ return iostreams::seek(filter_, device_, off, way, which); }
Index: restrict.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/iostreams/restrict.hpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- restrict.hpp 26 May 2005 08:53:15 -0000 1.1
+++ restrict.hpp 26 May 2007 12:42:42 -0000 1.2
@@ -61,7 +61,7 @@
stream_offset len = -1 );
std::streamsize read(char_type* s, std::streamsize n);
std::streamsize write(const char_type* s, std::streamsize n);
- stream_offset seek(stream_offset off, BOOST_IOS::seekdir way);
+ std::streampos seek(stream_offset off, BOOST_IOS::seekdir way);
private:
stream_offset beg_, pos_, end_;
};
@@ -145,7 +145,7 @@
}
template<typename Device>
- stream_offset seek(Device& dev, stream_offset off, BOOST_IOS::seekdir way)
+ std::streampos seek(Device& dev, stream_offset off, BOOST_IOS::seekdir way)
{
stream_offset next;
if (way == BOOST_IOS::beg) {
@@ -159,12 +159,12 @@
pos_ = this->component().seek(dev, off, BOOST_IOS::end);
if (pos_ < beg_)
bad_seek();
- return pos_ - beg_;
+ return offset_to_position(pos_ - beg_);
}
if (next < beg_ || end_ != -1 && next >= end_)
bad_seek();
pos_ = this->component().seek(dev, next, BOOST_IOS::cur);
- return pos_ - beg_;
+ return offset_to_position(pos_ - beg_);
}
private:
template<typename Device>
@@ -329,7 +329,7 @@
}
template<typename Device>
-stream_offset restricted_indirect_device<Device>::seek
+std::streampos restricted_indirect_device<Device>::seek
(stream_offset off, BOOST_IOS::seekdir way)
{
stream_offset next;
@@ -344,12 +344,12 @@
pos_ = iostreams::seek(this->component(), off, BOOST_IOS::end);
if (pos_ < beg_)
bad_seek();
- return pos_ - beg_;
+ return offset_to_position(pos_ - beg_);
}
if (next < beg_ || end_ != -1 && next >= end_)
bad_seek();
pos_ = iostreams::seek(this->component(), next - pos_, BOOST_IOS::cur);
- return pos_ - beg_;
+ return offset_to_position(pos_ - beg_);
}
//--------------Implementation of
restricted_direct_device--------------------//
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Boost-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/boost-cvs