diff --git a/include/boost/archive/detail/utf8_codecvt_facet.hpp b/include/boost/archive/detail/utf8_codecvt_facet.hpp index a40104ab..00b2b419 100644 --- a/include/boost/archive/detail/utf8_codecvt_facet.hpp +++ b/include/boost/archive/detail/utf8_codecvt_facet.hpp @@ -13,27 +13,17 @@ #error "wide char i/o not supported on this platform" #endif -// std::codecvt_utf8 doesn't seem to work for any versions of msvc +// use boost's utf8 codecvt facet +#include +#define BOOST_UTF8_BEGIN_NAMESPACE \ + namespace boost { namespace archive { namespace detail { +#define BOOST_UTF8_DECL BOOST_ARCHIVE_DECL +#define BOOST_UTF8_END_NAMESPACE }}} -#if defined(_MSC_VER) || defined(BOOST_NO_CXX11_HDR_CODECVT) - // use boost's utf8 codecvt facet - #include - #define BOOST_UTF8_BEGIN_NAMESPACE \ - namespace boost { namespace archive { namespace detail { - #define BOOST_UTF8_DECL BOOST_ARCHIVE_DECL - #define BOOST_UTF8_END_NAMESPACE }}} +#include - #include - - #undef BOOST_UTF8_END_NAMESPACE - #undef BOOST_UTF8_DECL - #undef BOOST_UTF8_BEGIN_NAMESPACE -#else - // use the standard vendor supplied facet - #include - namespace boost { namespace archive { namespace detail { - typedef std::codecvt_utf8 utf8_codecvt_facet; - } } } -#endif +#undef BOOST_UTF8_END_NAMESPACE +#undef BOOST_UTF8_DECL +#undef BOOST_UTF8_BEGIN_NAMESPACE #endif // BOOST_ARCHIVE_DETAIL_UTF8_CODECVT_FACET_HPP diff --git a/include/boost/archive/impl/xml_wiarchive_impl.ipp b/include/boost/archive/impl/xml_wiarchive_impl.ipp index ee66c126..f572b762 100644 --- a/include/boost/archive/impl/xml_wiarchive_impl.ipp +++ b/include/boost/archive/impl/xml_wiarchive_impl.ipp @@ -161,13 +161,13 @@ xml_wiarchive_impl::xml_wiarchive_impl( gimpl(new xml_wgrammar()) { if(0 == (flags & no_codecvt)){ - std::locale l = std::locale( + archive_locale = std::locale( is_.getloc(), new boost::archive::detail::utf8_codecvt_facet ); // libstdc++ crashes without this is_.sync(); - is_.imbue(l); + is_.imbue(archive_locale); } if(0 == (flags & no_header)) init(); diff --git a/include/boost/archive/impl/xml_woarchive_impl.ipp b/include/boost/archive/impl/xml_woarchive_impl.ipp index 01b1a052..630898b8 100644 --- a/include/boost/archive/impl/xml_woarchive_impl.ipp +++ b/include/boost/archive/impl/xml_woarchive_impl.ipp @@ -103,7 +103,6 @@ xml_woarchive_impl::save(const char * s){ template BOOST_WARCHIVE_DECL void xml_woarchive_impl::save(const wchar_t * ws){ - os << ws; typedef iterators::xml_escape xmbtows; std::copy( xmbtows(ws), @@ -126,12 +125,12 @@ xml_woarchive_impl::xml_woarchive_impl( basic_xml_oarchive(flags) { if(0 == (flags & no_codecvt)){ - std::locale l = std::locale( + archive_locale = std::locale( os_.getloc(), new boost::archive::detail::utf8_codecvt_facet ); os_.flush(); - os_.imbue(l); + os_.imbue(archive_locale); } if(0 == (flags & no_header)) this->init(); @@ -143,7 +142,7 @@ xml_woarchive_impl::~xml_woarchive_impl(){ if(std::uncaught_exception()) return; if(0 == (this->get_flags() & no_header)){ - save(L"\n"); + os << L""; } } diff --git a/include/boost/archive/xml_wiarchive.hpp b/include/boost/archive/xml_wiarchive.hpp index ac24289a..2ca3e559 100644 --- a/include/boost/archive/xml_wiarchive.hpp +++ b/include/boost/archive/xml_wiarchive.hpp @@ -62,6 +62,7 @@ protected: friend class basic_xml_iarchive; friend class load_access; #endif + std::locale archive_locale; boost::scoped_ptr gimpl; std::wistream & get_is(){ return is; diff --git a/src/archive_exception.cpp b/src/archive_exception.cpp index 8fcc6eeb..729a4edb 100644 --- a/src/archive_exception.cpp +++ b/src/archive_exception.cpp @@ -77,6 +77,14 @@ archive_exception::archive_exception( break; case input_stream_error: length = append(length, "input stream error"); + if(NULL != e1){ + length = append(length, "-"); + length = append(length, e1); + } + if(NULL != e2){ + length = append(length, "-"); + length = append(length, e2); + } break; case invalid_class_name: length = append(length, "class name too long"); @@ -105,6 +113,14 @@ archive_exception::archive_exception( break; case output_stream_error: length = append(length, "output stream error"); + if(NULL != e1){ + length = append(length, "-"); + length = append(length, e1); + } + if(NULL != e2){ + length = append(length, "-"); + length = append(length, e2); + } break; default: BOOST_ASSERT(false); diff --git a/src/basic_archive.cpp b/src/basic_archive.cpp index 54d24b90..6c3386e7 100644 --- a/src/basic_archive.cpp +++ b/src/basic_archive.cpp @@ -77,10 +77,12 @@ BOOST_ARCHIVE_SIGNATURE(){ // 13- simplified visibility, removed Borland, removed pfto // 14- improved visibility, refactor map/set // 15- corrections to optional and collection loading +// 16- eliminated dependency on which is buggy in some libraries +// and now officially deprecated in the standard BOOST_SYMBOL_VISIBLE library_version_type BOOST_ARCHIVE_VERSION(){ - return library_version_type(15); + return library_version_type(16); } } // namespace archive diff --git a/src/basic_xml_grammar.ipp b/src/basic_xml_grammar.ipp index f028f8fc..dcec1cc6 100644 --- a/src/basic_xml_grammar.ipp +++ b/src/basic_xml_grammar.ipp @@ -21,6 +21,9 @@ # pragma warning(disable : 4244 4511 4512) #endif +#include // errno +#include // strerror(errno) + // spirit stuff #include #include @@ -31,7 +34,6 @@ #endif // for head_iterator test -//#include #include #include @@ -188,8 +190,14 @@ bool basic_xml_grammar::my_parse( for(;;){ CharType result; is.get(result); - if(is.fail()) - return false; + if(is.fail()){ + boost::serialization::throw_exception( + boost::archive::archive_exception( + archive_exception::input_stream_error, + std::strerror(errno) + ) + ); + } if(is.eof()) return false; arg += result; diff --git a/src/utf8_codecvt_facet.cpp b/src/utf8_codecvt_facet.cpp index c213c7f9..f6550d07 100644 --- a/src/utf8_codecvt_facet.cpp +++ b/src/utf8_codecvt_facet.cpp @@ -9,18 +9,14 @@ #error "wide char i/o not supported on this platform" #endif -// std::codecvt_utf8 doesn't seem to work for any versions of msvc -#if defined(_MSC_VER) \ -|| defined( BOOST_NO_CXX11_HDR_CODECVT ) - // include boost implementation of utf8 codecvt facet - # define BOOST_ARCHIVE_SOURCE - #include - #define BOOST_UTF8_BEGIN_NAMESPACE \ - namespace boost { namespace archive { namespace detail { - #define BOOST_UTF8_DECL BOOST_ARCHIVE_DECL - #define BOOST_UTF8_END_NAMESPACE }}} - #include - #undef BOOST_UTF8_END_NAMESPACE - #undef BOOST_UTF8_DECL - #undef BOOST_UTF8_BEGIN_NAMESPACE -#endif +// include boost implementation of utf8 codecvt facet +# define BOOST_ARCHIVE_SOURCE +#include +#define BOOST_UTF8_BEGIN_NAMESPACE \ + namespace boost { namespace archive { namespace detail { +#define BOOST_UTF8_DECL BOOST_ARCHIVE_DECL +#define BOOST_UTF8_END_NAMESPACE }}} +#include +#undef BOOST_UTF8_END_NAMESPACE +#undef BOOST_UTF8_DECL +#undef BOOST_UTF8_BEGIN_NAMESPACE diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 99e0a3d2..3aab6169 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -147,11 +147,7 @@ if ! $(BOOST_ARCHIVE_LIST) { [ test-bsl-run test_iterators ] [ test-bsl-run test_iterators_base64 ] [ test-bsl-run test_smart_cast ] - [ test-bsl-run test_codecvt_null - : ../src/codecvt_null - : - : [ requires std_wstreambuf ] - ] + [ test-bsl-run test_codecvt_null ] #[ test-bsl-run test_z ]