acinclude.m4: Remove CCODECVT_H.

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
This commit is contained in:
Benjamin Kosnik 2005-01-07 19:34:46 +00:00 committed by Benjamin Kosnik
parent 5aa56f9d8f
commit 825bd0e1e8
10 changed files with 178 additions and 273 deletions

View 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

View 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)

View File

@ -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

View File

@ -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

View 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 \

View 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 \

View 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.
@ -466,10 +467,4 @@
~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

View 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,67 +32,66 @@
// 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>
// Written by Benjamin Kosnik <bkoz@redhat.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.
* 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___ENC_TRAITS 1
#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 __enc_traits
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 __desc_type;
typedef iconv_t descriptor_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];
std::string _M_int_enc;
// Name of external character set encoding.
char _M_ext_enc[_S_max_size];
std::string _M_ext_enc;
// 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;
descriptor_type _M_in_desc;
// Details the byte-order marker for the external encoding, if necessary.
// 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;
// Details the byte-order marker for the internal encoding, if necessary.
// 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);
}
// Number of external bytes needed to construct one complete
// character in the internal encoding.
// NB: -1 indicates variable, or stateful, encodings.
int _M_bytes;
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();
}
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
@ -101,56 +101,95 @@
// 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();
}
encoding_state(const encoding_state& __obj) : _M_in_desc(0), _M_out_desc(0)
{ construct(__obj); }
// Need assignment operator as well.
__enc_traits&
operator=(const __enc_traits& __obj)
encoding_state&
operator=(const encoding_state& __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();
construct(__obj);
return *this;
}
~__enc_traits()
{ _M_destroy(); }
~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
_M_init()
init()
{
const __desc_type __err = reinterpret_cast<iconv_t>(-1);
if (!_M_in_desc)
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, _M_ext_enc);
_M_in_desc = iconv_open(_M_int_enc.c_str(), _M_ext_enc.c_str());
if (_M_in_desc == __err)
__throw_runtime_error(__N("__enc_traits::_M_init "
"creating iconv input descriptor failed"));
std::__throw_runtime_error(__N("encoding_state::_M_init "
"creating iconv input descriptor failed"));
}
if (!_M_out_desc)
if (!_M_out_desc && __have_encodings)
{
_M_out_desc = iconv_open(_M_ext_enc, _M_int_enc);
_M_out_desc = iconv_open(_M_ext_enc.c_str(), _M_int_enc.c_str());
if (_M_out_desc == __err)
__throw_runtime_error(__N("__enc_traits::_M_init "
std::__throw_runtime_error(__N("encoding_state::_M_init "
"creating iconv output descriptor failed"));
}
}
void
_M_destroy()
construct(const encoding_state& __obj)
{
const __desc_type __err = reinterpret_cast<iconv_t>(-1);
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);
@ -162,56 +201,38 @@
_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.
/// @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, __enc_traits>
: public __codecvt_abstract_base<_InternT, _ExternT, __enc_traits>
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 __enc_traits state_type;
typedef __enc_traits::__desc_type __desc_type;
typedef __enc_traits __enc_type;
typedef __gnu_cxx::encoding_state state_type;
typedef state_type::descriptor_type descriptor_type;
// Data Members:
static locale::id id;
@ -222,11 +243,11 @@
{ }
explicit
codecvt(__enc_type* __enc, size_t __refs = 0)
codecvt(state_type& __enc, size_t __refs = 0)
: __codecvt_abstract_base<intern_type, extern_type, state_type>(__refs)
{ }
protected:
protected:
virtual
~codecvt() { }
@ -262,7 +283,7 @@
template<typename _InternT, typename _ExternT>
locale::id
codecvt<_InternT, _ExternT, __enc_traits>::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
@ -277,16 +298,16 @@
template<typename _InternT, typename _ExternT>
codecvt_base::result
codecvt<_InternT, _ExternT, __enc_traits>::
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._M_good())
if (__state.good())
{
const __desc_type* __desc = __state._M_get_out_descriptor();
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);
@ -303,7 +324,7 @@
// 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();
int __int_bom = __state.internal_bom();
if (__int_bom)
{
size_t __size = __from_end - __from;
@ -312,14 +333,14 @@
__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,
__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,
__conv = __iconv_adaptor(iconv, __desc, &__cfrom, &__fbytes,
&__cto, &__tbytes);
}
@ -346,21 +367,21 @@
template<typename _InternT, typename _ExternT>
codecvt_base::result
codecvt<_InternT, _ExternT, __enc_traits>::
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._M_good())
if (__state.good())
{
const __desc_type* __desc = __state._M_get_in_descriptor();
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,
size_t __conv = __iconv_adaptor(iconv,__desc, NULL, NULL,
&__cto, &__tlen);
if (__conv != size_t(-1))
@ -381,16 +402,16 @@
template<typename _InternT, typename _ExternT>
codecvt_base::result
codecvt<_InternT, _ExternT, __enc_traits>::
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._M_good())
if (__state.good())
{
const __desc_type* __desc = __state._M_get_in_descriptor();
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);
@ -407,7 +428,7 @@
// 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();
int __ext_bom = __state.external_bom();
if (__ext_bom)
{
size_t __size = __from_end - __from;
@ -416,14 +437,14 @@
__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,
__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,
__conv = __iconv_adaptor(iconv, __desc, &__cfrom,
&__flen, &__cto, &__tlen);
}
@ -451,24 +472,24 @@
template<typename _InternT, typename _ExternT>
int
codecvt<_InternT, _ExternT, __enc_traits>::
codecvt<_InternT, _ExternT, encoding_state>::
do_encoding() const throw()
{
int __ret = 0;
if (sizeof(_ExternT) <= sizeof(_InternT))
__ret = sizeof(_InternT)/sizeof(_ExternT);
__ret = sizeof(_InternT) / sizeof(_ExternT);
return __ret;
}
template<typename _InternT, typename _ExternT>
bool
codecvt<_InternT, _ExternT, __enc_traits>::
codecvt<_InternT, _ExternT, encoding_state>::
do_always_noconv() const throw()
{ return false; }
template<typename _InternT, typename _ExternT>
int
codecvt<_InternT, _ExternT, __enc_traits>::
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)); }
@ -477,7 +498,8 @@
// 74. Garbled text for codecvt::do_max_length
template<typename _InternT, typename _ExternT>
int
codecvt<_InternT, _ExternT, __enc_traits>::
codecvt<_InternT, _ExternT, encoding_state>::
do_max_length() const throw()
{ return 1; }
} // namespace std

View File

@ -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

View 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),