From 26cf0865201d710b436f5f124826305b9d10201b Mon Sep 17 00:00:00 2001 From: Beman Date: Wed, 3 Sep 2014 17:27:41 -0400 Subject: [PATCH] Fix #10354 from Juan Alday. As he pointed out, the declaration (in detail/utf8_codecvt_facet.hpp) and definition (in detail/utf8_codecvt_facet.ipp) need to use the same signature. Reapply Marshall Clow's [SVN r81616] and [SVN r81877] from November and December, 2012, as these appear to correctly supply const for the msvc/dinkumware library (since fixed) that used a do_length() first argument. Revert the portion of [SVN r86722] that removed BOOST_CODECVT_DO_LENGTH_CONST from the do_length() signature in utf8_codecvt_facet.ipp so that it stays in sync with utf8_codecvt_facet.hpp. For the same reason, copy the __IBMCPP__ workaround from utf8_codecvt_facet.ipp to utf8_codecvt_facet.hpp. Verified all libraries (filesystem, log, program_options, property_tree, serialization) that use utf8_codecvt_facet passed all tests before, and then after, these changes. Also applied minor edits to the use comments embedded in utf8_codecvt_facet.hpp. --- include/boost/detail/utf8_codecvt_facet.hpp | 27 +++++++++++++++------ include/boost/detail/utf8_codecvt_facet.ipp | 2 +- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/include/boost/detail/utf8_codecvt_facet.hpp b/include/boost/detail/utf8_codecvt_facet.hpp index 753b339..1e78b38 100644 --- a/include/boost/detail/utf8_codecvt_facet.hpp +++ b/include/boost/detail/utf8_codecvt_facet.hpp @@ -14,7 +14,7 @@ /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 // utf8_codecvt_facet.hpp -// This header defines class utf8_codecvt_facet, derived fro +// This header defines class utf8_codecvt_facet, derived from // std::codecvt, which can be used to convert utf8 data in // files into wchar_t strings in the application. // @@ -28,12 +28,13 @@ // This seems inconvenient, and asking a user to link to an unrevieved // library is strange. // Until the above points are fixed, a library which wants to use utf8 must: -// - include this header from one of it's headers or sources -// - include the corresponding .cpp file from one of the sources +// - include this header in one of it's headers or sources +// - include the corresponding boost/detail/utf8_codecvt_facet.ipp file in one +// of its sources // - before including either file, the library must define // - BOOST_UTF8_BEGIN_NAMESPACE to the namespace declaration that must be used // - BOOST_UTF8_END_NAMESPACE to the code to close the previous namespace -// - declaration. +// declaration. // - BOOST_UTF8_DECL -- to the code which must be used for all 'exportable' // symbols. // @@ -42,7 +43,7 @@ // namespace boost { namespace program_options { // #define BOOST_UTF8_END_NAMESPACE }} // #define BOOST_UTF8_DECL BOOST_PROGRAM_OPTIONS_DECL -// #include "../../detail/utf8/utf8_codecvt.cpp" +// #include // // Essentially, each library will have its own copy of utf8 code, in // different namespaces. @@ -92,7 +93,7 @@ namespace std { } #endif -#if !defined(__MSL_CPP__) && !defined(__LIBCOMO__) +#if defined(_CPPLIB_VER) && (_CPPLIB_VER < 540) #define BOOST_CODECVT_DO_LENGTH_CONST const #else #define BOOST_CODECVT_DO_LENGTH_CONST @@ -103,6 +104,14 @@ namespace std { BOOST_UTF8_BEGIN_NAMESPACE +//----------------------------------------------------------------------------// +// // +// utf8_codecvt_facet // +// // +// See utf8_codecvt_facet.ipp for the implementation. // +//----------------------------------------------------------------------------// + + struct BOOST_UTF8_DECL utf8_codecvt_facet : public std::codecvt { @@ -178,7 +187,11 @@ protected: const char * from, const char * from_end, std::size_t max_limit - ) const; + ) const +#if BOOST_WORKAROUND(__IBMCPP__, BOOST_TESTED_AT(600)) + throw() +#endif + ; // Largest possible value do_length(state,from,from_end,1) could return. virtual int do_max_length() const BOOST_NOEXCEPT_OR_NOTHROW { diff --git a/include/boost/detail/utf8_codecvt_facet.ipp b/include/boost/detail/utf8_codecvt_facet.ipp index d39170f..e08c9e0 100644 --- a/include/boost/detail/utf8_codecvt_facet.ipp +++ b/include/boost/detail/utf8_codecvt_facet.ipp @@ -171,7 +171,7 @@ std::codecvt_base::result utf8_codecvt_facet::do_out( // How many char objects can I process to get <= max_limit // wchar_t objects? int utf8_codecvt_facet::do_length( - const std::mbstate_t &, + BOOST_CODECVT_DO_LENGTH_CONST std::mbstate_t &, const char * from, const char * from_end, std::size_t max_limit