]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
codecvt_specializations_ieee_1003.1-200x.h: Initialize all data members in copy ctor.
authorBenjamin Kosnik <bkoz@redhat.com>
Fri, 1 Feb 2002 03:20:39 +0000 (03:20 +0000)
committerBenjamin Kosnik <bkoz@gcc.gnu.org>
Fri, 1 Feb 2002 03:20:39 +0000 (03:20 +0000)
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

libstdc++-v3/ChangeLog
libstdc++-v3/Makefile.in
libstdc++-v3/config/locale/codecvt_specializations_ieee_1003.1-200x.h
libstdc++-v3/include/bits/fstream.tcc
libstdc++-v3/include/bits/sstream.tcc
libstdc++-v3/include/bits/streambuf.tcc
libstdc++-v3/include/std/std_fstream.h
libstdc++-v3/include/std/std_sstream.h
libstdc++-v3/include/std/std_streambuf.h

index da392ff6a41e1339ac2ccfd999dc38e623a8c09d..7ec0a9b79df7bc0cc0796dc2b66788efa245c733 100644 (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
index 3385a30a864fbae4a1075ad5b7068faa926bd635..e1e996bf97550383967e412e6c8822c6ba9f4b05 100644 (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//`; \
index 3cf9fef9077723537042458f4f1713f2ad815f27..5cacffb81f88424af0962ba736c9a4f481225865 100644 (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
 
 // 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:
     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
       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);
     // 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);
+      _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_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;
     }
     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;
     _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; }
     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
     __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
index 420516bb50173b3d285a3a9277c1d5b55c70d4d6..85a0e085e3f744e6dae589b44787b65520943b66 100644 (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 
index ee8a6bfbf7b586b5ce0a6f901963f368fc54748d..d610532ae75bc0293f4e5b509e4c785f2240e3d0 100644 (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
index 9482c69c7adf223bfda10d9a487faebffde92d1a..81b40716f981e34f4274c15177b6ef2caa246e9a 100644 (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 
index ade2af9f7ac958cccc4ffe7a7237e71e07145f6b..7de9f30b3b3cb92fd9be39b18e87871ea44cde76 100644 (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 
-
index b32e63df0445ef64504102a265712795d2ed542a..fc7eb05654fe61b205677c9d32985af64622fecc 100644 (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
index ff58034ec897475fe82fa5494a858c2be6b77718..48ffd97e2f787d0f463321e5e872c1bc438d7417 100644 (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