home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: gnu.g++.lib.bug
- Path: sparky!uunet!charon.amdahl.com!pacbell.com!sgiblab!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!dfv.rwth-aachen.DE!mj
- From: mj@dfv.rwth-aachen.DE (Martin Junius)
- Subject: libg++-2.2 - bug in istream: :get()/getline()
- Message-ID: <1992Nov6.162043.24604@dfv.rwth-aachen.de>
- Sender: gnulists@ai.mit.edu
- Organization: Communication Networks
- Distribution: gnu
- Date: Fri, 6 Nov 1992 16:20:43 GMT
- Approved: bug-lib-g++@prep.ai.mit.edu
- Lines: 84
-
- 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)
-
-