acinclude.m4: Remove CCODECVT_H.
authorBenjamin Kosnik <bkoz@redhat.com>
Fri, 7 Jan 2005 19:34:46 +0000 (19:34 +0000)
committerBenjamin Kosnik <bkoz@gcc.gnu.org>
Fri, 7 Jan 2005 19:34:46 +0000 (19:34 +0000)
2005-01-07  Benjamin Kosnik  <bkoz@redhat.com>

* acinclude.m4: Remove CCODECVT_H.
* configure: Regenerate.
* include/Makefile.am (host_headers_extra): Move to...
(ext_headers): ...here.
* include/Makefile.in: Regenerate.
* include/ext/enc_filebuf: Remove enc_filebuf, consolidate
enc_traits to...
* config/locale/ieee_1003.1-2001/codecvt_specializations.h: Move...
* include/ext/codecvt_specializations.h: ...here. Remove
_GLIBCXX_USE___ENC_TRAITS.
(__enc_traits): To __encoding_state, put in __gnu_cxx namespace.
(enc_char_traits): To __encoding_char_traits, put in __gnu_cxx
namespace.
* config/locale/generic/codecvt_specializations.h: Remove.
* include/bits/codecvt.h: Remove codecvt_specializations.h include.
* src/codecvt.cc: Remove __enc_traits::_S_max_size.

From-SVN: r93062

libstdc++-v3/ChangeLog
libstdc++-v3/acinclude.m4
libstdc++-v3/config/locale/generic/codecvt_specializations.h [deleted file]
libstdc++-v3/config/locale/ieee_1003.1-2001/codecvt_specializations.h [deleted file]
libstdc++-v3/configure
libstdc++-v3/include/Makefile.am
libstdc++-v3/include/Makefile.in
libstdc++-v3/include/bits/codecvt.h
libstdc++-v3/include/ext/codecvt_specializations.h [new file with mode: 0644]
libstdc++-v3/include/ext/enc_filebuf.h [deleted file]
libstdc++-v3/src/codecvt.cc

index 8cce55dc5fe78822aa01eaa6e6403dccf1023f77..6391ad22ba3555ad4b711e1e78c2a4bb76ba4dfc 100644 (file)
@@ -1,3 +1,22 @@
+2005-01-07  Benjamin Kosnik  <bkoz@redhat.com>
+
+       * acinclude.m4: Remove CCODECVT_H.
+       * configure: Regenerate.
+       * include/Makefile.am (host_headers_extra): Move to...
+       (ext_headers): ...here.
+       * include/Makefile.in: Regenerate.
+       * include/ext/enc_filebuf: Remove enc_filebuf, consolidate
+       enc_traits to...
+       * config/locale/ieee_1003.1-2001/codecvt_specializations.h: Move...
+       * include/ext/codecvt_specializations.h: ...here. Remove
+       _GLIBCXX_USE___ENC_TRAITS. 
+       (__enc_traits): To __encoding_state, put in __gnu_cxx namespace.
+       (enc_char_traits): To __encoding_char_traits, put in __gnu_cxx
+       namespace.
+       * config/locale/generic/codecvt_specializations.h: Remove.
+       * include/bits/codecvt.h: Remove codecvt_specializations.h include.
+       * src/codecvt.cc: Remove __enc_traits::_S_max_size.
+
 2005-01-06  Benjamin Kosnik  <bkoz@redhat.com>
 
        * include/bits/fstream.tcc: Remove unnecessary qualifications for
index fc746c401f3687b9323ddfb21fd71d274a0f1682..16ec53a27ac14a1b557ea601d8f2db57f0875ee3 100644 (file)
@@ -1073,7 +1073,6 @@ AC_DEFUN([GLIBCXX_ENABLE_CLOCALE], [
 
       CLOCALE_H=config/locale/generic/c_locale.h
       CLOCALE_CC=config/locale/generic/c_locale.cc
-      CCODECVT_H=config/locale/generic/codecvt_specializations.h
       CCODECVT_CC=config/locale/generic/codecvt_members.cc
       CCOLLATE_CC=config/locale/generic/collate_members.cc
       CCTYPE_CC=config/locale/generic/ctype_members.cc
@@ -1090,7 +1089,6 @@ AC_DEFUN([GLIBCXX_ENABLE_CLOCALE], [
 
       CLOCALE_H=config/locale/generic/c_locale.h
       CLOCALE_CC=config/locale/generic/c_locale.cc
-      CCODECVT_H=config/locale/generic/codecvt_specializations.h
       CCODECVT_CC=config/locale/generic/codecvt_members.cc
       CCOLLATE_CC=config/locale/generic/collate_members.cc
       CCTYPE_CC=config/locale/darwin/ctype_members.cc
@@ -1126,7 +1124,6 @@ AC_DEFUN([GLIBCXX_ENABLE_CLOCALE], [
 
       CLOCALE_H=config/locale/gnu/c_locale.h
       CLOCALE_CC=config/locale/gnu/c_locale.cc
-      CCODECVT_H=config/locale/ieee_1003.1-2001/codecvt_specializations.h
       CCODECVT_CC=config/locale/gnu/codecvt_members.cc
       CCOLLATE_CC=config/locale/gnu/collate_members.cc
       CCTYPE_CC=config/locale/gnu/ctype_members.cc
@@ -1143,7 +1140,6 @@ AC_DEFUN([GLIBCXX_ENABLE_CLOCALE], [
 
       CLOCALE_H=config/locale/ieee_1003.1-2001/c_locale.h
       CLOCALE_CC=config/locale/ieee_1003.1-2001/c_locale.cc
-      CCODECVT_H=config/locale/ieee_1003.1-2001/codecvt_specializations.h
       CCODECVT_CC=config/locale/generic/codecvt_members.cc
       CCOLLATE_CC=config/locale/generic/collate_members.cc
       CCTYPE_CC=config/locale/generic/ctype_members.cc
@@ -1173,7 +1169,6 @@ AC_DEFUN([GLIBCXX_ENABLE_CLOCALE], [
 
   AC_SUBST(USE_NLS)
   AC_SUBST(CLOCALE_H)
-  AC_SUBST(CCODECVT_H)
   AC_SUBST(CMESSAGES_H)
   AC_SUBST(CCODECVT_CC)
   AC_SUBST(CCOLLATE_CC)
diff --git a/libstdc++-v3/config/locale/generic/codecvt_specializations.h b/libstdc++-v3/config/locale/generic/codecvt_specializations.h
deleted file mode 100644 (file)
index 24db4c8..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-// Locale support (codecvt) -*- C++ -*-
-
-// Copyright (C) 2000, 2001 Free Software Foundation, Inc.
-//
-// This file is part of the GNU ISO C++ Library.  This library is free
-// software; you can redistribute it and/or modify it under the
-// terms of the GNU General Public License as published by the
-// Free Software Foundation; either version 2, or (at your option)
-// any later version.
-
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING.  If not, write to the Free
-// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
-// USA.
-
-// As a special exception, you may use this file as part of a free software
-// library without restriction.  Specifically, if other files instantiate
-// templates or use macros or inline functions from this file, or you compile
-// this file and link it with other files to produce an executable, this
-// file does not by itself cause the resulting executable to be covered by
-// the GNU General Public License.  This exception does not however
-// invalidate any other reasons why the executable file might be covered by
-// the GNU General Public License.
-
-//
-// ISO C++ 14882: 22.2.1.5 Template class codecvt
-//
-
-// Warning: this file is not meant for user inclusion.  Use <locale>.
-
-// Written by Benjamin Kosnik <bkoz@cygnus.com>
-
-// XXX dummy file
diff --git a/libstdc++-v3/config/locale/ieee_1003.1-2001/codecvt_specializations.h b/libstdc++-v3/config/locale/ieee_1003.1-2001/codecvt_specializations.h
deleted file mode 100644 (file)
index 29f12d9..0000000
+++ /dev/null
@@ -1,483 +0,0 @@
-// Locale support (codecvt) -*- C++ -*-
-
-// Copyright (C) 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
-//
-// This file is part of the GNU ISO C++ Library.  This library is free
-// software; you can redistribute it and/or modify it under the
-// terms of the GNU General Public License as published by the
-// Free Software Foundation; either version 2, or (at your option)
-// any later version.
-
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING.  If not, write to the Free
-// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
-// USA.
-
-// As a special exception, you may use this file as part of a free software
-// library without restriction.  Specifically, if other files instantiate
-// templates or use macros or inline functions from this file, or you compile
-// this file and link it with other files to produce an executable, this
-// file does not by itself cause the resulting executable to be covered by
-// the GNU General Public License.  This exception does not however
-// invalidate any other reasons why the executable file might be covered by
-// the GNU General Public License.
-
-//
-// ISO C++ 14882: 22.2.1.5 Template class codecvt
-//
-
-// Warning: this file is not meant for user inclusion.  Use <locale>.
-
-// Written by Benjamin Kosnik <bkoz@cygnus.com>
-
-/** @file bits/codecvt_specializations.h
- *  This is an internal header file, included by other library headers.
- *  You should not attempt to use it directly.
- */
-
-  // XXX
-  // Define this here so codecvt.cc can have _S_max_size definition.
-#define _GLIBCXX_USE___ENC_TRAITS 1
-
-  /// @brief  Extension to use icov for dealing with character encodings.
-  // This includes conversions and comparisons between various character
-  // sets.  This object encapsulates data that may need to be shared between
-  // char_traits, codecvt and ctype.
-  class __enc_traits
-  {
-  public:
-    // 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:
-    // Max size of charset encoding name
-    static const int   _S_max_size = 32;
-    // Name of internal character set encoding.
-    char               _M_int_enc[_S_max_size];
-    // Name of external character set encoding.
-    char               _M_ext_enc[_S_max_size];
-
-    // Conversion descriptor between external encoding to internal encoding.
-    __desc_type                _M_in_desc;
-    // Conversion descriptor between internal encoding to external encoding.
-    __desc_type                _M_out_desc;
-
-    // Details the byte-order marker for the external encoding, if necessary.
-    int                        _M_ext_bom;
-
-    // Details the byte-order marker for the internal encoding, if necessary.
-    int                        _M_int_bom;
-
-  public:
-    explicit __enc_traits() 
-    : _M_in_desc(0), _M_out_desc(0), _M_ext_bom(0), _M_int_bom(0) 
-    {
-      memset(_M_int_enc, 0, _S_max_size);
-      memset(_M_ext_enc, 0, _S_max_size);
-    }
-
-    explicit __enc_traits(const char* __int, const char* __ext, 
-                         int __ibom = 0, int __ebom = 0)
-    : _M_in_desc(0), _M_out_desc(0), _M_ext_bom(__ebom), _M_int_bom(__ibom)
-    {
-      strncpy(_M_int_enc, __int, _S_max_size);
-      strncpy(_M_ext_enc, __ext, _S_max_size);
-      _M_init();
-    }
-
-    // 21.1.2 traits typedefs
-    // p4
-    // typedef STATE_T state_type
-    // requires: state_type shall meet the requirements of
-    // CopyConstructible types (20.1.3)
-    // NB: This does not preseve the actual state of the conversion
-    // descriptor member, but it does duplicate the encoding
-    // information.
-    __enc_traits(const __enc_traits& __obj): _M_in_desc(0), _M_out_desc(0)
-    {
-      strncpy(_M_int_enc, __obj._M_int_enc, _S_max_size);
-      strncpy(_M_ext_enc, __obj._M_ext_enc, _S_max_size);
-      _M_ext_bom = __obj._M_ext_bom;
-      _M_int_bom = __obj._M_int_bom;
-      _M_destroy();
-      _M_init();
-    }
-
-    // Need assignment operator as well.
-    __enc_traits&
-    operator=(const __enc_traits& __obj)
-    {
-      strncpy(_M_int_enc, __obj._M_int_enc, _S_max_size);
-      strncpy(_M_ext_enc, __obj._M_ext_enc, _S_max_size);
-      _M_ext_bom = __obj._M_ext_bom;
-      _M_int_bom = __obj._M_int_bom;
-      _M_destroy();
-      _M_init();
-      return *this;
-    }
-
-    ~__enc_traits()
-    { _M_destroy(); } 
-
-    void
-    _M_init()
-    {
-      const __desc_type __err = reinterpret_cast<iconv_t>(-1);
-      if (!_M_in_desc)
-       {
-         _M_in_desc = iconv_open(_M_int_enc, _M_ext_enc);
-         if (_M_in_desc == __err)
-           __throw_runtime_error(__N("__enc_traits::_M_init "
-                                 "creating iconv input descriptor failed"));
-       }
-      if (!_M_out_desc)
-       {
-         _M_out_desc = iconv_open(_M_ext_enc, _M_int_enc);
-         if (_M_out_desc == __err)
-           __throw_runtime_error(__N("__enc_traits::_M_init "
-                                 "creating iconv output descriptor failed"));
-       }
-    }
-
-    void
-    _M_destroy()
-    {
-      const __desc_type __err = reinterpret_cast<iconv_t>(-1);
-      if (_M_in_desc && _M_in_desc != __err) 
-       {
-         iconv_close(_M_in_desc);
-         _M_in_desc = 0;
-       }
-      if (_M_out_desc && _M_out_desc != __err) 
-       {
-         iconv_close(_M_out_desc);
-         _M_out_desc = 0;
-       }
-    }
-
-    bool
-    _M_good()
-    { 
-      const __desc_type __err = reinterpret_cast<iconv_t>(-1);
-      bool __test = _M_in_desc && _M_in_desc != __err; 
-      __test &=  _M_out_desc && _M_out_desc != __err;
-      return __test;
-    }
-
-    const __desc_type* 
-    _M_get_in_descriptor()
-    { return &_M_in_desc; }
-
-    const __desc_type* 
-    _M_get_out_descriptor()
-    { return &_M_out_desc; }
-
-    int 
-    _M_get_external_bom()
-    { return _M_ext_bom; }
-
-    int 
-    _M_get_internal_bom()
-    { return _M_int_bom; }
-
-    const char* 
-    _M_get_internal_enc()
-    { return _M_int_enc; }
-
-    const char* 
-    _M_get_external_enc()
-    { return _M_ext_enc; }    
-  };
-
-  /// @brief  class codecvt<InternT, _ExternT, __enc_traits> specialization.
-  // This partial 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>
-    : 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::__desc_type                __desc_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(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;
-
-  // This adaptor works around the signature problems of the second
-  // argument to iconv():  SUSv2 and others use 'const char**', but glibc 2.2
-  // uses 'char**', which matches the POSIX 1003.1-2001 standard.
-  // Using this adaptor, g++ will do the work for us.
-  template<typename _T>
-    inline size_t
-    __iconv_adaptor(size_t(*__func)(iconv_t, _T, size_t*, char**, size_t*),
-                    iconv_t __cd, char** __inbuf, size_t* __inbytes,
-                    char** __outbuf, size_t* __outbytes)
-    { return __func(__cd, (_T)__inbuf, __inbytes, __outbuf, __outbytes); }
-
-  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 = codecvt_base::error;
-      if (__state._M_good())
-       {
-         const __desc_type* __desc = __state._M_get_out_descriptor();
-         const size_t __fmultiple = sizeof(intern_type);
-         size_t __fbytes = __fmultiple * (__from_end - __from);
-         const size_t __tmultiple = sizeof(extern_type);
-         size_t __tbytes = __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);
-         char* __cfrom;
-         size_t __conv;
-
-         // Some encodings need a byte order marker as the first item
-         // in the byte stream, to designate endian-ness. The default
-         // value for the byte order marker is NULL, so if this is
-         // the case, it's not necessary and we can just go on our
-         // merry way.
-         int __int_bom = __state._M_get_internal_bom();
-         if (__int_bom)
-           {     
-             size_t __size = __from_end - __from;
-             intern_type* __cfixed = static_cast<intern_type*>
-               (__builtin_alloca(sizeof(intern_type) * (__size + 1)));
-             __cfixed[0] = static_cast<intern_type>(__int_bom);
-             char_traits<intern_type>::copy(__cfixed + 1, __from, __size);
-             __cfrom = reinterpret_cast<char*>(__cfixed);
-             __conv = __iconv_adaptor(iconv, *__desc, &__cfrom,
-                                        &__fbytes, &__cto, &__tbytes); 
-           }
-         else
-           {
-             intern_type* __cfixed = const_cast<intern_type*>(__from);
-             __cfrom = reinterpret_cast<char*>(__cfixed);
-             __conv = __iconv_adaptor(iconv, *__desc, &__cfrom, &__fbytes, 
-                                      &__cto, &__tbytes); 
-           }
-
-         if (__conv != size_t(-1))
-           {
-             __from_next = reinterpret_cast<const intern_type*>(__cfrom);
-             __to_next = reinterpret_cast<extern_type*>(__cto);
-             __ret = codecvt_base::ok;
-           }
-         else 
-           {
-             if (__fbytes < __fmultiple * (__from_end - __from))
-               {
-                 __from_next = reinterpret_cast<const intern_type*>(__cfrom);
-                 __to_next = reinterpret_cast<extern_type*>(__cto);
-                 __ret = codecvt_base::partial;
-               }
-             else
-               __ret = codecvt_base::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 = codecvt_base::error;
-      if (__state._M_good())
-       {
-         const __desc_type* __desc = __state._M_get_in_descriptor();
-         const size_t __tmultiple = sizeof(intern_type);
-         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_adaptor(iconv,*__desc, NULL, NULL,
-                                          &__cto, &__tlen); 
-         
-         if (__conv != size_t(-1))
-           {
-             __to_next = reinterpret_cast<extern_type*>(__cto);
-             if (__tlen == __tmultiple * (__to_end - __to))
-               __ret = codecvt_base::noconv;
-             else if (__tlen == 0)
-               __ret = codecvt_base::ok;
-             else
-               __ret = codecvt_base::partial;
-           }
-         else 
-           __ret = codecvt_base::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 = codecvt_base::error;
-      if (__state._M_good())
-       {
-         const __desc_type* __desc = __state._M_get_in_descriptor();
-         const size_t __fmultiple = sizeof(extern_type);
-         size_t __flen = __fmultiple * (__from_end - __from);
-         const size_t __tmultiple = sizeof(intern_type);
-         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);
-         char* __cfrom;
-         size_t __conv;
-
-         // Some encodings need a byte order marker as the first item
-         // in the byte stream, to designate endian-ness. The default
-         // value for the byte order marker is NULL, so if this is
-         // the case, it's not necessary and we can just go on our
-         // merry way.
-         int __ext_bom = __state._M_get_external_bom();
-         if (__ext_bom)
-           {     
-             size_t __size = __from_end - __from;
-             extern_type* __cfixed =  static_cast<extern_type*>
-               (__builtin_alloca(sizeof(extern_type) * (__size + 1)));
-             __cfixed[0] = static_cast<extern_type>(__ext_bom);
-             char_traits<extern_type>::copy(__cfixed + 1, __from, __size);
-             __cfrom = reinterpret_cast<char*>(__cfixed);
-             __conv = __iconv_adaptor(iconv, *__desc, &__cfrom,
-                                       &__flen, &__cto, &__tlen); 
-           }
-         else
-           {
-             extern_type* __cfixed = const_cast<extern_type*>(__from);
-             __cfrom = reinterpret_cast<char*>(__cfixed);
-             __conv = __iconv_adaptor(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 = codecvt_base::ok;
-           }
-         else 
-           {
-             if (__flen < static_cast<size_t>(__from_end - __from))
-               {
-                 __from_next = reinterpret_cast<const extern_type*>(__cfrom);
-                 __to_next = reinterpret_cast<intern_type*>(__cto);
-                 __ret = codecvt_base::partial;
-               }
-             else
-               __ret = codecvt_base::error;
-           }
-       }
-      return __ret; 
-    }
-  
-  template<typename _InternT, typename _ExternT>
-    int 
-    codecvt<_InternT, _ExternT, __enc_traits>::
-    do_encoding() const throw()
-    {
-      int __ret = 0;
-      if (sizeof(_ExternT) <= sizeof(_InternT))
-       __ret = sizeof(_InternT)/sizeof(_ExternT);
-      return __ret; 
-    }
-  
-  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(state_type&, const extern_type* __from, 
-             const extern_type* __end, size_t __max) const
-    { return std::min(__max, static_cast<size_t>(__end - __from)); }
-
-  // _GLIBCXX_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; }
-
index 77c8d2c4fa05c15f631380e4cba249c24bc11f62..490c45c1c497bbf3039e0d0225de40d1c9795f49 100755 (executable)
@@ -309,7 +309,7 @@ ac_includes_default="\
 # include <unistd.h>
 #endif"
 
-ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS libtool_VERSION multi_basedir build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar glibcxx_builddir glibcxx_srcdir toplevel_srcdir CC ac_ct_CC EXEEXT OBJEXT CXX ac_ct_CXX CFLAGS CXXFLAGS LN_S AS ac_ct_AS AR ac_ct_AR RANLIB ac_ct_RANLIB MAINTAINER_MODE_TRUE MAINTAINER_MODE_FALSE MAINT LIBTOOL CXXCPP CPPFLAGS enable_shared enable_static GLIBCXX_HOSTED_TRUE GLIBCXX_HOSTED_FALSE GLIBCXX_BUILD_PCH_TRUE GLIBCXX_BUILD_PCH_FALSE glibcxx_PCHFLAGS CSTDIO_H BASIC_FILE_H BASIC_FILE_CC CPP EGREP check_msgfmt glibcxx_MOFILES glibcxx_POFILES glibcxx_localedir USE_NLS CLOCALE_H CCODECVT_H CMESSAGES_H CCODECVT_CC CCOLLATE_CC CCTYPE_CC CMESSAGES_CC CMONEY_CC CNUMERIC_CC CTIME_H CTIME_CC CLOCALE_CC CLOCALE_INTERNAL_H ALLOCATOR_H ALLOCATOR_NAME C_INCLUDE_DIR GLIBCXX_C_HEADERS_C_TRUE GLIBCXX_C_HEADERS_C_FALSE GLIBCXX_C_HEADERS_C_STD_TRUE GLIBCXX_C_HEADERS_C_STD_FALSE GLIBCXX_C_HEADERS_COMPATIBILITY_TRUE GLIBCXX_C_HEADERS_COMPATIBILITY_FALSE glibcxx_thread_h DEBUG_FLAGS GLIBCXX_BUILD_DEBUG_TRUE GLIBCXX_BUILD_DEBUG_FALSE EXTRA_CXX_FLAGS WERROR SECTION_FLAGS SECTION_LDFLAGS OPT_LDFLAGS LIBMATHOBJS LIBICONV SYMVER_MAP port_specific_symbol_files GLIBCXX_BUILD_VERSIONED_SHLIB_TRUE GLIBCXX_BUILD_VERSIONED_SHLIB_FALSE baseline_dir GLIBCXX_TEST_WCHAR_T_TRUE GLIBCXX_TEST_WCHAR_T_FALSE GLIBCXX_TEST_THREAD_TRUE GLIBCXX_TEST_THREAD_FALSE GLIBCXX_TEST_ABI_TRUE GLIBCXX_TEST_ABI_FALSE ATOMICITY_SRCDIR ATOMIC_WORD_SRCDIR ABI_TWEAKS_SRCDIR OS_INC_SRCDIR glibcxx_prefixdir gxx_include_dir glibcxx_toolexecdir glibcxx_toolexeclibdir GLIBCXX_INCLUDES TOPLEVEL_INCLUDES OPTIMIZE_CXXFLAGS WARN_FLAGS LIBSUPCXX_PICFLAGS LIBOBJS LTLIBOBJS'
+ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS libtool_VERSION multi_basedir build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar glibcxx_builddir glibcxx_srcdir toplevel_srcdir CC ac_ct_CC EXEEXT OBJEXT CXX ac_ct_CXX CFLAGS CXXFLAGS LN_S AS ac_ct_AS AR ac_ct_AR RANLIB ac_ct_RANLIB MAINTAINER_MODE_TRUE MAINTAINER_MODE_FALSE MAINT LIBTOOL CXXCPP CPPFLAGS enable_shared enable_static GLIBCXX_HOSTED_TRUE GLIBCXX_HOSTED_FALSE GLIBCXX_BUILD_PCH_TRUE GLIBCXX_BUILD_PCH_FALSE glibcxx_PCHFLAGS CSTDIO_H BASIC_FILE_H BASIC_FILE_CC CPP EGREP check_msgfmt glibcxx_MOFILES glibcxx_POFILES glibcxx_localedir USE_NLS CLOCALE_H CMESSAGES_H CCODECVT_CC CCOLLATE_CC CCTYPE_CC CMESSAGES_CC CMONEY_CC CNUMERIC_CC CTIME_H CTIME_CC CLOCALE_CC CLOCALE_INTERNAL_H ALLOCATOR_H ALLOCATOR_NAME C_INCLUDE_DIR GLIBCXX_C_HEADERS_C_TRUE GLIBCXX_C_HEADERS_C_FALSE GLIBCXX_C_HEADERS_C_STD_TRUE GLIBCXX_C_HEADERS_C_STD_FALSE GLIBCXX_C_HEADERS_COMPATIBILITY_TRUE GLIBCXX_C_HEADERS_COMPATIBILITY_FALSE glibcxx_thread_h DEBUG_FLAGS GLIBCXX_BUILD_DEBUG_TRUE GLIBCXX_BUILD_DEBUG_FALSE EXTRA_CXX_FLAGS WERROR SECTION_FLAGS SECTION_LDFLAGS OPT_LDFLAGS LIBMATHOBJS LIBICONV SYMVER_MAP port_specific_symbol_files GLIBCXX_BUILD_VERSIONED_SHLIB_TRUE GLIBCXX_BUILD_VERSIONED_SHLIB_FALSE baseline_dir GLIBCXX_TEST_WCHAR_T_TRUE GLIBCXX_TEST_WCHAR_T_FALSE GLIBCXX_TEST_THREAD_TRUE GLIBCXX_TEST_THREAD_FALSE GLIBCXX_TEST_ABI_TRUE GLIBCXX_TEST_ABI_FALSE ATOMICITY_SRCDIR ATOMIC_WORD_SRCDIR ABI_TWEAKS_SRCDIR OS_INC_SRCDIR glibcxx_prefixdir gxx_include_dir glibcxx_toolexecdir glibcxx_toolexeclibdir GLIBCXX_INCLUDES TOPLEVEL_INCLUDES OPTIMIZE_CXXFLAGS WARN_FLAGS LIBSUPCXX_PICFLAGS LIBOBJS LTLIBOBJS'
 ac_subst_files=''
 
 # Initialize some variables set by options.
@@ -5811,7 +5811,6 @@ echo "${ECHO_T}generic" >&6
 
       CLOCALE_H=config/locale/generic/c_locale.h
       CLOCALE_CC=config/locale/generic/c_locale.cc
-      CCODECVT_H=config/locale/generic/codecvt_specializations.h
       CCODECVT_CC=config/locale/generic/codecvt_members.cc
       CCOLLATE_CC=config/locale/generic/collate_members.cc
       CCTYPE_CC=config/locale/generic/ctype_members.cc
@@ -5829,7 +5828,6 @@ echo "${ECHO_T}darwin" >&6
 
       CLOCALE_H=config/locale/generic/c_locale.h
       CLOCALE_CC=config/locale/generic/c_locale.cc
-      CCODECVT_H=config/locale/generic/codecvt_specializations.h
       CCODECVT_CC=config/locale/generic/codecvt_members.cc
       CCOLLATE_CC=config/locale/generic/collate_members.cc
       CCTYPE_CC=config/locale/darwin/ctype_members.cc
@@ -5901,7 +5899,6 @@ fi
 
       CLOCALE_H=config/locale/gnu/c_locale.h
       CLOCALE_CC=config/locale/gnu/c_locale.cc
-      CCODECVT_H=config/locale/ieee_1003.1-2001/codecvt_specializations.h
       CCODECVT_CC=config/locale/gnu/codecvt_members.cc
       CCOLLATE_CC=config/locale/gnu/collate_members.cc
       CCTYPE_CC=config/locale/gnu/ctype_members.cc
@@ -5919,7 +5916,6 @@ echo "${ECHO_T}IEEE 1003.1" >&6
 
       CLOCALE_H=config/locale/ieee_1003.1-2001/c_locale.h
       CLOCALE_CC=config/locale/ieee_1003.1-2001/c_locale.cc
-      CCODECVT_H=config/locale/ieee_1003.1-2001/codecvt_specializations.h
       CCODECVT_CC=config/locale/generic/codecvt_members.cc
       CCOLLATE_CC=config/locale/generic/collate_members.cc
       CCTYPE_CC=config/locale/generic/ctype_members.cc
@@ -6253,7 +6249,6 @@ _ACEOF
 
 
 
-
   echo "$as_me:$LINENO: checking for std::allocator base class to use" >&5
 echo $ECHO_N "checking for std::allocator base class to use... $ECHO_C" >&6
    # Check whether --enable-libstdcxx-allocator or --disable-libstdcxx-allocator was given.
@@ -98509,7 +98504,6 @@ s,@glibcxx_POFILES@,$glibcxx_POFILES,;t t
 s,@glibcxx_localedir@,$glibcxx_localedir,;t t
 s,@USE_NLS@,$USE_NLS,;t t
 s,@CLOCALE_H@,$CLOCALE_H,;t t
-s,@CCODECVT_H@,$CCODECVT_H,;t t
 s,@CMESSAGES_H@,$CMESSAGES_H,;t t
 s,@CCODECVT_CC@,$CCODECVT_CC,;t t
 s,@CCOLLATE_CC@,$CCOLLATE_CC,;t t
index ba615fa84aac1cc32f3fd318cf57dd3bcc203374..be8320a999080930f172e664043df1bab6c5cf26 100644 (file)
@@ -203,8 +203,8 @@ ext_headers = \
        ${ext_srcdir}/algorithm \
        ${ext_srcdir}/array_allocator.h \
        ${ext_srcdir}/bitmap_allocator.h \
+       ${ext_srcdir}/codecvt_specializations.h \
        ${ext_srcdir}/debug_allocator.h \
-       ${ext_srcdir}/enc_filebuf.h \
        ${ext_srcdir}/stdio_filebuf.h \
        ${ext_srcdir}/stdio_sync_filebuf.h \
        ${ext_srcdir}/functional \
@@ -366,8 +366,7 @@ host_headers_extra = \
        ${host_builddir}/c++io.h \
        ${host_builddir}/c++locale.h \
        ${host_builddir}/messages_members.h \
-       ${host_builddir}/time_members.h \
-       ${host_builddir}/codecvt_specializations.h
+       ${host_builddir}/time_members.h 
 
 thread_host_headers = \
        ${host_builddir}/gthr.h \
index 87470b28e603665cc77fabb0d6d5129643505ba8..6bdf5010ec37eade7bfa62abd6d76235ad9506f2 100644 (file)
@@ -71,7 +71,6 @@ BASIC_FILE_CC = @BASIC_FILE_CC@
 BASIC_FILE_H = @BASIC_FILE_H@
 CC = @CC@
 CCODECVT_CC = @CCODECVT_CC@
-CCODECVT_H = @CCODECVT_H@
 CCOLLATE_CC = @CCOLLATE_CC@
 CCTYPE_CC = @CCTYPE_CC@
 CFLAGS = @CFLAGS@
@@ -420,8 +419,8 @@ ext_headers = \
        ${ext_srcdir}/algorithm \
        ${ext_srcdir}/array_allocator.h \
        ${ext_srcdir}/bitmap_allocator.h \
+       ${ext_srcdir}/codecvt_specializations.h \
        ${ext_srcdir}/debug_allocator.h \
-       ${ext_srcdir}/enc_filebuf.h \
        ${ext_srcdir}/stdio_filebuf.h \
        ${ext_srcdir}/stdio_sync_filebuf.h \
        ${ext_srcdir}/functional \
@@ -581,8 +580,7 @@ host_headers_extra = \
        ${host_builddir}/c++io.h \
        ${host_builddir}/c++locale.h \
        ${host_builddir}/messages_members.h \
-       ${host_builddir}/time_members.h \
-       ${host_builddir}/codecvt_specializations.h
+       ${host_builddir}/time_members.h 
 
 thread_host_headers = \
        ${host_builddir}/gthr.h \
index 51ad4dd7d1f125cf530b7b4fba9cf3205df4e9a3..cd9146ff16076f2b7fbbe05e81f1f5a790f32f4b 100644 (file)
@@ -1,6 +1,7 @@
 // Locale support (codecvt) -*- C++ -*-
 
-// Copyright (C) 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005
+//  Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
 // software; you can redistribute it and/or modify it under the
@@ -31,7 +32,7 @@
 // ISO C++ 14882: 22.2.1.5 Template class codecvt
 //
 
-// Written by Benjamin Kosnik <bkoz@cygnus.com>
+// Written by Benjamin Kosnik <bkoz@redhat.com>
 
 /** @file bits/codecvt.h
  *  This is an internal header file, included by other library headers.
       ~codecvt_byname() { }
     };
 
-  // Include host and configuration specific partial specializations
-  // with additional functionality, if possible.
-#ifdef _GLIBCXX_USE_WCHAR_T
-  #include <bits/codecvt_specializations.h>
-#endif
-
 #endif // _CODECVT_H
diff --git a/libstdc++-v3/include/ext/codecvt_specializations.h b/libstdc++-v3/include/ext/codecvt_specializations.h
new file mode 100644 (file)
index 0000000..af343a1
--- /dev/null
@@ -0,0 +1,505 @@
+// Locale support (codecvt) -*- C++ -*-
+
+// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005
+//  Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING.  If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction.  Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License.  This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+//
+// ISO C++ 14882: 22.2.1.5 Template class codecvt
+//
+
+// Written by Benjamin Kosnik <bkoz@redhat.com>
+
+/** @file bits/codecvt_specializations.h
+ *  This file is a GNU extension to the Standard C++ Library.
+ */
+
+  // XXX
+  // Define this here so codecvt.cc can have _S_max_size definition.
+#define _GLIBCXX_USE_ENCODING_STATE 1
+
+namespace __gnu_cxx
+{
+  /// @brief  Extension to use icov for dealing with character encodings.
+  // This includes conversions and comparisons between various character
+  // sets.  This object encapsulates data that may need to be shared between
+  // char_traits, codecvt and ctype.
+  class encoding_state
+  {
+  public:
+    // Types: 
+    // NB: A conversion descriptor subsumes and enhances the
+    // functionality of a simple state type such as mbstate_t.
+    typedef iconv_t    descriptor_type;
+    
+  protected:
+    // Name of internal character set encoding.
+    std::string                _M_int_enc;
+
+    // Name of external character set encoding.
+    std::string        _M_ext_enc;
+
+    // Conversion descriptor between external encoding to internal encoding.
+    descriptor_type    _M_in_desc;
+
+    // Conversion descriptor between internal encoding to external encoding.
+    descriptor_type    _M_out_desc;
+
+    // The byte-order marker for the external encoding, if necessary.
+    int                        _M_ext_bom;
+
+    // The byte-order marker for the internal encoding, if necessary.
+    int                        _M_int_bom;
+
+    // Number of external bytes needed to construct one complete
+    // character in the internal encoding.
+    // NB: -1 indicates variable, or stateful, encodings.
+    int                _M_bytes;
+
+  public:
+    explicit 
+    encoding_state() 
+    : _M_in_desc(0), _M_out_desc(0), _M_ext_bom(0), _M_int_bom(0), _M_bytes(0)
+    { }
+
+    explicit 
+    encoding_state(const char* __int, const char* __ext, 
+                  int __ibom = 0, int __ebom = 0, int __bytes = 1)
+    : _M_int_enc(__int), _M_ext_enc(__ext), _M_in_desc(0), _M_out_desc(0), 
+      _M_ext_bom(__ebom), _M_int_bom(__ibom), _M_bytes(__bytes)
+    { init(); }
+
+    // 21.1.2 traits typedefs
+    // p4
+    // typedef STATE_T state_type
+    // requires: state_type shall meet the requirements of
+    // CopyConstructible types (20.1.3)
+    // NB: This does not preseve the actual state of the conversion
+    // descriptor member, but it does duplicate the encoding
+    // information.
+    encoding_state(const encoding_state& __obj) : _M_in_desc(0), _M_out_desc(0)
+    { construct(__obj); }
+
+    // Need assignment operator as well.
+    encoding_state&
+    operator=(const encoding_state& __obj)
+    {
+      construct(__obj);
+      return *this;
+    }
+
+    ~encoding_state()
+    { destroy(); } 
+
+    bool
+    good() const throw()
+    { 
+      const descriptor_type __err = reinterpret_cast<iconv_t>(-1);
+      bool __test = _M_in_desc && _M_in_desc != __err; 
+      __test &=  _M_out_desc && _M_out_desc != __err;
+      return __test;
+    }
+    
+    int
+    character_ratio() const
+    { return _M_bytes; }
+
+    const std::string
+    internal_encoding() const
+    { return _M_int_enc; }
+
+    int 
+    internal_bom() const
+    { return _M_int_bom; }
+
+    const std::string
+    external_encoding() const
+    { return _M_ext_enc; }
+
+    int 
+    external_bom() const
+    { return _M_ext_bom; }
+
+    const descriptor_type&
+    in_descriptor() const
+    { return _M_in_desc; }
+
+    const descriptor_type&
+    out_descriptor() const
+    { return _M_out_desc; }
+
+  protected:
+    void
+    init()
+    {
+      const descriptor_type __err = reinterpret_cast<iconv_t>(-1);
+      const bool __have_encodings = _M_int_enc.size() && _M_ext_enc.size();
+      if (!_M_in_desc && __have_encodings)
+       {
+         _M_in_desc = iconv_open(_M_int_enc.c_str(), _M_ext_enc.c_str());
+         if (_M_in_desc == __err)
+           std::__throw_runtime_error(__N("encoding_state::_M_init "
+                                   "creating iconv input descriptor failed"));
+       }
+      if (!_M_out_desc && __have_encodings)
+       {
+         _M_out_desc = iconv_open(_M_ext_enc.c_str(), _M_int_enc.c_str());
+         if (_M_out_desc == __err)
+           std::__throw_runtime_error(__N("encoding_state::_M_init "
+                                 "creating iconv output descriptor failed"));
+       }
+    }
+
+    void
+    construct(const encoding_state& __obj)
+    {
+      destroy();
+      _M_int_enc = __obj._M_int_enc;
+      _M_ext_enc = __obj._M_ext_enc;
+      _M_ext_bom = __obj._M_ext_bom;
+      _M_int_bom = __obj._M_int_bom;
+      _M_bytes = __obj._M_bytes;
+      init();
+    }
+
+    void
+    destroy() throw()
+    {
+      const descriptor_type __err = reinterpret_cast<iconv_t>(-1);
+      if (_M_in_desc && _M_in_desc != __err) 
+       {
+         iconv_close(_M_in_desc);
+         _M_in_desc = 0;
+       }
+      if (_M_out_desc && _M_out_desc != __err) 
+       {
+         iconv_close(_M_out_desc);
+         _M_out_desc = 0;
+       }
+    }
+  };
+
+  /// @brief  encoding_char_traits.
+  // Custom traits type with encoding_state for the state type, and the
+  // associated fpos<encoding_state> for the position type, all other
+  // bits equivalent to the required char_traits instantiations.
+  template<typename _CharT>
+    struct encoding_char_traits : public std::char_traits<_CharT>
+    {
+      typedef encoding_state                           state_type;
+      typedef typename std::fpos<state_type>           pos_type;
+    };
+} // namespace __gnu_cxx
+
+namespace std
+{
+  using __gnu_cxx::encoding_state;
+
+  /// @brief  codecvt<InternT, _ExternT, encoding_state> specialization.
+  // This partial 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, encoding_state>
+    : public __codecvt_abstract_base<_InternT, _ExternT, encoding_state>
+    {
+    public:      
+      // Types:
+      typedef codecvt_base::result                     result;
+      typedef _InternT                                         intern_type;
+      typedef _ExternT                                         extern_type;
+      typedef __gnu_cxx::encoding_state                state_type;
+      typedef state_type::descriptor_type              descriptor_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(state_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(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, encoding_state>::id;
+
+  // This adaptor works around the signature problems of the second
+  // argument to iconv():  SUSv2 and others use 'const char**', but glibc 2.2
+  // uses 'char**', which matches the POSIX 1003.1-2001 standard.
+  // Using this adaptor, g++ will do the work for us.
+  template<typename _T>
+    inline size_t
+    __iconv_adaptor(size_t(*__func)(iconv_t, _T, size_t*, char**, size_t*),
+                    iconv_t __cd, char** __inbuf, size_t* __inbytes,
+                    char** __outbuf, size_t* __outbytes)
+    { return __func(__cd, (_T)__inbuf, __inbytes, __outbuf, __outbytes); }
+
+  template<typename _InternT, typename _ExternT>
+    codecvt_base::result
+    codecvt<_InternT, _ExternT, encoding_state>::
+    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 = codecvt_base::error;
+      if (__state.good())
+       {
+         const descriptor_type& __desc = __state.out_descriptor();
+         const size_t __fmultiple = sizeof(intern_type);
+         size_t __fbytes = __fmultiple * (__from_end - __from);
+         const size_t __tmultiple = sizeof(extern_type);
+         size_t __tbytes = __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);
+         char* __cfrom;
+         size_t __conv;
+
+         // Some encodings need a byte order marker as the first item
+         // in the byte stream, to designate endian-ness. The default
+         // value for the byte order marker is NULL, so if this is
+         // the case, it's not necessary and we can just go on our
+         // merry way.
+         int __int_bom = __state.internal_bom();
+         if (__int_bom)
+           {     
+             size_t __size = __from_end - __from;
+             intern_type* __cfixed = static_cast<intern_type*>
+               (__builtin_alloca(sizeof(intern_type) * (__size + 1)));
+             __cfixed[0] = static_cast<intern_type>(__int_bom);
+             char_traits<intern_type>::copy(__cfixed + 1, __from, __size);
+             __cfrom = reinterpret_cast<char*>(__cfixed);
+             __conv = __iconv_adaptor(iconv, __desc, &__cfrom,
+                                        &__fbytes, &__cto, &__tbytes); 
+           }
+         else
+           {
+             intern_type* __cfixed = const_cast<intern_type*>(__from);
+             __cfrom = reinterpret_cast<char*>(__cfixed);
+             __conv = __iconv_adaptor(iconv, __desc, &__cfrom, &__fbytes, 
+                                      &__cto, &__tbytes); 
+           }
+
+         if (__conv != size_t(-1))
+           {
+             __from_next = reinterpret_cast<const intern_type*>(__cfrom);
+             __to_next = reinterpret_cast<extern_type*>(__cto);
+             __ret = codecvt_base::ok;
+           }
+         else 
+           {
+             if (__fbytes < __fmultiple * (__from_end - __from))
+               {
+                 __from_next = reinterpret_cast<const intern_type*>(__cfrom);
+                 __to_next = reinterpret_cast<extern_type*>(__cto);
+                 __ret = codecvt_base::partial;
+               }
+             else
+               __ret = codecvt_base::error;
+           }
+       }
+      return __ret; 
+    }
+
+  template<typename _InternT, typename _ExternT>
+    codecvt_base::result
+    codecvt<_InternT, _ExternT, encoding_state>::
+    do_unshift(state_type& __state, extern_type* __to, 
+              extern_type* __to_end, extern_type*& __to_next) const
+    {
+      result __ret = codecvt_base::error;
+      if (__state.good())
+       {
+         const descriptor_type& __desc = __state.in_descriptor();
+         const size_t __tmultiple = sizeof(intern_type);
+         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_adaptor(iconv,__desc, NULL, NULL,
+                                          &__cto, &__tlen); 
+         
+         if (__conv != size_t(-1))
+           {
+             __to_next = reinterpret_cast<extern_type*>(__cto);
+             if (__tlen == __tmultiple * (__to_end - __to))
+               __ret = codecvt_base::noconv;
+             else if (__tlen == 0)
+               __ret = codecvt_base::ok;
+             else
+               __ret = codecvt_base::partial;
+           }
+         else 
+           __ret = codecvt_base::error;
+       }
+      return __ret; 
+    }
+   
+  template<typename _InternT, typename _ExternT>
+    codecvt_base::result
+    codecvt<_InternT, _ExternT, encoding_state>::
+    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 = codecvt_base::error;
+      if (__state.good())
+       {
+         const descriptor_type& __desc = __state.in_descriptor();
+         const size_t __fmultiple = sizeof(extern_type);
+         size_t __flen = __fmultiple * (__from_end - __from);
+         const size_t __tmultiple = sizeof(intern_type);
+         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);
+         char* __cfrom;
+         size_t __conv;
+
+         // Some encodings need a byte order marker as the first item
+         // in the byte stream, to designate endian-ness. The default
+         // value for the byte order marker is NULL, so if this is
+         // the case, it's not necessary and we can just go on our
+         // merry way.
+         int __ext_bom = __state.external_bom();
+         if (__ext_bom)
+           {     
+             size_t __size = __from_end - __from;
+             extern_type* __cfixed =  static_cast<extern_type*>
+               (__builtin_alloca(sizeof(extern_type) * (__size + 1)));
+             __cfixed[0] = static_cast<extern_type>(__ext_bom);
+             char_traits<extern_type>::copy(__cfixed + 1, __from, __size);
+             __cfrom = reinterpret_cast<char*>(__cfixed);
+             __conv = __iconv_adaptor(iconv, __desc, &__cfrom,
+                                       &__flen, &__cto, &__tlen); 
+           }
+         else
+           {
+             extern_type* __cfixed = const_cast<extern_type*>(__from);
+             __cfrom = reinterpret_cast<char*>(__cfixed);
+             __conv = __iconv_adaptor(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 = codecvt_base::ok;
+           }
+         else 
+           {
+             if (__flen < static_cast<size_t>(__from_end - __from))
+               {
+                 __from_next = reinterpret_cast<const extern_type*>(__cfrom);
+                 __to_next = reinterpret_cast<intern_type*>(__cto);
+                 __ret = codecvt_base::partial;
+               }
+             else
+               __ret = codecvt_base::error;
+           }
+       }
+      return __ret; 
+    }
+  
+  template<typename _InternT, typename _ExternT>
+    int 
+    codecvt<_InternT, _ExternT, encoding_state>::
+    do_encoding() const throw()
+    {
+      int __ret = 0;
+      if (sizeof(_ExternT) <= sizeof(_InternT))
+       __ret = sizeof(_InternT) / sizeof(_ExternT);
+      return __ret; 
+    }
+  
+  template<typename _InternT, typename _ExternT>
+    bool 
+    codecvt<_InternT, _ExternT, encoding_state>::
+    do_always_noconv() const throw()
+    { return false; }
+  
+  template<typename _InternT, typename _ExternT>
+    int 
+    codecvt<_InternT, _ExternT, encoding_state>::
+    do_length(state_type&, const extern_type* __from, 
+             const extern_type* __end, size_t __max) const
+    { return std::min(__max, static_cast<size_t>(__end - __from)); }
+
+  // _GLIBCXX_RESOLVE_LIB_DEFECTS
+  // 74.  Garbled text for codecvt::do_max_length
+  template<typename _InternT, typename _ExternT>
+    int 
+    codecvt<_InternT, _ExternT, encoding_state>::
+    do_max_length() const throw()
+    { return 1; }
+} // namespace std
+
diff --git a/libstdc++-v3/include/ext/enc_filebuf.h b/libstdc++-v3/include/ext/enc_filebuf.h
deleted file mode 100644 (file)
index c4df933..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-// filebuf with __enc_traits state type -*- C++ -*-
-
-// Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
-//
-// This file is part of the GNU ISO C++ Library.  This library is free
-// software; you can redistribute it and/or modify it under the
-// terms of the GNU General Public License as published by the
-// Free Software Foundation; either version 2, or (at your option)
-// any later version.
-
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING.  If not, write to the Free
-// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
-// USA.
-
-// As a special exception, you may use this file as part of a free software
-// library without restriction.  Specifically, if other files instantiate
-// templates or use macros or inline functions from this file, or you compile
-// this file and link it with other files to produce an executable, this
-// file does not by itself cause the resulting executable to be covered by
-// the GNU General Public License.  This exception does not however
-// invalidate any other reasons why the executable file might be covered by
-// the GNU General Public License.
-
-/** @file ext/enc_filebuf.h
- *  This file is a GNU extension to the Standard C++ Library.
- */
-
-#include <fstream>
-#include <locale>
-
-namespace __gnu_cxx
-{
-  // Custom traits type with __enc_traits for the state type, and the
-  // associated fpos<__enc_traits> for the position type, all other
-  // bits equivalent to the required char_traits instantiations.
-  /// @brief  class enc_char_traits.
-  template<typename _CharT>
-    struct enc_char_traits: public std::char_traits<_CharT>
-    {
-      typedef std::__enc_traits                        state_type;
-      typedef typename std::fpos<state_type>   pos_type;
-    };
-
-  /// @brief  class enc_filebuf.
-  template<typename _CharT>
-    class enc_filebuf
-    : public std::basic_filebuf<_CharT, enc_char_traits<_CharT> >
-    {
-    public:
-      typedef enc_char_traits<_CharT>          traits_type;
-      typedef typename traits_type::state_type state_type;
-      typedef typename traits_type::pos_type   pos_type;
-
-      enc_filebuf(state_type& __state)
-      : std::basic_filebuf<_CharT, enc_char_traits<_CharT> >()
-      {
-       this->_M_state_beg = __state;
-       this->_M_state_beg._M_init();
-      }
-
-    private:
-      // concept requirements:
-      // Set state type to something useful.
-      // Something more than copyconstructible is needed here, so
-      // require default and copy constructible + assignment operator.
-      __glibcxx_class_requires(state_type, _SGIAssignableConcept)
-    };
-} // namespace __gnu_cxx
index 2010593f51a2cab18dff707e39fe2f0025e9ee13..7634225c7f5996a9804aa406a8416f4424aec057 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2000, 2002, 2004 Free Software Foundation, Inc.
+// Copyright (C) 2000, 2002, 2004, 2005 Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
 // software; you can redistribute it and/or modify it under the
@@ -25,7 +25,7 @@
 // invalidate any other reasons why the executable file might be covered by
 // the GNU General Public License.
 
-// Written by Benjamin Kosnik <bkoz@cygnus.com>
+// Written by Benjamin Kosnik <bkoz@redhat.com>
 
 #include <locale>
 
@@ -38,11 +38,6 @@ namespace std
   locale::id codecvt<wchar_t, char, mbstate_t>::id;
 #endif
 
-#ifdef _GLIBCXX_USE___ENC_TRAITS
-  // Definitions for static const data members of __enc_traits.
-  const int __enc_traits::_S_max_size;
-#endif 
-
   codecvt<char, char, mbstate_t>::
   codecvt(size_t __refs)
   : __codecvt_abstract_base<char, char, mbstate_t>(__refs),