Commit ffe9f785 by Benjamin Kosnik Committed by Benjamin Kosnik

codecvt.html: Add more bits, format.


2000-08-28  Benjamin Kosnik  <bkoz@purist.soma.redhat.com>

	* docs/22_locale/codecvt.html: Add more bits, format.
	* bits/codecvt.h: Add copy ctor, rename types.
	* testsuite/22_locale/codecvt_unicode_char.cc: Tweak.

	* libio/iofwide.c: Tweak.

From-SVN: r36032
parent 484fde94
2000-08-28 Benjamin Kosnik <bkoz@purist.soma.redhat.com> 2000-08-28 Benjamin Kosnik <bkoz@purist.soma.redhat.com>
* docs/22_locale/codecvt.html: Add more bits, format. * docs/22_locale/codecvt.html: Add more bits, format.
* bits/codecvt.h: Add copy ctor, rename types.
* testsuite/22_locale/codecvt_unicode_char.cc: Tweak.
* libio/iofwide.c: Tweak.
2000-08-28 Phil Edwards <pme@sources.redhat.com> 2000-08-28 Phil Edwards <pme@sources.redhat.com>
* docs/configopts.html: Mention new options. * docs/configopts.html: Mention new options.
......
...@@ -45,7 +45,7 @@ ...@@ -45,7 +45,7 @@
namespace std namespace std
{ {
// XXX __enc_traits may need to move up the locale header heirarchy, // XXX __enc_traits may need to move up the locale header hierarchy,
// depending on if ctype ends up using it. // depending on if ctype ends up using it.
#ifdef _GLIBCPP_USE_WCHAR_T #ifdef _GLIBCPP_USE_WCHAR_T
// Extensions to use icov for dealing with character encodings, // Extensions to use icov for dealing with character encodings,
...@@ -55,9 +55,10 @@ namespace std ...@@ -55,9 +55,10 @@ namespace std
class __enc_traits class __enc_traits
{ {
public: public:
// Types: // Types:
typedef iconv_t __conv_type; // NB: A conversion descriptor subsumes and enhances the
typedef mbstate_t __state_type; // functionality of a simple state type such as mbstate_t.
typedef iconv_t __desc_type;
protected: protected:
// Data Members: // Data Members:
...@@ -69,9 +70,9 @@ namespace std ...@@ -69,9 +70,9 @@ namespace std
char __extc_enc[__max_size]; char __extc_enc[__max_size];
// Conversion descriptor between external encoding to internal encoding. // Conversion descriptor between external encoding to internal encoding.
__conv_type __in_desc; __desc_type __in_desc;
// Conversion descriptor between internal encoding to external encoding. // Conversion descriptor between internal encoding to external encoding.
__conv_type __out_desc; __desc_type __out_desc;
public: public:
__enc_traits() : __in_desc(0), __out_desc(0) __enc_traits() : __in_desc(0), __out_desc(0)
...@@ -89,8 +90,19 @@ namespace std ...@@ -89,8 +90,19 @@ namespace std
__enc_traits(const char* __int, const char* __ext) __enc_traits(const char* __int, const char* __ext)
: __in_desc(0), __out_desc(0) : __in_desc(0), __out_desc(0)
{ {
strcpy(__intc_enc, __int); strncpy(__intc_enc, __int, __max_size);
strcpy(__extc_enc, __ext); strncpy(__extc_enc, __ext, __max_size);
}
// 21.1.2 traits typedefs
// p4
// typedef STATE_T state_type
// requires: state_type shall meet the requirements of
// CopyConstructible types (20.1.3)
__enc_traits(const __enc_traits& __obj)
{
strncpy(__intc_enc, __obj.__intc_enc, __max_size);
strncpy(__extc_enc, __obj.__extc_enc, __max_size);
} }
~__enc_traits() ~__enc_traits()
...@@ -118,11 +130,11 @@ namespace std ...@@ -118,11 +130,11 @@ namespace std
&& __out_desc != iconv_t(-1) && __in_desc != iconv_t(-1); && __out_desc != iconv_t(-1) && __in_desc != iconv_t(-1);
} }
const __conv_type* const __desc_type*
_M_get_in_descriptor() _M_get_in_descriptor()
{ return &__in_desc; } { return &__in_desc; }
const __conv_type* const __desc_type*
_M_get_out_descriptor() _M_get_out_descriptor()
{ return &__out_desc; } { return &__out_desc; }
...@@ -133,15 +145,6 @@ namespace std ...@@ -133,15 +145,6 @@ namespace std
const char* const char*
_M_get_external_enc() _M_get_external_enc()
{ return __extc_enc; } { return __extc_enc; }
protected:
// 21.1.2 traits typedefs
// p4
// typedef STATE_T state_type
// requires: state_type shall meet the requirements of
// CopyConstructible types (20.1.3)
// XXX because of this, these might actually need to be filled out.
__enc_traits(const __enc_traits&);
}; };
#endif //_GLIBCPP_USE_WCHAR_T #endif //_GLIBCPP_USE_WCHAR_T
...@@ -295,7 +298,7 @@ namespace std ...@@ -295,7 +298,7 @@ namespace std
typedef _InternT intern_type; typedef _InternT intern_type;
typedef _ExternT extern_type; typedef _ExternT extern_type;
typedef __enc_traits state_type; typedef __enc_traits state_type;
typedef __enc_traits::__conv_type __conv_type; typedef __enc_traits::__desc_type __desc_type;
typedef __enc_traits __enc_type; typedef __enc_traits __enc_type;
// Data Members: // Data Members:
...@@ -360,8 +363,8 @@ namespace std ...@@ -360,8 +363,8 @@ namespace std
result __ret = error; result __ret = error;
if (__state._M_good()) if (__state._M_good())
{ {
typedef state_type::__conv_type __conv_type; typedef state_type::__desc_type __desc_type;
const __conv_type* __desc = __state._M_get_out_descriptor(); const __desc_type* __desc = __state._M_get_out_descriptor();
const size_t __fmultiple = sizeof(intern_type) / sizeof(char); const size_t __fmultiple = sizeof(intern_type) / sizeof(char);
size_t __flen = __fmultiple * (__from_end - __from); size_t __flen = __fmultiple * (__from_end - __from);
const size_t __tmultiple = sizeof(extern_type) / sizeof(char); const size_t __tmultiple = sizeof(extern_type) / sizeof(char);
...@@ -403,8 +406,8 @@ namespace std ...@@ -403,8 +406,8 @@ namespace std
result __ret = error; result __ret = error;
if (__state._M_good()) if (__state._M_good())
{ {
typedef state_type::__conv_type __conv_type; typedef state_type::__desc_type __desc_type;
const __conv_type* __desc = __state._M_get_in_descriptor(); const __desc_type* __desc = __state._M_get_in_descriptor();
const size_t __tmultiple = sizeof(intern_type) / sizeof(char); const size_t __tmultiple = sizeof(intern_type) / sizeof(char);
size_t __tlen = __tmultiple * (__to_end - __to); size_t __tlen = __tmultiple * (__to_end - __to);
...@@ -440,8 +443,8 @@ namespace std ...@@ -440,8 +443,8 @@ namespace std
result __ret = error; result __ret = error;
if (__state._M_good()) if (__state._M_good())
{ {
typedef state_type::__conv_type __conv_type; typedef state_type::__desc_type __desc_type;
const __conv_type* __desc = __state._M_get_in_descriptor(); const __desc_type* __desc = __state._M_get_in_descriptor();
const size_t __fmultiple = sizeof(extern_type) / sizeof(char); const size_t __fmultiple = sizeof(extern_type) / sizeof(char);
size_t __flen = __fmultiple * (__from_end - __from); size_t __flen = __fmultiple * (__from_end - __from);
const size_t __tmultiple = sizeof(intern_type) / sizeof(char); const size_t __tmultiple = sizeof(intern_type) / sizeof(char);
......
...@@ -155,6 +155,7 @@ _IO_fwide (fp, mode) ...@@ -155,6 +155,7 @@ _IO_fwide (fp, mode)
cares about systems which changing internal charsets they cares about systems which changing internal charsets they
should come up with a solution for the determination of the should come up with a solution for the determination of the
currently used internal character set. */ currently used internal character set. */
#if 0
const char *internal_ccs = _G_INTERNAL_CCS; const char *internal_ccs = _G_INTERNAL_CCS;
const char *external_ccs = nl_langinfo(CODESET); const char *external_ccs = nl_langinfo(CODESET);
...@@ -164,6 +165,7 @@ _IO_fwide (fp, mode) ...@@ -164,6 +165,7 @@ _IO_fwide (fp, mode)
cc->__cd_in = iconv_open (internal_ccs, external_ccs); cc->__cd_in = iconv_open (internal_ccs, external_ccs);
if (cc->__cd_in != (iconv_t) -1) if (cc->__cd_in != (iconv_t) -1)
cc->__cd_out = iconv_open (external_ccs, internal_ccs); cc->__cd_out = iconv_open (external_ccs, internal_ccs);
#endif
} }
# else # else
# error "somehow determine this from LC_CTYPE" # error "somehow determine this from LC_CTYPE"
......
...@@ -120,7 +120,7 @@ void test01() ...@@ -120,7 +120,7 @@ void test01()
const unicode_codecvt& cvt = use_facet<unicode_codecvt>(loc); const unicode_codecvt& cvt = use_facet<unicode_codecvt>(loc);
// in // in
unicode_codecvt::state_type state01("UNICODE", "ISO_8859-1"); unicode_codecvt::state_type state01("UNICODE", "ISO-8859-15");
initialize_state(state01); initialize_state(state01);
result r1 = cvt.in(state01, e_lit, e_lit + size, efrom_next, result r1 = cvt.in(state01, e_lit, e_lit + size, efrom_next,
i_arr, i_arr + size, ito_next); i_arr, i_arr + size, ito_next);
...@@ -130,7 +130,7 @@ void test01() ...@@ -130,7 +130,7 @@ void test01()
VERIFY( ito_next == i_arr + size ); VERIFY( ito_next == i_arr + size );
// out // out
unicode_codecvt::state_type state02("UNICODE", "ISO_8859-1"); unicode_codecvt::state_type state02("UNICODE", "ISO-8859-15");
initialize_state(state02); initialize_state(state02);
result r2 = cvt.out(state02, i_lit, i_lit + size, ifrom_next, result r2 = cvt.out(state02, i_lit, i_lit + size, ifrom_next,
e_arr, e_arr + size, eto_next); e_arr, e_arr + size, eto_next);
...@@ -141,7 +141,7 @@ void test01() ...@@ -141,7 +141,7 @@ void test01()
// unshift // unshift
ext_traits::copy(e_arr, e_lit, size); ext_traits::copy(e_arr, e_lit, size);
unicode_codecvt::state_type state03("UNICODE", "ISO_8859-1"); unicode_codecvt::state_type state03("UNICODE", "ISO-8859-15");
initialize_state(state03); initialize_state(state03);
result r3 = cvt.unshift(state03, e_arr, e_arr + size, eto_next); result r3 = cvt.unshift(state03, e_arr, e_arr + size, eto_next);
VERIFY( r3 == codecvt_base::noconv ); VERIFY( r3 == codecvt_base::noconv );
...@@ -153,7 +153,7 @@ void test01() ...@@ -153,7 +153,7 @@ void test01()
VERIFY( !cvt.always_noconv() ); VERIFY( !cvt.always_noconv() );
unicode_codecvt::state_type state04("UNICODE", "ISO_8859-1"); unicode_codecvt::state_type state04("UNICODE", "ISO-8859-15");
initialize_state(state04); initialize_state(state04);
int j = cvt.length(state03, e_lit, e_lit + size, 5); int j = cvt.length(state03, e_lit, e_lit + size, 5);
VERIFY( j == 5 ); VERIFY( j == 5 );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment