This is the mail archive of the libstdc++@sources.redhat.com mailing list for the libstdc++ project.


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

Re: [bug] istream::getline(char*,streamsize) still broken


On 20 Jul 2000 at 18:48 (-0700), Benjamin Kosnik wrote:
| 
| Sorry about the delay.....
|
| Ummmmm. Have you tried this recently?

yes. I just started digging back into stdc++ last night and noticed a 
handful of testsuite failures in my (hacked) tree, and noticed a couple
of failures in 27_io/istream_unformatted.cc... one I suggested, but now
realize a test is wrong (line 409)... more on the testsuite issues 
later, probably early Sunday.

| [snip]
|   const std::streamsize it = 5;
|   assert( eifs.getline(tmp,it) ); // use eifs.getline(...); eifs.fail() 
|   assert( eifs.gcount() == it );  // no, it - 1 max possible to extract
| 
| characters are no longer extracted and stored after n - 1, so gcount()

correct about 'extracted and stored'

| over it - 1 (4) would be incorrect.

...hmm

27.6.1.3 says:

getline(char_type* s, streamsize n, char_type delim);
  2) c==delim for the next available input character c (in which 
     case the input character is extracted but not stored)

and

streamsize gcount() const;
  2 Returns: The number of characters extracted by the last unformatted
    input member function called for the object.

... so we canmust extract n characters, if (&& only if) the nth 
character is the delimiter. I still believe the patch to istream.cc 
will enforce proper behavior. It does cause a couple of failures (bad 
tests IMO) in the testsuite, which I will address/justify when I get 
a breather :) I _seriously_ believe the tests in the original message 
accurately enforce the std.

thanks.
  Brent

-- 
Damon Brent Verner                        o      _     _         _
Cracker Jack? Surprise Certified  _o     /\_   _ \\o  (_)\__/o  (_)
brent@rcfile.org                _< \_   _>(_) (_)/<_    \_| \   _|/' \/
brent@linux1.org               (_)>(_) (_)        (_)   (_)    (_)'  _\o_

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