#define _CPP_BITS_CODECVT_H 1
#ifdef _GLIBCPP_USE_WCHAR_T
-// #include <localefwd.h>
-// XXX include iconv here or higher up....
#include <iconv.h> // For iconv, iconv_t
+#include <langinfo.h>
#endif
namespace std
// including conversions and comparisons between various character
// sets. This object encapsulates data that may need to be shared between
// char_traits, codecvt and ctype.
- template<typename _InternT, typename _ExternT>
class __enc_traits
{
public:
// Types:
- typedef _InternT __intc_type;
- typedef _ExternT __extc_type;
typedef iconv_t __conv_type;
typedef mbstate_t __state_type;
+ protected:
// Data Members:
// Max size of charset encoding name
static const int __max_size = 32;
char __extc_enc[__max_size];
// Conversion descriptor between external encoding to internal encoding.
- __conv_type __in_conv;
+ __conv_type __in_desc;
// Conversion descriptor between internal encoding to external encoding.
- __conv_type __out_conv;
+ __conv_type __out_desc;
- __enc_traits()
+ public:
+ __enc_traits() : __in_desc(0), __out_desc(0)
{
// __intc_end = whatever we are using internally, which is
// UCS4 (linux)
- // UCS2 (microsoft, java, aix, whatever...)
+ // UCS2 == UNICODE (microsoft, java, aix, whatever...)
// XXX Currently don't know how to get this data from target system...
strcpy(__intc_enc, "UCS4");
// __extc_end = external codeset in current locale
strcpy(__extc_enc, nl_langinfo(CODESET));
- __in_conv = iconv_open(__intc_enc, __extc_enc);
- __out_conv = iconv_open(__extc_enc, __intc_enc);
- if (__out_conv == (iconv_t) -1 || __in_conv == (iconv_t) -1)
- {
- // XXX Extended error checking.
- }
}
__enc_traits(const char* __int, const char* __ext)
+ : __in_desc(0), __out_desc(0)
{
strcpy(__intc_enc, __int);
strcpy(__extc_enc, __ext);
- __in_conv = iconv_open(__intc_enc, __extc_enc);
- __out_conv = iconv_open(__extc_enc, __intc_enc);
- if (__out_conv == (iconv_t) -1 || __in_conv == (iconv_t) -1)
- {
- // XXX Extended error checking.
- }
}
~__enc_traits()
{
- iconv_close(__in_conv);
- iconv_close(__out_conv);
+ iconv_close(__in_desc);
+ iconv_close(__out_desc);
}
- const char*
- _M_get_intc_enc(void)
- { return __intc_enc; }
-
+ // Initializes
void
- _M_set_intc_enc(const char* __c)
- { strcpy(__intc_enc, __c); }
+ _M_init()
+ {
+ __in_desc = iconv_open(__intc_enc, __extc_enc);
+ __out_desc = iconv_open(__extc_enc, __intc_enc);
+ if (__out_desc == (iconv_t) -1 || __in_desc == (iconv_t) -1)
+ {
+ // XXX Extended error checking.
+ }
+ }
+
+ bool
+ _M_good()
+ {
+ return __out_desc && __in_desc
+ && __out_desc != iconv_t(-1) && __in_desc != iconv_t(-1);
+ }
+
+ const __conv_type*
+ _M_get_in_descriptor()
+ { return &__in_desc; }
+
+ const __conv_type*
+ _M_get_out_descriptor()
+ { return &__out_desc; }
+
+ const char*
+ _M_get_internal_enc()
+ { return __intc_enc; }
const char*
- _M_get_extc_enc(void)
+ _M_get_external_enc()
{ return __extc_enc; }
- void
- _M_set_extc_enc(const char* __c)
- { strcpy(__extc_enc, __c); }
-
protected:
// 21.1.2 traits typedefs
// p4
{
public:
// Types:
- typedef _InternT intern_type;
- typedef _ExternT extern_type;
- typedef _StateT state_type;
+ typedef codecvt_base::result result;
+ typedef _InternT intern_type;
+ typedef _ExternT extern_type;
+ typedef _StateT state_type;
// 22.2.1.5.1 codecvt members
result
out(state_type& __state, const intern_type* __from,
const intern_type* __from_end, const intern_type*& __from_next,
- extern_type* __to, extern_type* __to_limit,
+ extern_type* __to, extern_type* __to_end,
extern_type*& __to_next) const
{
return this->do_out(__state, __from, __from_end, __from_next,
- __to, __to_limit, __to_next);
+ __to, __to_end, __to_next);
}
result
- unshift(state_type& __state, extern_type* __to, extern_type* __to_limit,
+ unshift(state_type& __state, extern_type* __to, extern_type* __to_end,
extern_type*& __to_next) const
- { return this->do_unshift(__state, __to,__to_limit,__to_next); }
+ { return this->do_unshift(__state, __to,__to_end,__to_next); }
result
in(state_type& __state, const extern_type* __from,
const extern_type* __from_end, const extern_type*& __from_next,
- intern_type* __to, intern_type* __to_limit,
+ intern_type* __to, intern_type* __to_end,
intern_type*& __to_next) const
{
return this->do_in(__state, __from, __from_end, __from_next,
- __to, __to_limit, __to_next);
+ __to, __to_end, __to_next);
}
int
virtual result
do_out(state_type& __state, const intern_type* __from,
const intern_type* __from_end, const intern_type*& __from_next,
- extern_type* __to, extern_type* __to_limit,
+ extern_type* __to, extern_type* __to_end,
extern_type*& __to_next) const = 0;
virtual result
do_unshift(state_type& __state, extern_type* __to,
- extern_type* __to_limit, extern_type*& __to_next) const = 0;
+ extern_type* __to_end, extern_type*& __to_next) const = 0;
virtual result
do_in(state_type& __state, const extern_type* __from,
const extern_type* __from_end, const extern_type*& __from_next,
- intern_type* __to, intern_type* __to_limit,
+ intern_type* __to, intern_type* __to_end,
intern_type*& __to_next) const = 0;
virtual int
{
public:
// Types:
+ typedef codecvt_base::result result;
typedef _InternT intern_type;
typedef _ExternT extern_type;
typedef _StateT state_type;
locale::id codecvt<_InternT, _ExternT, _StateT>::id;
// partial specialization
+ // This specialization takes advantage of iconv to provide code
+ // conversions between a large number of character encodings.
template<typename _InternT, typename _ExternT>
- class codecvt<_InternT, _ExternT, __enc_traits<_InternT, _ExternT> >
- : public __codecvt_abstract_base<_InternT,
- _ExternT, __enc_traits<_InternT, _ExternT> >
- { };
+ class codecvt<_InternT, _ExternT, __enc_traits>
+ : public __codecvt_abstract_base<_InternT, _ExternT, __enc_traits>
+ {
+ public:
+ // Types:
+ typedef codecvt_base::result result;
+ typedef _InternT intern_type;
+ typedef _ExternT extern_type;
+ typedef __enc_traits state_type;
+ typedef __enc_traits::__conv_type __conv_type;
+ typedef __enc_traits __enc_type;
+
+ // Data Members:
+ static locale::id id;
+
+ explicit
+ codecvt(size_t __refs = 0)
+ : __codecvt_abstract_base<intern_type, extern_type, state_type>(__refs)
+ { }
+
+ explicit
+ codecvt(__enc_type* __enc, size_t __refs = 0)
+ : __codecvt_abstract_base<intern_type, extern_type, state_type>(__refs)
+ { }
+
+ protected:
+ virtual
+ ~codecvt() { }
+
+ virtual result
+ do_out(state_type& __state, const intern_type* __from,
+ const intern_type* __from_end, const intern_type*& __from_next,
+ extern_type* __to, extern_type* __to_end,
+ extern_type*& __to_next) const;
+
+ virtual result
+ do_unshift(state_type& __state, extern_type* __to,
+ extern_type* __to_end, extern_type*& __to_next) const;
+
+ virtual result
+ do_in(state_type& __state, const extern_type* __from,
+ const extern_type* __from_end, const extern_type*& __from_next,
+ intern_type* __to, intern_type* __to_end,
+ intern_type*& __to_next) const;
+
+ virtual int
+ do_encoding() const throw();
+
+ virtual bool
+ do_always_noconv() const throw();
+
+ virtual int
+ do_length(const state_type&, const extern_type* __from,
+ const extern_type* __end, size_t __max) const;
+
+ virtual int
+ do_max_length() const throw();
+ };
+
+ template<typename _InternT, typename _ExternT>
+ locale::id
+ codecvt<_InternT, _ExternT, __enc_traits>::id;
+
+ template<typename _InternT, typename _ExternT>
+ codecvt_base::result
+ codecvt<_InternT, _ExternT, __enc_traits>::
+ do_out(state_type& __state, const intern_type* __from,
+ const intern_type* __from_end, const intern_type*& __from_next,
+ extern_type* __to, extern_type* __to_end,
+ extern_type*& __to_next) const
+ {
+ result __ret = error;
+ if (__state._M_good())
+ {
+ typedef state_type::__conv_type __conv_type;
+ const __conv_type* __desc = __state._M_get_out_descriptor();
+ const size_t __fmultiple = sizeof(intern_type) / sizeof(char);
+ size_t __flen = __fmultiple * (__from_end - __from);
+ const size_t __tmultiple = sizeof(extern_type) / sizeof(char);
+ size_t __tlen = __tmultiple * (__to_end - __to);
+
+ // Argument list for iconv specifies a byte sequence. Thus,
+ // all to/from arrays must be brutally casted to char*.
+ const char* __cfrom = reinterpret_cast<const char*>(__from);
+ char* __cto = reinterpret_cast<char*>(__to);
+ size_t __conv = iconv(*__desc, &__cfrom, &__flen, &__cto, &__tlen);
+
+ if (__conv != size_t(-1))
+ {
+ __from_next = reinterpret_cast<const intern_type*>(__cfrom);
+ __to_next = reinterpret_cast<extern_type*>(__cto);
+ __ret = ok;
+ }
+ else
+ {
+ if (__flen < __from_end - __from)
+ {
+ __from_next = reinterpret_cast<const intern_type*>(__cfrom);
+ __to_next = reinterpret_cast<extern_type*>(__cto);
+ __ret = partial;
+ }
+ else
+ __ret = error;
+ }
+ }
+ return __ret;
+ }
+
+ template<typename _InternT, typename _ExternT>
+ codecvt_base::result
+ codecvt<_InternT, _ExternT, __enc_traits>::
+ do_unshift(state_type& __state, extern_type* __to,
+ extern_type* __to_end, extern_type*& __to_next) const
+ {
+ result __ret = error;
+ if (__state._M_good())
+ {
+ typedef state_type::__conv_type __conv_type;
+ const __conv_type* __desc = __state._M_get_in_descriptor();
+ const size_t __tmultiple = sizeof(intern_type) / sizeof(char);
+ size_t __tlen = __tmultiple * (__to_end - __to);
+
+ // Argument list for iconv specifies a byte sequence. Thus,
+ // all to/from arrays must be brutally casted to char*.
+ char* __cto = reinterpret_cast<char*>(__to);
+ size_t __conv = iconv(*__desc, NULL, NULL, &__cto, &__tlen);
+
+ if (__conv != size_t(-1))
+ {
+ __to_next = reinterpret_cast<extern_type*>(__cto);
+ __ret = ok;
+ }
+ else
+ __ret = error;
+ }
+ return __ret;
+ }
+
+ template<typename _InternT, typename _ExternT>
+ codecvt_base::result
+ codecvt<_InternT, _ExternT, __enc_traits>::
+ do_in(state_type& __state, const extern_type* __from,
+ const extern_type* __from_end, const extern_type*& __from_next,
+ intern_type* __to, intern_type* __to_end,
+ intern_type*& __to_next) const
+ {
+ result __ret = error;
+ if (__state._M_good())
+ {
+ typedef state_type::__conv_type __conv_type;
+ const __conv_type* __desc = __state._M_get_in_descriptor();
+ const size_t __fmultiple = sizeof(extern_type) / sizeof(char);
+ size_t __flen = __fmultiple * (__from_end - __from);
+ const size_t __tmultiple = sizeof(intern_type) / sizeof(char);
+ size_t __tlen = __tmultiple * (__to_end - __to);
+
+ // Argument list for iconv specifies a byte sequence. Thus,
+ // all to/from arrays must be brutally casted to char*.
+ const char* __cfrom = reinterpret_cast<const char*>(__from);
+ char* __cto = reinterpret_cast<char*>(__to);
+ size_t __conv = iconv(*__desc, &__cfrom, &__flen, &__cto, &__tlen);
+
+ if (__conv != size_t(-1))
+ {
+ __from_next = reinterpret_cast<const extern_type*>(__cfrom);
+ __to_next = reinterpret_cast<intern_type*>(__cto);
+ __ret = ok;
+ }
+ else
+ {
+ if (__flen < __from_end - __from)
+ {
+ __from_next = reinterpret_cast<const extern_type*>(__cfrom);
+ __to_next = reinterpret_cast<intern_type*>(__cto);
+ __ret = partial;
+ }
+ else
+ __ret = error;
+ }
+ }
+ return __ret;
+ }
+
+ template<typename _InternT, typename _ExternT>
+ int
+ codecvt<_InternT, _ExternT, __enc_traits>::
+ do_encoding() const throw()
+ { return 0; }
+
+ template<typename _InternT, typename _ExternT>
+ bool
+ codecvt<_InternT, _ExternT, __enc_traits>::
+ do_always_noconv() const throw()
+ { return false; }
+
+ template<typename _InternT, typename _ExternT>
+ int
+ codecvt<_InternT, _ExternT, __enc_traits>::
+ do_length(const state_type& __state, const extern_type* __from,
+ const extern_type* __end, size_t __max) const
+ { return min(__max, static_cast<size_t>(__end - __from)); }
+
+#ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS
+// 74. Garbled text for codecvt::do_max_length
+ template<typename _InternT, typename _ExternT>
+ int
+ codecvt<_InternT, _ExternT, __enc_traits>::
+ do_max_length() const throw()
+ { return 1; }
+#endif
// codecvt<char, char, mbstate_t> required specialization
template<>
virtual result
do_out(state_type& __state, const intern_type* __from,
const intern_type* __from_end, const intern_type*& __from_next,
- extern_type* __to, extern_type* __to_limit,
+ extern_type* __to, extern_type* __to_end,
extern_type*& __to_next) const;
virtual result
do_unshift(state_type& __state, extern_type* __to,
- extern_type* __to_limit, extern_type*& __to_next) const;
+ extern_type* __to_end, extern_type*& __to_next) const;
virtual result
do_in(state_type& __state, const extern_type* __from,
const extern_type* __from_end, const extern_type*& __from_next,
- intern_type* __to, intern_type* __to_limit,
+ intern_type* __to, intern_type* __to_end,
intern_type*& __to_next) const;
virtual int
virtual result
do_out(state_type& __state, const intern_type* __from,
const intern_type* __from_end, const intern_type*& __from_next,
- extern_type* __to, extern_type* __to_limit,
+ extern_type* __to, extern_type* __to_end,
extern_type*& __to_next) const;
virtual result
do_unshift(state_type& __state,
- extern_type* __to, extern_type* __to_limit,
+ extern_type* __to, extern_type* __to_end,
extern_type*& __to_next) const;
virtual result
do_in(state_type& __state,
const extern_type* __from, const extern_type* __from_end,
const extern_type*& __from_next,
- intern_type* __to, intern_type* __to_limit,
+ intern_type* __to, intern_type* __to_end,
intern_type*& __to_next) const;
virtual
template<>
const ctype<char>&
- use_facet<const ctype<char> > (const locale& __loc);
+ use_facet<const ctype<char> >(const locale& __loc);
#ifdef _GLIBCPP_USE_WCHAR_T
// ctype<wchar_t> specialization
template<>
const ctype<wchar_t>&
- use_facet< const ctype<wchar_t> > (const locale& __loc);
+ use_facet< const ctype<wchar_t> >(const locale& __loc);
#endif //_GLIBCPP_USE_WCHAR_T
// Include host-specific ctype specializations.
template<typename _CharT>
inline bool
isspace(_CharT __c, const locale& __loc)
- { return use_facet<ctype<_CharT> > (__loc).is(ctype_base::space, __c); }
+ { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::space, __c); }
template<typename _CharT>
inline bool
isprint(_CharT __c, const locale& __loc)
- { return use_facet<ctype<_CharT> > (__loc).is(ctype_base::print, __c); }
+ { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::print, __c); }
template<typename _CharT>
inline bool
iscntrl(_CharT __c, const locale& __loc)
- { return use_facet<ctype<_CharT> > (__loc).is(ctype_base::cntrl, __c); }
+ { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::cntrl, __c); }
template<typename _CharT>
inline bool
isupper(_CharT __c, const locale& __loc)
- { return use_facet<ctype<_CharT> > (__loc).is(ctype_base::upper, __c); }
+ { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::upper, __c); }
template<typename _CharT>
inline bool islower(_CharT __c, const locale& __loc)
- { return use_facet<ctype<_CharT> > (__loc).is(ctype_base::lower, __c); }
+ { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::lower, __c); }
template<typename _CharT>
inline bool
isalpha(_CharT __c, const locale& __loc)
- { return use_facet<ctype<_CharT> > (__loc).is(ctype_base::alpha, __c); }
+ { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::alpha, __c); }
template<typename _CharT>
inline bool
isdigit(_CharT __c, const locale& __loc)
- { return use_facet<ctype<_CharT> > (__loc).is(ctype_base::digit, __c); }
+ { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::digit, __c); }
template<typename _CharT>
inline bool
ispunct(_CharT __c, const locale& __loc)
- { return use_facet<ctype<_CharT> > (__loc).is(ctype_base::punct, __c); }
+ { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::punct, __c); }
template<typename _CharT>
inline bool
isxdigit(_CharT __c, const locale& __loc)
- { return use_facet<ctype<_CharT> > (__loc).is(ctype_base::xdigit, __c); }
+ { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::xdigit, __c); }
template<typename _CharT>
inline bool
isalnum(_CharT __c, const locale& __loc)
- { return use_facet<ctype<_CharT> > (__loc).is(ctype_base::alnum, __c); }
+ { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::alnum, __c); }
template<typename _CharT>
inline bool
isgraph(_CharT __c, const locale& __loc)
- { return use_facet<ctype<_CharT> > (__loc).is(ctype_base::graph, __c); }
+ { return use_facet<ctype<_CharT> >(__loc).is(ctype_base::graph, __c); }
template<typename _CharT>
inline _CharT
toupper(_CharT __c, const locale& __loc)
- { return use_facet<ctype<_CharT> > (__loc).toupper(__c); }
+ { return use_facet<ctype<_CharT> >(__loc).toupper(__c); }
template<typename _CharT>
inline _CharT
tolower(_CharT __c, const locale& __loc)
- { return use_facet<ctype<_CharT> > (__loc).tolower(__c); }
+ { return use_facet<ctype<_CharT> >(__loc).tolower(__c); }
} // namespace std
namespace std {
+ // codecvt<char, char, mbstate_t> required specialization
locale::id codecvt<char, char, mbstate_t>::id;
codecvt<char, char, mbstate_t>::
extern_type* __to, extern_type* __to_end,
extern_type*& __to_next) const
{
- size_t __sizefrom = __from_end - __from;
- size_t __sizeto = __to_end - __to;
- size_t __length = __sizefrom <= __sizeto ? __sizefrom : __sizeto;
- memcpy(__to, __from, __length);
+ size_t __len = min(__from_end - __from, __to_end - __to);
+ memcpy(__to, __from, __len);
__from_next = __from;
__to_next = __to;
return noconv;
codecvt_base::result
codecvt<char, char, mbstate_t>::
do_unshift(state_type& /*__state*/, extern_type* __to,
- extern_type* /*__to_limit*/, extern_type*& __to_next) const
+ extern_type* /*__to_end*/, extern_type*& __to_next) const
{
__to_next = __to;
return noconv;
intern_type* __to, intern_type* __to_end,
intern_type*& __to_next) const
{
- size_t __sizefrom = __from_end - __from;
- size_t __sizeto = __to_end - __to;
- size_t __length = __sizefrom <= __sizeto ? __sizefrom : __sizeto;
- memcpy(__to, __from, __length);
+ size_t __len = min(__from_end - __from, __to_end - __to);
+ memcpy(__to, __from, __len);
__from_next = __from;
__to_next = __to;
return noconv;
int
codecvt<char, char, mbstate_t>::
- do_encoding() const throw() { return 1; }
+ do_encoding() const throw()
+ { return 1; }
bool
codecvt<char, char, mbstate_t>::
- do_always_noconv() const throw() { return true; }
+ do_always_noconv() const throw()
+ { return true; }
int
codecvt<char, char, mbstate_t>::
do_length (const state_type& /*__state*/, const extern_type* __from,
const extern_type* __end, size_t __max) const
- { return (__max < size_t(__end - __from)) ? __max : __end - __from; }
+ { return min(__max, static_cast<size_t>(__end - __from)); }
int
codecvt<char, char, mbstate_t>::
- do_max_length() const throw() { return 1; }
+ do_max_length() const throw()
+ { return 1; }
codecvt_byname<char, char, mbstate_t>::
codecvt_byname(const char* /*__s*/, size_t __refs)
~codecvt_byname() { }
#ifdef _GLIBCPP_USE_WCHAR_T
+ // codecvt<wchar_t, char, mbstate_t> required specialization
locale::id codecvt<wchar_t, char, mbstate_t>::id;
codecvt<wchar_t, char, mbstate_t>::
codecvt_base::result
codecvt<wchar_t, char, mbstate_t>::
- do_out(state_type& /*__state*/, const intern_type* __from,
+ do_out(state_type& __state, const intern_type* __from,
const intern_type* __from_end, const intern_type*& __from_next,
- extern_type* __to, extern_type* __to_limit,
+ extern_type* __to, extern_type* __to_end,
extern_type*& __to_next) const
{
- for (; __from < __from_end && __to < __to_limit; ++__from, ++__to)
- *__to = static_cast<char>(*__from);
- __from_next = __from; __to_next = __to;
- return __from == __from_end ? ok : partial;
+ result __ret = error;
+ size_t __len = min(__from_end - __from, __to_end - __to);
+ size_t __conv = wcsrtombs(__to, &__from, __len, &__state);
+
+ if (__conv == __len)
+ {
+ __from_next = __from;
+ __to_next = __to + __conv;
+ __ret = ok;
+ }
+ else if (__conv > 0 && __conv < __len)
+ {
+ __from_next = __from;
+ __to_next = __to + __conv;
+ __ret = partial;
+ }
+ else
+ __ret = error;
+
+ return __ret;
}
codecvt_base::result
codecvt<wchar_t, char, mbstate_t>::
- do_unshift (state_type& /*__state*/, extern_type* __to,
- extern_type* /*__to_limit*/, extern_type*& __to_next) const
+ do_unshift(state_type& /*__state*/, extern_type* __to,
+ extern_type* /*__to_end*/, extern_type*& __to_next) const
{
__to_next = __to;
return noconv;
codecvt_base::result
codecvt<wchar_t, char, mbstate_t>::
- do_in(state_type& /*__state*/, const extern_type* __from,
+ do_in(state_type& __state, const extern_type* __from,
const extern_type* __from_end, const extern_type*& __from_next,
- intern_type* __to, intern_type* __to_limit,
+ intern_type* __to, intern_type* __to_end,
intern_type*& __to_next) const
{
- for (; __from < __from_end && __to < __to_limit; ++__from, ++__to)
- *__to = static_cast<wchar_t>(*__from);
- __from_next = __from;
- __to_next = __to;
- return __from == __from_end ? ok : partial;
+ result __ret = error;
+ size_t __len = min(__from_end - __from, __to_end - __to);
+ size_t __conv = mbsrtowcs(__to, &__from, __len, &__state);
+
+ if (__conv == __len)
+ {
+ __from_next = __from;
+ __to_next = __to + __conv;
+ __ret = ok;
+ }
+ else if (__conv > 0 && __conv < __len)
+ {
+ __from_next = __from;
+ __to_next = __to + __conv;
+ __ret = partial;
+ }
+ else
+ __ret = error;
+
+ return __ret;
}
int
codecvt<wchar_t, char, mbstate_t>::
do_encoding() const throw()
- { return 1; }
+ { return 0; }
bool
codecvt<wchar_t, char, mbstate_t>::
codecvt<wchar_t, char, mbstate_t>::
do_length(const state_type& /*__state*/, const extern_type* __from,
const extern_type* __end, size_t __max) const
- { return (__max < size_t(__end - __from)) ? __max : __end - __from; }
-
+ { return min(__max, static_cast<size_t>(__end - __from)); }
+
int
- codecvt<wchar_t, char, mbstate_t>::do_max_length() const throw()
+ codecvt<wchar_t, char, mbstate_t>::
+ do_max_length() const throw()
{ return 1; }
codecvt_byname<wchar_t, char, mbstate_t>::