public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* libstdc++/4522: Improperly set eofbit in __copy_streambufs
@ 2001-10-10  8:36 howes
  0 siblings, 0 replies; 3+ messages in thread
From: howes @ 2001-10-10  8:36 UTC (permalink / raw)
  To: gcc-gnats

>Number:         4522
>Category:       libstdc++
>Synopsis:       Improperly set eofbit in __copy_streambufs
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Oct 10 08:36:00 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     Brad Howes
>Release:        3.0.1
>Organization:
>Environment:
System: SunOS max 5.8 Generic_108528-07 sun4u sparc SUNW,Sun-Blade-100
Architecture: sun4

	
host: sparc-sun-solaris2.8
build: sparc-sun-solaris2.8
target: sparc-sun-solaris2.8
configured with: ../gcc-3.0.1/configure 
>Description:
The following code raises EOF for cout, which is not correct:

  // foo.cc

  #include <iostream>
  #include <strstream>

  int
  main(int argc, const char* argv[])
  {
    const char* data = "first line # comment\n\
second line\n\
# commentary line\n\
last line\n";

    std::istrstream iss(data);
    std::cout << "Original:" << std::endl << iss.rdbuf();
    short state = std::cout.rdstate();
    std::cout.clear();
    std::cout << "flags: " << std::hex << state << std::endl;
  }

>How-To-Repeat:
Compiled using: g++ -g -o foo foo.cc

>Fix:
I've applied the following patches to my streambuf.tcc and istream.tcc, but I'm
not sure about their validity.

*** streambuf.tcc~	Tue Oct  9 08:38:39 2001
--- streambuf.tcc	Wed Oct 10 09:41:45 2001
***************
*** 204,221 ****
  	    __xtrct = __sbout->sputn(__sbin->gptr(), __bufsize);
  	    __ret += __xtrct;
  	    __sbin->_M_in_cur_move(__xtrct);
! 	    if (__xtrct == __bufsize)
  	      {
! 		int_type __c = __sbin->sgetc();
! 		if (__c == _Traits::eof())
  		  {
- 		    __ios.setstate(ios_base::eofbit);
  		    break;
  		  }
  		__bufsize = __sbin->in_avail();
  	      }
- 	    else
- 	      break;
  	  }
        }
        catch(exception& __fail) {
--- 204,218 ----
  	    __xtrct = __sbout->sputn(__sbin->gptr(), __bufsize);
  	    __ret += __xtrct;
  	    __sbin->_M_in_cur_move(__xtrct);
! 	    __bufsize -= __xtrct;
! 	    if (0 == __bufsize)
  	      {
! 		if (__sbin->sgetc() == _Traits::eof())
  		  {
  		    break;
  		  }
  		__bufsize = __sbin->in_avail();
  	      }
  	  }
        }
        catch(exception& __fail) {


*** istream.tcc~	Tue Oct  9 08:38:15 2001
--- istream.tcc	Wed Oct 10 09:38:01 2001
***************
*** 458,464 ****
--- 458,467 ----
        __streambuf_type* __sbin = this->rdbuf();
        sentry __cerb(*this, false);
        if (__sbout && __cerb)
+       {
  	__xtrct = __copy_streambufs(*this, __sbin, __sbout);
+ 	this->setstate(ios_base::eofbit);
+       }
        if (!__sbout || !__xtrct)
  	this->setstate(ios_base::failbit);
        return *this;
>Release-Note:
>Audit-Trail:
>Unformatted:


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: libstdc++/4522: Improperly set eofbit in __copy_streambufs
@ 2002-04-03 18:57 bkoz
  0 siblings, 0 replies; 3+ messages in thread
From: bkoz @ 2002-04-03 18:57 UTC (permalink / raw)
  To: bkoz, gcc-bugs, gcc-prs, howes

Synopsis: Improperly set eofbit in __copy_streambufs

State-Changed-From-To: feedback->closed
State-Changed-By: bkoz
State-Changed-When: Wed Apr  3 18:57:03 2002
State-Changed-Why:
    Fixed.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=4522


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: libstdc++/4522: Improperly set eofbit in __copy_streambufs
@ 2002-04-02 18:35 bkoz
  0 siblings, 0 replies; 3+ messages in thread
From: bkoz @ 2002-04-02 18:35 UTC (permalink / raw)
  To: bkoz, gcc-bugs, gcc-prs, howes, nobody

Synopsis: Improperly set eofbit in __copy_streambufs

Responsible-Changed-From-To: unassigned->bkoz
Responsible-Changed-By: bkoz
Responsible-Changed-When: Tue Apr  2 18:35:03 2002
Responsible-Changed-Why:
    Mine.
State-Changed-From-To: open->feedback
State-Changed-By: bkoz
State-Changed-When: Tue Apr  2 18:35:03 2002
State-Changed-Why:
    This is not a bug in current sources:
    
    %a.out 
    Original:
    first line # comment
    second line
    # commentary line
    last line
    flags: 0

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=4522


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2002-04-04  2:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-10-10  8:36 libstdc++/4522: Improperly set eofbit in __copy_streambufs howes
2002-04-02 18:35 bkoz
2002-04-03 18:57 bkoz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).