🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: gnu.g++.lib.bug
1 messages
1 total messages Started by Martin Junius Fri, 06 Nov 1992 16:20
libg++-2.2 - bug in istream: :get()/getline()
#315
Author: Martin Junius
Date: Fri, 06 Nov 1992 16:20
83 lines
2611 bytes
Bugs:

- istream::getline(), istream::get() in igetline.C set 
  ios::failbit when receiving an empty line as input and don't 
  set ios::eofbit when EOF occurs.
- streambuf::sgetline() doesn't communicate EOF from underflow() 
  to it's caller.

The following patch fixes this:

*** igetline.C-ORIG	Fri Nov  6 13:44:09 1992
--- igetline.C	Fri Nov  6 17:06:51 1992
***************
*** 23,30 ****
      if (ipfx1()) {
  	long count = rdbuf()->sgetline(buf, len, delim, 0);
  	_gcount = count;
! 	if (count <= 0 || count == len-1)
! 	    set(ios::failbit);
      }
      return *this;
  }
--- 23,32 ----
      if (ipfx1()) {
  	long count = rdbuf()->sgetline(buf, len, delim, 0);
  	_gcount = count;
! //	if (count <= 0 || count == len-1)
! //	    set(ios::failbit);
! 	if (count < 0)
! 	    set(ios::failbit|ios::eofbit);
      }
      return *this;
  }
***************
*** 34,41 ****
      _gcount = 0;
      if (ipfx1()) {
  	long count = rdbuf()->sgetline(buf, len, delim, -1);
! 	if (count <= 0)
! 	    set(ios::failbit);
  	else
  	    _gcount = count;
      }
--- 36,45 ----
      _gcount = 0;
      if (ipfx1()) {
  	long count = rdbuf()->sgetline(buf, len, delim, -1);
! //	if (count <= 0)
! //	    set(ios::failbit);
!         if (count < 0)
! 	    set(ios::failbit|ios::eofbit);
  	else
  	    _gcount = count;
      }
*** sgetline.C-ORIG	Fri Nov  6 16:42:00 1992
--- sgetline.C	Fri Nov  6 16:42:47 1992
***************
*** 34,40 ****
  	int len = egptr() - gptr();
  	if (len <= 0)
  	    if (underflow() == EOF)
! 		break;
  	    else
  		len = egptr() - gptr();
  	if (len >= (int)n)
--- 34,43 ----
  	int len = egptr() - gptr();
  	if (len <= 0)
  	    if (underflow() == EOF)
! 	    {
! 	    	*ptr = 0;
! 	    	return EOF;
! 	    }
  	    else
  		len = egptr() - gptr();
  	if (len >= (int)n)

Martin
-- 
 _____ _____
|     |___  |   Martin Junius           FIDO:      2:242/6.1
| | | |   | |   Communication Networks  Internet:  mj@dfv.rwth-aachen.de
|_|_|_|@work|   Aachen U of Technology  Phone:     ++49-241-8790220 (voice)
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads