Commit 6f48900c by Benjamin Kosnik Committed by Benjamin Kosnik

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
parent 6d747e63
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> 2002-01-31 Loren Rittle <ljrittle@acm.org>
* testsuite/22_locale/codecvt_members_char_char.cc: Do not * testsuite/22_locale/codecvt_members_char_char.cc: Do not
......
# 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 # This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it, # gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved. # with or without modifications, as long as this notice is preserved.
...@@ -308,7 +308,7 @@ maintainer-clean-recursive: ...@@ -308,7 +308,7 @@ maintainer-clean-recursive:
dot_seen=no; \ dot_seen=no; \
rev=''; list='$(SUBDIRS)'; for subdir in $$list; do \ rev=''; list='$(SUBDIRS)'; for subdir in $$list; do \
rev="$$subdir $$rev"; \ rev="$$subdir $$rev"; \
test "$$subdir" = "." && dot_seen=yes; \ test "$$subdir" != "." || dot_seen=yes; \
done; \ done; \
test "$$dot_seen" = "no" && rev=". $$rev"; \ test "$$dot_seen" = "no" && rev=". $$rev"; \
target=`echo $@ | sed s/-recursive//`; \ target=`echo $@ | sed s/-recursive//`; \
......
// Locale support (codecvt) -*- C++ -*- // 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 // 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 // software; you can redistribute it and/or modify it under the
...@@ -35,23 +35,18 @@ ...@@ -35,23 +35,18 @@
// Written by Benjamin Kosnik <bkoz@cygnus.com> // Written by Benjamin Kosnik <bkoz@cygnus.com>
// XXX // XXX
// __enc_traits may need to move up the locale header hierarchy, // Define this here to codecvt.cc can have _S_max_size definition.
// depending on if ctype ends up using it. #define _GLIBCPP_USE___ENC_TRAITS 1
// 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.
#if _GLIBCPP_USE_SHADOW_HEADERS #if _GLIBCPP_USE_SHADOW_HEADERS
using _C_legacy::CODESET; using _C_legacy::CODESET;
#endif #endif
// XXX // Extension to use icov for dealing with character encodings,
// Define this here to codecvt.cc can have _S_max_size definition. // including conversions and comparisons between various character
#define _GLIBCPP_USE___ENC_TRAITS 1 // sets. This object encapsulates data that may need to be shared between
// char_traits, codecvt and ctype.
class __enc_traits class __enc_traits
{ {
public: public:
...@@ -81,7 +76,14 @@ ...@@ -81,7 +76,14 @@
int _M_int_bom; int _M_int_bom;
public: 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) : _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 // __intc_end = whatever we are using internally, which is
...@@ -98,8 +100,8 @@ ...@@ -98,8 +100,8 @@
locale::facet::_S_destroy_c_locale(__cloc); locale::facet::_S_destroy_c_locale(__cloc);
} }
__enc_traits(const char* __int, const char* __ext, int __ibom = 0, explicit __enc_traits(const char* __int, const char* __ext,
int __ebom = 0) int __ibom = 0, int __ebom = 0)
: _M_in_desc(0), _M_out_desc(0), _M_ext_bom(0), _M_int_bom(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); strncpy(_M_int_enc, __int, _S_max_size);
...@@ -111,10 +113,22 @@ ...@@ -111,10 +113,22 @@
// typedef STATE_T state_type // typedef STATE_T state_type
// requires: state_type shall meet the requirements of // requires: state_type shall meet the requirements of
// CopyConstructible types (20.1.3) // 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);
_M_ext_bom = __obj._M_ext_bom;
_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_int_enc, __obj._M_int_enc, _S_max_size);
strncpy(_M_ext_enc, __obj._M_ext_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_ext_bom = __obj._M_ext_bom;
_M_int_bom = __obj._M_int_bom; _M_int_bom = __obj._M_int_bom;
} }
...@@ -131,19 +145,25 @@ ...@@ -131,19 +145,25 @@
void void
_M_init() _M_init()
{ {
__desc_type __err = reinterpret_cast<iconv_t>(-1); const __desc_type __err = reinterpret_cast<iconv_t>(-1);
_M_in_desc = iconv_open(_M_int_enc, _M_ext_enc); if (!_M_in_desc)
if (_M_in_desc == __err) {
__throw_runtime_error("creating iconv input descriptor failed."); _M_in_desc = iconv_open(_M_int_enc, _M_ext_enc);
_M_out_desc = iconv_open(_M_ext_enc, _M_int_enc); if (_M_in_desc == __err)
if (_M_out_desc == __err) __throw_runtime_error("creating iconv input descriptor failed.");
__throw_runtime_error("creating iconv output 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 bool
_M_good() _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; bool __test = _M_in_desc && _M_in_desc != __err;
__test &= _M_out_desc && _M_out_desc != __err; __test &= _M_out_desc && _M_out_desc != __err;
return __test; return __test;
...@@ -157,14 +177,6 @@ ...@@ -157,14 +177,6 @@
_M_get_out_descriptor() _M_get_out_descriptor()
{ return &_M_out_desc; } { 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 int
_M_get_external_bom() _M_get_external_bom()
{ return _M_ext_bom; } { return _M_ext_bom; }
...@@ -172,6 +184,14 @@ ...@@ -172,6 +184,14 @@
int int
_M_get_internal_bom() _M_get_internal_bom()
{ return _M_int_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 // Partial specialization
...@@ -250,9 +270,7 @@ ...@@ -250,9 +270,7 @@
__iconv_adaptor(size_t(*iconv_func)(iconv_t, _T, size_t*, char**, size_t*), __iconv_adaptor(size_t(*iconv_func)(iconv_t, _T, size_t*, char**, size_t*),
iconv_t cd, char** inbuf, size_t* inbytesleft, iconv_t cd, char** inbuf, size_t* inbytesleft,
char** outbuf, size_t* outbytesleft) 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> template<typename _InternT, typename _ExternT>
codecvt_base::result codecvt_base::result
......
...@@ -143,9 +143,7 @@ namespace std ...@@ -143,9 +143,7 @@ namespace std
int int
basic_filebuf<_CharT, _Traits>:: basic_filebuf<_CharT, _Traits>::
fd() fd()
{ { return _M_file->fd(); }
return _M_file->fd();
}
template<typename _CharT, typename _Traits> template<typename _CharT, typename _Traits>
typename basic_filebuf<_CharT, _Traits>::__filebuf_type* typename basic_filebuf<_CharT, _Traits>::__filebuf_type*
...@@ -604,14 +602,6 @@ namespace std ...@@ -604,14 +602,6 @@ namespace std
// XXX The part in the above comment is not done. // XXX The part in the above comment is not done.
_M_last_overflowed = false; _M_last_overflowed = false;
} }
} // namespace std } // namespace std
#endif // _CPP_BITS_FSTREAM_TCC #endif
// String based streams -*- C++ -*- // 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 // 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 // software; you can redistribute it and/or modify it under the
...@@ -38,7 +39,6 @@ ...@@ -38,7 +39,6 @@
namespace std namespace std
{ {
template <class _CharT, class _Traits, class _Alloc> template <class _CharT, class _Traits, class _Alloc>
typename basic_stringbuf<_CharT, _Traits, _Alloc>::int_type typename basic_stringbuf<_CharT, _Traits, _Alloc>::int_type
basic_stringbuf<_CharT, _Traits, _Alloc>:: basic_stringbuf<_CharT, _Traits, _Alloc>::
...@@ -206,8 +206,6 @@ namespace std ...@@ -206,8 +206,6 @@ namespace std
return __ret; return __ret;
} }
} // namespace std } // namespace std
#endif /* _CPP_BITS_SSTREAM_TCC */ #endif
// Stream buffer classes -*- C++ -*- // 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 // 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 // software; you can redistribute it and/or modify it under the
...@@ -34,8 +35,8 @@ ...@@ -34,8 +35,8 @@
#ifndef _CPP_BITS_STREAMBUF_TCC #ifndef _CPP_BITS_STREAMBUF_TCC
#define _CPP_BITS_STREAMBUF_TCC 1 #define _CPP_BITS_STREAMBUF_TCC 1
namespace std { namespace std
{
template<typename _CharT, typename _Traits> template<typename _CharT, typename _Traits>
typename basic_streambuf<_CharT, _Traits>::int_type typename basic_streambuf<_CharT, _Traits>::int_type
basic_streambuf<_CharT, _Traits>:: basic_streambuf<_CharT, _Traits>::
...@@ -225,4 +226,4 @@ namespace std { ...@@ -225,4 +226,4 @@ namespace std {
} }
} // namespace std } // namespace std
#endif // _CPP_BITS_STREAMBUF_TCC #endif
...@@ -44,8 +44,8 @@ ...@@ -44,8 +44,8 @@
#include <istream> #include <istream>
#include <ostream> #include <ostream>
#include <bits/basic_file.h>
#include <locale> // For codecvt #include <locale> // For codecvt
#include <bits/basic_file.h>
#include <bits/gthr.h> #include <bits/gthr.h>
namespace std namespace std
...@@ -72,7 +72,7 @@ namespace std ...@@ -72,7 +72,7 @@ namespace std
friend class ios_base; // For sync_with_stdio. friend class ios_base; // For sync_with_stdio.
private: protected:
// Data Members: // Data Members:
// External buffer. // External buffer.
__file_type* _M_file; __file_type* _M_file;
...@@ -422,7 +422,6 @@ namespace std ...@@ -422,7 +422,6 @@ namespace std
}; };
} // namespace std } // namespace std
#ifdef _GLIBCPP_NO_TEMPLATE_EXPORT #ifdef _GLIBCPP_NO_TEMPLATE_EXPORT
# define export # define export
#ifdef _GLIBCPP_FULLY_COMPLIANT_HEADERS #ifdef _GLIBCPP_FULLY_COMPLIANT_HEADERS
...@@ -431,4 +430,3 @@ namespace std ...@@ -431,4 +430,3 @@ namespace std
#endif #endif
#endif #endif
...@@ -66,7 +66,7 @@ namespace std ...@@ -66,7 +66,7 @@ namespace std
typedef basic_string<char_type, _Traits, _Alloc> __string_type; typedef basic_string<char_type, _Traits, _Alloc> __string_type;
typedef typename __string_type::size_type __size_type; typedef typename __string_type::size_type __size_type;
private: protected:
// Data Members: // Data Members:
__string_type _M_string; __string_type _M_string;
...@@ -360,8 +360,6 @@ namespace std ...@@ -360,8 +360,6 @@ namespace std
}; };
} // namespace std } // namespace std
#ifdef _GLIBCPP_NO_TEMPLATE_EXPORT #ifdef _GLIBCPP_NO_TEMPLATE_EXPORT
# define export # define export
#ifdef _GLIBCPP_FULLY_COMPLIANT_HEADERS #ifdef _GLIBCPP_FULLY_COMPLIANT_HEADERS
...@@ -369,4 +367,4 @@ namespace std ...@@ -369,4 +367,4 @@ namespace std
#endif #endif
#endif #endif
#endif // _CPP_SSTREAM #endif
...@@ -83,7 +83,6 @@ namespace std ...@@ -83,7 +83,6 @@ namespace std
__streambuf_type* __sbin,__streambuf_type* __sbout); __streambuf_type* __sbin,__streambuf_type* __sbout);
protected: protected:
// Pointer to the beginning of internally-allocated // Pointer to the beginning of internally-allocated
// space. Filebuf manually allocates/deallocates this, whereas // space. Filebuf manually allocates/deallocates this, whereas
// stringstreams attempt to use the built-in intelligence of the // stringstreams attempt to use the built-in intelligence of the
...@@ -527,7 +526,6 @@ namespace std ...@@ -527,7 +526,6 @@ namespace std
operator=(const __streambuf_type&); operator=(const __streambuf_type&);
#endif #endif
}; };
} // namespace std } // namespace std
#ifdef _GLIBCPP_NO_TEMPLATE_EXPORT #ifdef _GLIBCPP_NO_TEMPLATE_EXPORT
...@@ -537,5 +535,4 @@ namespace std ...@@ -537,5 +535,4 @@ namespace std
#endif #endif
#endif #endif
#endif /* _CPP_STREAMBUF */ #endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment