This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] libstdc++/9322


Hi,

This patch fixes PR libstdc++/9322 by removing the member variable
_M_buf_locale_init from basic_streambuf.

Tested on linux on x86.

Regards,
Petur

2003-01-22  Petur Runolfsson  <peturr02@ru.is>

	PR libstdc++/9322
	* include/std/std_streambuf.h
	(basic_streambuf::basic_streambuf,
	basic_streambuf::~basic_streambuf,
	basic_streambuf::getloc, basic_streambuf::imbue):
	Remove _M_buf_locale_init
	* include/bits/fstream.tcc (basic_filebuf::imbue):  Likewise
	* testsuite/27_io/filebuf_virtuals.cc (test08):  Add.
	* testsuite/27_io/streambuf_members.cc (test08):  Add.
	* testsuite/27_io/stringbuf_virtuals.cc (test08):  Add.

diff -c3pr ../tmp/gcc-20030120/libstdc++-v3/include/bits/fstream.tcc gcc-20030120/libstdc++-v3/include/bits/fstream.tcc
*** ../tmp/gcc-20030120/libstdc++-v3/include/bits/fstream.tcc	2002-11-11 23:18:04.000000000 +0000
--- gcc-20030120/libstdc++-v3/include/bits/fstream.tcc	2003-01-22 19:23:03.000000000 +0000
*************** namespace std
*** 473,479 ****
        if (__testbeg && _M_buf_locale != __loc)
  	{
  	  _M_buf_locale = __loc;
- 	  _M_buf_locale_init = true;
  	}
  
        // NB this may require the reconversion of previously
--- 473,478 ----
diff -c3pr ../tmp/gcc-20030120/libstdc++-v3/include/std/std_streambuf.h gcc-20030120/libstdc++-v3/include/std/std_streambuf.h
*** ../tmp/gcc-20030120/libstdc++-v3/include/std/std_streambuf.h	2002-11-21 07:06:41.000000000 +0000
--- gcc-20030120/libstdc++-v3/include/std/std_streambuf.h	2003-01-22 19:23:00.000000000 +0000
*************** namespace std
*** 224,236 ****
        */
        locale 			_M_buf_locale;	
  
-       /**
-        *  @if maint
-        *  True iff locale is initialized.
-        *  @endif
-       */
-       bool 			_M_buf_locale_init;
- 
        //@{
        /**
         *  @if maint
--- 224,229 ----
*************** namespace std
*** 364,370 ****
  	_M_buf_size = 0;
  	_M_buf_size_opt = 0;
  	_M_mode = ios_base::openmode(0);
- 	_M_buf_locale_init = false;
        }
  
        // [27.5.2.2.1] locales
--- 357,362 ----
*************** namespace std
*** 394,403 ****
        locale   
        getloc() const
        {
! 	if (_M_buf_locale_init)
! 	  return _M_buf_locale; 
! 	else 
! 	  return locale();
        } 
  
        // [27.5.2.2.2] buffer management and positioning
--- 386,392 ----
        locale   
        getloc() const
        {
! 	return _M_buf_locale; 
        } 
  
        // [27.5.2.2.2] buffer management and positioning
*************** namespace std
*** 584,590 ****
        _M_buf_unified(false), _M_in_beg(0), _M_in_cur(0), _M_in_end(0), 
        _M_out_beg(0), _M_out_cur(0), _M_out_end(0), 
        _M_mode(ios_base::openmode(0)), _M_buf_locale(locale()), 
!       _M_buf_locale_init(false), _M_pback_cur_save(0), _M_pback_end_save(0), 
        _M_pback_init(false)
        { }
  
--- 573,579 ----
        _M_buf_unified(false), _M_in_beg(0), _M_in_cur(0), _M_in_end(0), 
        _M_out_beg(0), _M_out_cur(0), _M_out_end(0), 
        _M_mode(ios_base::openmode(0)), _M_buf_locale(locale()), 
!       _M_pback_cur_save(0), _M_pback_end_save(0), 
        _M_pback_init(false)
        { }
  
*************** namespace std
*** 700,706 ****
        virtual void 
        imbue(const locale& __loc) 
        { 
- 	_M_buf_locale_init = true;
  	if (_M_buf_locale != __loc)
  	  _M_buf_locale = __loc;
        }
--- 689,694 ----
diff -c3pr ../tmp/gcc-20030120/libstdc++-v3/testsuite/27_io/filebuf_virtuals.cc gcc-20030120/libstdc++-v3/testsuite/27_io/filebuf_virtuals.cc
*** ../tmp/gcc-20030120/libstdc++-v3/testsuite/27_io/filebuf_virtuals.cc	2002-07-31 02:47:36.000000000 +0000
--- gcc-20030120/libstdc++-v3/testsuite/27_io/filebuf_virtuals.cc	2003-01-22 18:46:21.000000000 +0000
***************
*** 21,26 ****
--- 21,27 ----
  // 27.8.1.4 Overridden virtual functions
  
  #include <fstream>
+ #include <locale>
  #include <testsuite_hooks.h>
  
  // @require@ %-*.tst %-*.txt
*************** void test06()
*** 514,520 ****
    VERIFY( buffer[0] == 'a' );
  }
  
! main() 
  {
    test01();
    test02();
--- 515,543 ----
    VERIFY( buffer[0] == 'a' );
  }
  
! // libstdc++/9322
! void test08()
! {
!   using std::locale;
!   bool test = true;
! 
!   locale loc;
!   std::filebuf ob;
!   VERIFY( ob.getloc() == loc );
! 
!   locale::global(locale("en_US"));
!   VERIFY( ob.getloc() == loc );
! 
!   locale loc_de ("de_DE");
!   locale ret = ob.pubimbue(loc_de);
!   VERIFY( ob.getloc() == loc_de );
!   VERIFY( ret == loc );
! 
!   locale::global(loc);
!   VERIFY( ob.getloc() == loc_de );
! }
! 
! int main() 
  {
    test01();
    test02();
*************** main() 
*** 524,528 ****
--- 547,552 ----
    test05();
    test06();
  
+   test08();
    return 0;
  }
diff -c3pr ../tmp/gcc-20030120/libstdc++-v3/testsuite/27_io/streambuf_members.cc gcc-20030120/libstdc++-v3/testsuite/27_io/streambuf_members.cc
*** ../tmp/gcc-20030120/libstdc++-v3/testsuite/27_io/streambuf_members.cc	2002-07-26 01:49:36.000000000 +0000
--- gcc-20030120/libstdc++-v3/testsuite/27_io/streambuf_members.cc	2003-01-22 18:46:18.000000000 +0000
***************
*** 33,38 ****
--- 33,39 ----
  #include <streambuf>
  #include <string>
  #include <ostream>
+ #include <locale>
  #include <testsuite_hooks.h>
  
  class testbuf : public std::streambuf
*************** test07()
*** 364,369 ****
--- 365,392 ----
    VERIFY(out.good());
  }
  
+ // libstdc++/9322
+ void test08()
+ {
+   using std::locale;
+   bool test = true;
+ 
+   locale loc;
+   testbuf2 ob;
+   VERIFY( ob.getloc() == loc );
+ 
+   locale::global(locale("en_US"));
+   VERIFY( ob.getloc() == loc );
+ 
+   locale loc_de ("de_DE");
+   locale ret = ob.pubimbue(loc_de);
+   VERIFY( ob.getloc() == loc_de );
+   VERIFY( ret == loc );
+ 
+   locale::global(loc);
+   VERIFY( ob.getloc() == loc_de );
+ }
+ 
  int main() 
  {
    test01();
*************** int main() 
*** 374,378 ****
--- 397,403 ----
    test05();
  
    test07();
+ 
+   test08();
    return 0;
  }
diff -c3pr ../tmp/gcc-20030120/libstdc++-v3/testsuite/27_io/stringbuf_virtuals.cc gcc-20030120/libstdc++-v3/testsuite/27_io/stringbuf_virtuals.cc
*** ../tmp/gcc-20030120/libstdc++-v3/testsuite/27_io/stringbuf_virtuals.cc	2002-04-09 06:14:32.000000000 +0000
--- gcc-20030120/libstdc++-v3/testsuite/27_io/stringbuf_virtuals.cc	2003-01-22 18:46:22.000000000 +0000
***************
*** 21,26 ****
--- 21,27 ----
  // 27.7.1.3 Overridden virtual functions
  
  #include <sstream>
+ #include <locale>
  #include <testsuite_hooks.h>
  
  void test01()
*************** void test02(std::stringbuf& in, bool pas
*** 70,75 ****
--- 71,98 ----
    VERIFY( p == bad );
  }
  
+ // libstdc++/9322
+ void test08()
+ {
+   using std::locale;
+   bool test = true;
+ 
+   locale loc;
+   std::stringbuf ob;
+   VERIFY( ob.getloc() == loc );
+ 
+   locale::global(locale("en_US"));
+   VERIFY( ob.getloc() == loc );
+ 
+   locale loc_de ("de_DE");
+   locale ret = ob.pubimbue(loc_de);
+   VERIFY( ob.getloc() == loc_de );
+   VERIFY( ret == loc );
+ 
+   locale::global(loc);
+   VERIFY( ob.getloc() == loc_de );
+ }
+ 
  int main() 
  {
    using namespace std;
*************** int main() 
*** 83,87 ****
--- 106,111 ----
    test02(in2, false);
    test02(in3, false);
  
+   test08();
    return 0;
  }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]