aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/config/locale
diff options
context:
space:
mode:
authorBenjamin Kosnik <bkoz@gcc.gnu.org>2004-03-27 16:21:21 +0000
committerBenjamin Kosnik <bkoz@gcc.gnu.org>2004-03-27 16:21:21 +0000
commita5f105b59031f43cc15e2a44293a7631dfea4253 (patch)
tree13503acaa4f6fbf5791b17b4ed6108e955151b1d /libstdc++-v3/config/locale
parent84c1fa24b1cb78ca71c2f5a490f93f266073e9bc (diff)
downloadgcc-a5f105b59031f43cc15e2a44293a7631dfea4253.zip
gcc-a5f105b59031f43cc15e2a44293a7631dfea4253.tar.gz
gcc-a5f105b59031f43cc15e2a44293a7631dfea4253.tar.bz2
[multiple changes]
2004-03-27 Benjamin Kosnik <bkoz@redhat.com> libstdc++ PR/13598 * config/locale/ieee_1003.1-2001/codecvt_specializations.h (__enc_traits::_M_destroy): New. (__enc_traits::~__enc_traits): Use it. (__enc_traits::operator=): Use _M_destroy, _M_init. (__enc_traits::__enc_traits): Same. 2004-03-27 Petur Runolfsson <peturr02@ru.is> * testsuite/ext/enc_filebuf/char/13598.cc: New. From-SVN: r80027
Diffstat (limited to 'libstdc++-v3/config/locale')
-rw-r--r--libstdc++-v3/config/locale/ieee_1003.1-2001/codecvt_specializations.h38
1 files changed, 27 insertions, 11 deletions
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
index efa8c37..ef0923d 100644
--- a/libstdc++-v3/config/locale/ieee_1003.1-2001/codecvt_specializations.h
+++ b/libstdc++-v3/config/locale/ieee_1003.1-2001/codecvt_specializations.h
@@ -1,6 +1,6 @@
// Locale support (codecvt) -*- C++ -*-
-// Copyright (C) 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+// 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
@@ -85,6 +85,7 @@
{
strncpy(_M_int_enc, __int, _S_max_size);
strncpy(_M_ext_enc, __ext, _S_max_size);
+ _M_init();
}
// 21.1.2 traits typedefs
@@ -92,12 +93,17 @@
// 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.
@@ -106,21 +112,15 @@
{
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;
+ _M_destroy();
+ _M_init();
return *this;
}
~__enc_traits()
- {
- __desc_type __err = reinterpret_cast<iconv_t>(-1);
- if (_M_in_desc && _M_in_desc != __err)
- iconv_close(_M_in_desc);
- if (_M_out_desc && _M_out_desc != __err)
- iconv_close(_M_out_desc);
- }
+ { _M_destroy(); }
void
_M_init()
@@ -142,6 +142,22 @@
}
}
+ 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()
{
@@ -173,7 +189,7 @@
const char*
_M_get_external_enc()
- { return _M_ext_enc; }
+ { return _M_ext_enc; }
};
// Partial specialization