Topic: streambuf derivation error or bug in istream::getline?


Author: admin@rzaix13.uni-hamburg.de (Bernd Eggink)
Date: 1995/12/04
Raw View
Christopher Barber (cbarber@bbn.com) wrote:
>  I have derived a new class from streambuf and overloaded most
>  of the virtual protected members (overflow, underflow, xsgetn, xsputn, etc)
>  but do not touch the stream pointer methods (setg, gbump, setp, etc)
>  and as far as I understand the standard I don't need to.

>  The problem is that the implementation of istream::getline which I am using
>  (in gnu libio - I don't know the version offhand) accesses the gbeg, gnext,
>  gend pointers directly and ends up in an infinite loop when these pointers
>  are null (which is their default value).

>  I think this is a bug in the istream::getline implementation, but given
>  the complexity of the iostream classes am willing to consider the
>  possiblity that I have just misunderstood the spec.  Anyone, care to
>  comment?

You MUST call setp() and segp() from within your functions overflow() and
underflow() in order to set up the put/get area and reflect the fact
that the put area is now empty and ready to be filled again, rsp. that the
get area has been filled from the source and characters may now be
extracted.

 Bernd

--
+----------------------------------+
|          Bernd Eggink            |
|    Rechenzentrum Uni Hamburg     |
| admin@rzaix13.rrz.uni-hamburg.de |
+----------------------------------+


---
[ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]