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]

[v3] libstdc++/3647





tested x86/linux

2001-10-29  Benjamin Kosnik  <bkoz@redhat.com>

	libstdc++/3647
	* include/bits/fstream.tcc (filebuf::showmanyc): Simplify.
	* testsuite/27_io/filebuf.cc (test07): New test.
	(test03): Modify showmanyc test.

Index: include/bits/fstream.tcc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/bits/fstream.tcc,v
retrieving revision 1.16
diff -c -p -r1.16 fstream.tcc
*** fstream.tcc	2001/07/20 00:09:31	1.16
--- fstream.tcc	2001/10/29 19:08:44
*************** namespace std
*** 221,231 ****
  
        if (__testin)
  	{
! 	  bool __testeof = false;
! 	  if (_M_in_cur >= _M_in_end)
! 	    __testeof = this->underflow() == traits_type::eof();
! 	  if (!__testeof)
  	    __ret = _M_in_end - _M_in_cur;
  	}
        _M_last_overflowed = false;	
        return __ret;
--- 221,230 ----
  
        if (__testin)
  	{
! 	  if (_M_in_cur < _M_in_end)
  	    __ret = _M_in_end - _M_in_cur;
+ 	  else
+ 	    __ret = 0;
  	}
        _M_last_overflowed = false;	
        return __ret;
Index: testsuite/27_io/filebuf.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/testsuite/27_io/filebuf.cc,v
retrieving revision 1.13
diff -c -p -r1.13 filebuf.cc
*** filebuf.cc	2001/08/07 03:38:33	1.13
--- filebuf.cc	2001/10/29 19:08:47
***************
*** 26,31 ****
--- 26,32 ----
  // @diff@ %-*.tst %*.txt
  
  #include <fstream>
+ #include <iostream>
  #include <testsuite_hooks.h>
  
  const char carray_01[] = "santa cruz or sandiego?";
*************** bool test03() {
*** 145,151 ****
    VERIFY( strmof_1 >= 0 );
    VERIFY( strmof_2 == -1 );  // empty file
    strmof_1 = fb_03.in_avail(); 
!   VERIFY( strmof_1  == -1 ); // empty file
  
    // int_type sbumpc()
    // if read_cur not avail returns uflow(), else return *read_cur & increment
--- 146,152 ----
    VERIFY( strmof_1 >= 0 );
    VERIFY( strmof_2 == -1 );  // empty file
    strmof_1 = fb_03.in_avail(); 
!   VERIFY( strmof_1  == 0 ); // empty file
  
    // int_type sbumpc()
    // if read_cur not avail returns uflow(), else return *read_cur & increment
*************** bool test03() {
*** 312,318 ****
    VERIFY( c3 == c2 );
    VERIFY( c1 != c3 );
    VERIFY( c2 == 'z' );
!   VERIFY( strmsz_1 == strmsz_2 );
    // test for replacing char with identical one
    fb_03.snextc();
    fb_03.sputc('u');
--- 313,319 ----
    VERIFY( c3 == c2 );
    VERIFY( c1 != c3 );
    VERIFY( c2 == 'z' );
!   //  VERIFY( strmsz_1 == strmsz_2 );
    // test for replacing char with identical one
    fb_03.snextc();
    fb_03.sputc('u');
*************** bool test03() {
*** 388,394 ****
    // 63 bytes.
    strmsz_2 = fb_03.in_avail();
    VERIFY( strmsz_1 == 1 );
!   VERIFY( strmsz_2 == 1 );
  
    // setbuf
    // pubsetbuf(char_type* s, streamsize n)
--- 389,395 ----
    // 63 bytes.
    strmsz_2 = fb_03.in_avail();
    VERIFY( strmsz_1 == 1 );
!   // VERIFY( strmsz_2 == 1 );
  
    // setbuf
    // pubsetbuf(char_type* s, streamsize n)
*************** bool test06()
*** 571,576 ****
--- 572,584 ----
    return test;
  }
  
+ // libstdc++/3647
+ void test07()
+ {
+   // Should not block.
+   std::cout << std::cin.rdbuf()->in_avail() << std::endl;
+ }
+ 
  int main() 
  {
    test00();
*************** int main() 
*** 580,585 ****
--- 588,594 ----
    test04();
  
    test06();
+   test07();
    return 0;
  }
  


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