From ffe9f7851edf04aad05b8d5c3489d232fd9547f5 Mon Sep 17 00:00:00 2001 From: Benjamin Kosnik Date: Tue, 29 Aug 2000 07:57:10 +0000 Subject: [PATCH] codecvt.html: Add more bits, format. 2000-08-28 Benjamin Kosnik * 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 --- libstdc++-v3/ChangeLog | 6 +- libstdc++-v3/bits/codecvt.h | 55 ++++++++++--------- libstdc++-v3/libio/iofwide.c | 2 + .../22_locale/codecvt_unicode_char.cc | 8 +-- 4 files changed, 40 insertions(+), 31 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 3e7a44b2b29..7fce4b7cfce 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,7 +1,11 @@ 2000-08-28 Benjamin Kosnik * 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 * docs/configopts.html: Mention new options. diff --git a/libstdc++-v3/bits/codecvt.h b/libstdc++-v3/bits/codecvt.h index f4c8e94b853..27c87b7f270 100644 --- a/libstdc++-v3/bits/codecvt.h +++ b/libstdc++-v3/bits/codecvt.h @@ -45,7 +45,7 @@ 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. #ifdef _GLIBCPP_USE_WCHAR_T // Extensions to use icov for dealing with character encodings, @@ -55,9 +55,10 @@ namespace std class __enc_traits { public: - // Types: - typedef iconv_t __conv_type; - typedef mbstate_t __state_type; + // Types: + // NB: A conversion descriptor subsumes and enhances the + // functionality of a simple state type such as mbstate_t. + typedef iconv_t __desc_type; protected: // Data Members: @@ -69,9 +70,9 @@ namespace std char __extc_enc[__max_size]; // Conversion descriptor between external encoding to internal encoding. - __conv_type __in_desc; + __desc_type __in_desc; // Conversion descriptor between internal encoding to external encoding. - __conv_type __out_desc; + __desc_type __out_desc; public: __enc_traits() : __in_desc(0), __out_desc(0) @@ -89,8 +90,19 @@ namespace std __enc_traits(const char* __int, const char* __ext) : __in_desc(0), __out_desc(0) { - strcpy(__intc_enc, __int); - strcpy(__extc_enc, __ext); + strncpy(__intc_enc, __int, __max_size); + 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() @@ -118,11 +130,11 @@ namespace std && __out_desc != iconv_t(-1) && __in_desc != iconv_t(-1); } - const __conv_type* + const __desc_type* _M_get_in_descriptor() { return &__in_desc; } - const __conv_type* + const __desc_type* _M_get_out_descriptor() { return &__out_desc; } @@ -133,15 +145,6 @@ namespace std const char* _M_get_external_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 @@ -295,7 +298,7 @@ namespace std typedef _InternT intern_type; typedef _ExternT extern_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; // Data Members: @@ -360,8 +363,8 @@ namespace std result __ret = error; if (__state._M_good()) { - typedef state_type::__conv_type __conv_type; - const __conv_type* __desc = __state._M_get_out_descriptor(); + typedef state_type::__desc_type __desc_type; + const __desc_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); @@ -403,8 +406,8 @@ namespace std result __ret = error; if (__state._M_good()) { - typedef state_type::__conv_type __conv_type; - const __conv_type* __desc = __state._M_get_in_descriptor(); + typedef state_type::__desc_type __desc_type; + const __desc_type* __desc = __state._M_get_in_descriptor(); const size_t __tmultiple = sizeof(intern_type) / sizeof(char); size_t __tlen = __tmultiple * (__to_end - __to); @@ -440,8 +443,8 @@ namespace std result __ret = error; if (__state._M_good()) { - typedef state_type::__conv_type __conv_type; - const __conv_type* __desc = __state._M_get_in_descriptor(); + typedef state_type::__desc_type __desc_type; + const __desc_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); diff --git a/libstdc++-v3/libio/iofwide.c b/libstdc++-v3/libio/iofwide.c index db1a4f1a76a..64bc7c97dac 100644 --- a/libstdc++-v3/libio/iofwide.c +++ b/libstdc++-v3/libio/iofwide.c @@ -155,6 +155,7 @@ _IO_fwide (fp, mode) cares about systems which changing internal charsets they should come up with a solution for the determination of the currently used internal character set. */ +#if 0 const char *internal_ccs = _G_INTERNAL_CCS; const char *external_ccs = nl_langinfo(CODESET); @@ -164,6 +165,7 @@ _IO_fwide (fp, mode) cc->__cd_in = iconv_open (internal_ccs, external_ccs); if (cc->__cd_in != (iconv_t) -1) cc->__cd_out = iconv_open (external_ccs, internal_ccs); +#endif } # else # error "somehow determine this from LC_CTYPE" diff --git a/libstdc++-v3/testsuite/22_locale/codecvt_unicode_char.cc b/libstdc++-v3/testsuite/22_locale/codecvt_unicode_char.cc index d7e39c8d533..b29b16388d1 100644 --- a/libstdc++-v3/testsuite/22_locale/codecvt_unicode_char.cc +++ b/libstdc++-v3/testsuite/22_locale/codecvt_unicode_char.cc @@ -120,7 +120,7 @@ void test01() const unicode_codecvt& cvt = use_facet(loc); // in - unicode_codecvt::state_type state01("UNICODE", "ISO_8859-1"); + unicode_codecvt::state_type state01("UNICODE", "ISO-8859-15"); initialize_state(state01); result r1 = cvt.in(state01, e_lit, e_lit + size, efrom_next, i_arr, i_arr + size, ito_next); @@ -130,7 +130,7 @@ void test01() VERIFY( ito_next == i_arr + size ); // out - unicode_codecvt::state_type state02("UNICODE", "ISO_8859-1"); + unicode_codecvt::state_type state02("UNICODE", "ISO-8859-15"); initialize_state(state02); result r2 = cvt.out(state02, i_lit, i_lit + size, ifrom_next, e_arr, e_arr + size, eto_next); @@ -141,7 +141,7 @@ void test01() // unshift 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); result r3 = cvt.unshift(state03, e_arr, e_arr + size, eto_next); VERIFY( r3 == codecvt_base::noconv ); @@ -153,7 +153,7 @@ void test01() 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); int j = cvt.length(state03, e_lit, e_lit + size, 5); VERIFY( j == 5 ); -- 2.30.2