codecvt_specializations_ieee_1003.1-200x.h: Initialize all data members in copy ctor.

2002-01-31  Benjamin Kosnik  <bkoz@redhat.com>

	* config/locale/codecvt_specializations_ieee_1003.1-200x.h:
	Initialize all data members in copy ctor. Make ctors explicit.
	(__enc_traits::__enc_traits()): Default ctor does nothing.
	(__enc_traits::_M_init): Guard against multiple iconv_opens.
	* include/std/std_sstream.h (basic_stringbuf): Make data members
	protected.
	* include/std/std_fstream.h (basic_filebuf): Same.
	* include/std/std_streambuf.h: Tweak.
	* include/bits/streambuf.tcc: Same.
	* include/bits/sstream.tcc: Same.
	* include/bits/fstream.tcc: Same.

From-SVN: r49387
This commit is contained in:
Benjamin Kosnik 2002-02-01 03:20:39 +00:00 committed by Benjamin Kosnik
parent 6d747e63e0
commit 6f48900c2b
9 changed files with 86 additions and 72 deletions

View File

@ -1,3 +1,17 @@
2002-01-31 Benjamin Kosnik <bkoz@redhat.com>
* config/locale/codecvt_specializations_ieee_1003.1-200x.h:
Initialize all data members in copy ctor. Make ctors explicit.
(__enc_traits::__enc_traits()): Default ctor does nothing.
(__enc_traits::_M_init): Guard against multiple iconv_opens.
* include/std/std_sstream.h (basic_stringbuf): Make data members
protected.
* include/std/std_fstream.h (basic_filebuf): Same.
* include/std/std_streambuf.h: Tweak.
* include/bits/streambuf.tcc: Same.
* include/bits/sstream.tcc: Same.
* include/bits/fstream.tcc: Same.
2002-01-31 Loren Rittle <ljrittle@acm.org>
* testsuite/22_locale/codecvt_members_char_char.cc: Do not

View File

@ -1,6 +1,6 @@
# Makefile.in generated automatically by automake 1.4 from Makefile.am
# Makefile.in generated automatically by automake 1.4-p5 from Makefile.am
# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
# Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
@ -308,7 +308,7 @@ maintainer-clean-recursive:
dot_seen=no; \
rev=''; list='$(SUBDIRS)'; for subdir in $$list; do \
rev="$$subdir $$rev"; \
test "$$subdir" = "." && dot_seen=yes; \
test "$$subdir" != "." || dot_seen=yes; \
done; \
test "$$dot_seen" = "no" && rev=". $$rev"; \
target=`echo $@ | sed s/-recursive//`; \

View File

@ -1,6 +1,6 @@
// Locale support (codecvt) -*- C++ -*-
// Copyright (C) 2000, 2001 Free Software Foundation, Inc.
// Copyright (C) 2000, 2001, 2002 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
@ -35,23 +35,18 @@
// Written by Benjamin Kosnik <bkoz@cygnus.com>
// XXX
// __enc_traits may need to move up the locale header hierarchy,
// depending on if ctype ends up using it.
// Extensions to use icov for dealing with character encodings,
// including conversions and comparisons between various character
// sets. This object encapsulates data that may need to be shared between
// char_traits, codecvt and ctype.
// XXX
// Define this here to codecvt.cc can have _S_max_size definition.
#define _GLIBCPP_USE___ENC_TRAITS 1
#if _GLIBCPP_USE_SHADOW_HEADERS
using _C_legacy::CODESET;
#endif
// XXX
// Define this here to codecvt.cc can have _S_max_size definition.
#define _GLIBCPP_USE___ENC_TRAITS 1
// Extension to use icov for dealing with character encodings,
// including 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:
@ -81,7 +76,14 @@
int _M_int_bom;
public:
__enc_traits(const locale& __loc = locale())
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 locale& __loc)
: _M_in_desc(0), _M_out_desc(0), _M_ext_bom(0), _M_int_bom(0)
{
// __intc_end = whatever we are using internally, which is
@ -98,8 +100,8 @@
locale::facet::_S_destroy_c_locale(__cloc);
}
__enc_traits(const char* __int, const char* __ext, int __ibom = 0,
int __ebom = 0)
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(0), _M_int_bom(0)
{
strncpy(_M_int_enc, __int, _S_max_size);
@ -111,7 +113,7 @@
// typedef STATE_T state_type
// requires: state_type shall meet the requirements of
// CopyConstructible types (20.1.3)
__enc_traits(const __enc_traits& __obj)
__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);
@ -119,6 +121,18 @@
_M_int_bom = __obj._M_int_bom;
}
// 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_in_desc = 0;
_M_out_desc = 0;
_M_ext_bom = __obj._M_ext_bom;
_M_int_bom = __obj._M_int_bom;
}
~__enc_traits()
{
__desc_type __err = reinterpret_cast<iconv_t>(-1);
@ -131,19 +145,25 @@
void
_M_init()
{
__desc_type __err = reinterpret_cast<iconv_t>(-1);
_M_in_desc = iconv_open(_M_int_enc, _M_ext_enc);
if (_M_in_desc == __err)
__throw_runtime_error("creating iconv input descriptor failed.");
_M_out_desc = iconv_open(_M_ext_enc, _M_int_enc);
if (_M_out_desc == __err)
__throw_runtime_error("creating iconv output descriptor failed.");
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("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("creating iconv output descriptor failed.");
}
}
bool
_M_good()
{
__desc_type __err = reinterpret_cast<iconv_t>(-1);
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;
@ -157,14 +177,6 @@
_M_get_out_descriptor()
{ return &_M_out_desc; }
const char*
_M_get_internal_enc()
{ return _M_int_enc; }
const char*
_M_get_external_enc()
{ return _M_ext_enc; }
int
_M_get_external_bom()
{ return _M_ext_bom; }
@ -172,6 +184,14 @@
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; }
};
// Partial specialization
@ -250,9 +270,7 @@
__iconv_adaptor(size_t(*iconv_func)(iconv_t, _T, size_t*, char**, size_t*),
iconv_t cd, char** inbuf, size_t* inbytesleft,
char** outbuf, size_t* outbytesleft)
{
return iconv_func(cd, (_T)inbuf, inbytesleft, outbuf, outbytesleft);
}
{ return iconv_func(cd, (_T)inbuf, inbytesleft, outbuf, outbytesleft); }
template<typename _InternT, typename _ExternT>
codecvt_base::result

View File

@ -143,9 +143,7 @@ namespace std
int
basic_filebuf<_CharT, _Traits>::
fd()
{
return _M_file->fd();
}
{ return _M_file->fd(); }
template<typename _CharT, typename _Traits>
typename basic_filebuf<_CharT, _Traits>::__filebuf_type*
@ -604,14 +602,6 @@ namespace std
// XXX The part in the above comment is not done.
_M_last_overflowed = false;
}
} // namespace std
#endif // _CPP_BITS_FSTREAM_TCC
#endif

View File

@ -1,6 +1,7 @@
// String based streams -*- C++ -*-
// Copyright (C) 1997, 1998, 1999, 2001 Free Software Foundation, Inc.
// Copyright (C) 1997, 1998, 1999, 2001, 2002
// 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
@ -38,7 +39,6 @@
namespace std
{
template <class _CharT, class _Traits, class _Alloc>
typename basic_stringbuf<_CharT, _Traits, _Alloc>::int_type
basic_stringbuf<_CharT, _Traits, _Alloc>::
@ -206,8 +206,6 @@ namespace std
return __ret;
}
} // namespace std
#endif /* _CPP_BITS_SSTREAM_TCC */
#endif

View File

@ -1,6 +1,7 @@
// Stream buffer classes -*- C++ -*-
// Copyright (C) 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002
// 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
@ -34,8 +35,8 @@
#ifndef _CPP_BITS_STREAMBUF_TCC
#define _CPP_BITS_STREAMBUF_TCC 1
namespace std {
namespace std
{
template<typename _CharT, typename _Traits>
typename basic_streambuf<_CharT, _Traits>::int_type
basic_streambuf<_CharT, _Traits>::
@ -225,4 +226,4 @@ namespace std {
}
} // namespace std
#endif // _CPP_BITS_STREAMBUF_TCC
#endif

View File

@ -44,8 +44,8 @@
#include <istream>
#include <ostream>
#include <bits/basic_file.h>
#include <locale> // For codecvt
#include <bits/basic_file.h>
#include <bits/gthr.h>
namespace std
@ -72,7 +72,7 @@ namespace std
friend class ios_base; // For sync_with_stdio.
private:
protected:
// Data Members:
// External buffer.
__file_type* _M_file;
@ -422,7 +422,6 @@ namespace std
};
} // namespace std
#ifdef _GLIBCPP_NO_TEMPLATE_EXPORT
# define export
#ifdef _GLIBCPP_FULLY_COMPLIANT_HEADERS
@ -431,4 +430,3 @@ namespace std
#endif
#endif

View File

@ -66,7 +66,7 @@ namespace std
typedef basic_string<char_type, _Traits, _Alloc> __string_type;
typedef typename __string_type::size_type __size_type;
private:
protected:
// Data Members:
__string_type _M_string;
@ -360,8 +360,6 @@ namespace std
};
} // namespace std
#ifdef _GLIBCPP_NO_TEMPLATE_EXPORT
# define export
#ifdef _GLIBCPP_FULLY_COMPLIANT_HEADERS
@ -369,4 +367,4 @@ namespace std
#endif
#endif
#endif // _CPP_SSTREAM
#endif

View File

@ -83,7 +83,6 @@ namespace std
__streambuf_type* __sbin,__streambuf_type* __sbout);
protected:
// Pointer to the beginning of internally-allocated
// space. Filebuf manually allocates/deallocates this, whereas
// stringstreams attempt to use the built-in intelligence of the
@ -527,7 +526,6 @@ namespace std
operator=(const __streambuf_type&);
#endif
};
} // namespace std
#ifdef _GLIBCPP_NO_TEMPLATE_EXPORT
@ -537,5 +535,4 @@ namespace std
#endif
#endif
#endif /* _CPP_STREAMBUF */
#endif