This is the mail archive of the 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


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:)

#include <cstring>
#include <istream>
#include <sstream>

  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);
  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 &= !; 	// failbit not set
  char c = 'z';
  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.


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