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 22 Jul 2000 at 12:09 (-0700), Benjamin Kosnik wrote:
| 
| Brent:
| 
| I'm ready to concede. I've looked at existing practice and scoped the
| reflector archives. It was my contention that after n - 1 characters
| were extracted (ie, after 'd' in "abcd") that no more characters were
| extracted, period. 
| 
| We are/were both in agreement about what gcount() returns.
|
| This seems to be wrong. Here's what should happen (I'm hoping we can
| now easily agree on this:)

agreed :) 

The test case below passes in my tree with the patch applied. I still 
have to dig through the testsuite to verify that any failures related 
to this patch are reviewed. I should have a patch ready later
today/tonight.

| #include <cstring>
| #include <istream>
| #include <sstream>
| 
| // http://sources.redhat.com/ml/libstdc++/2000-07/msg00126.html
| int
| main()
| {
|   using namespace std;
| 
|   bool test = true;
|   const streamsize it = 5;
|   char tmp[it];
|   const char* str_lit = "abcd\n";
| 
|   stringbuf strbuf(str_lit, std::ios_base::in);
|   istream istr(&strbuf);
|   
|   istr.getline(tmp,it); 
|   test &= istr.gcount() == it;  // extracted whole string
|   test &= strlen(tmp) == 4;     // stored all but '\n'
|   test &= !istr.eof();          // extracted up to but not eof
|   test &= !istr.fail(); 	// failbit not set
|   
|   char c = 'z';
|   istr.get(c);
|   test &= c == 'z';
|   test &= istr.eof();
| 
|   return 0;
| }
| 
| 
|
| If you can re-submit your patch reflective of this, patch up any
| testcase weirdness and add the above, that would be cool.

queued ;)

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]