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.

This commit is contained in:
Beman
2014-09-03 17:27:41 -04:00
parent 5ef03bffe3
commit 26cf086520
2 changed files with 21 additions and 8 deletions

View File

@@ -14,7 +14,7 @@
/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// utf8_codecvt_facet.hpp // utf8_codecvt_facet.hpp
// This header defines class utf8_codecvt_facet, derived fro // This header defines class utf8_codecvt_facet, derived from
// std::codecvt<wchar_t, char>, which can be used to convert utf8 data in // std::codecvt<wchar_t, char>, which can be used to convert utf8 data in
// files into wchar_t strings in the application. // files into wchar_t strings in the application.
// //
@@ -28,12 +28,13 @@
// This seems inconvenient, and asking a user to link to an unrevieved // This seems inconvenient, and asking a user to link to an unrevieved
// library is strange. // library is strange.
// Until the above points are fixed, a library which wants to use utf8 must: // 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 this header in one of it's headers or sources
// - include the corresponding .cpp file from one of the sources // - include the corresponding boost/detail/utf8_codecvt_facet.ipp file in one
// of its sources
// - before including either file, the library must define // - before including either file, the library must define
// - BOOST_UTF8_BEGIN_NAMESPACE to the namespace declaration that must be used // - BOOST_UTF8_BEGIN_NAMESPACE to the namespace declaration that must be used
// - BOOST_UTF8_END_NAMESPACE to the code to close the previous namespace // - 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' // - BOOST_UTF8_DECL -- to the code which must be used for all 'exportable'
// symbols. // symbols.
// //
@@ -42,7 +43,7 @@
// namespace boost { namespace program_options { // namespace boost { namespace program_options {
// #define BOOST_UTF8_END_NAMESPACE }} // #define BOOST_UTF8_END_NAMESPACE }}
// #define BOOST_UTF8_DECL BOOST_PROGRAM_OPTIONS_DECL // #define BOOST_UTF8_DECL BOOST_PROGRAM_OPTIONS_DECL
// #include "../../detail/utf8/utf8_codecvt.cpp" // #include <boost/detail/utf8_codecvt_facet.ipp>
// //
// Essentially, each library will have its own copy of utf8 code, in // Essentially, each library will have its own copy of utf8 code, in
// different namespaces. // different namespaces.
@@ -92,7 +93,7 @@ namespace std {
} }
#endif #endif
#if !defined(__MSL_CPP__) && !defined(__LIBCOMO__) #if defined(_CPPLIB_VER) && (_CPPLIB_VER < 540)
#define BOOST_CODECVT_DO_LENGTH_CONST const #define BOOST_CODECVT_DO_LENGTH_CONST const
#else #else
#define BOOST_CODECVT_DO_LENGTH_CONST #define BOOST_CODECVT_DO_LENGTH_CONST
@@ -103,6 +104,14 @@ namespace std {
BOOST_UTF8_BEGIN_NAMESPACE BOOST_UTF8_BEGIN_NAMESPACE
//----------------------------------------------------------------------------//
// //
// utf8_codecvt_facet //
// //
// See utf8_codecvt_facet.ipp for the implementation. //
//----------------------------------------------------------------------------//
struct BOOST_UTF8_DECL utf8_codecvt_facet : struct BOOST_UTF8_DECL utf8_codecvt_facet :
public std::codecvt<wchar_t, char, std::mbstate_t> public std::codecvt<wchar_t, char, std::mbstate_t>
{ {
@@ -178,7 +187,11 @@ protected:
const char * from, const char * from,
const char * from_end, const char * from_end,
std::size_t max_limit 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. // Largest possible value do_length(state,from,from_end,1) could return.
virtual int do_max_length() const BOOST_NOEXCEPT_OR_NOTHROW { virtual int do_max_length() const BOOST_NOEXCEPT_OR_NOTHROW {

View File

@@ -171,7 +171,7 @@ std::codecvt_base::result utf8_codecvt_facet::do_out(
// How many char objects can I process to get <= max_limit // How many char objects can I process to get <= max_limit
// wchar_t objects? // wchar_t objects?
int utf8_codecvt_facet::do_length( int utf8_codecvt_facet::do_length(
const std::mbstate_t &, BOOST_CODECVT_DO_LENGTH_CONST std::mbstate_t &,
const char * from, const char * from,
const char * from_end, const char * from_end,
std::size_t max_limit std::size_t max_limit