Usenet comp.unix.tru64 (2000-2013)
 help / color / mirror / Atom feed
From: banderet@nagra.com (Gregoire Banderet)
Subject: iostream bug ?
Date: 30 Jan 2003 05:34:41 -0800	[thread overview]
Message-ID: <ded6cfa7.0301300534.992a24a@posting.google.com> (raw)

> uname -mrpsv
OSF1 V4.0 1530 alpha

> cat stream.cxx
#include <iostream>
#include <sstream>

int main(int NbArgs, char *pszArgs[])
{
        std::ostringstream ostrs;
   std::string strIn = "This is a string of 129
bytes....................................................................................................";
 //std::string strIn = "This is a string of 128
bytes...................................................................................................";

#ifdef WORKAROUND // we write the string per blocks of 128 bytes.
   long NbBytesWritten = 0;
   long NbBytesToWrite = strIn.length();
   long const NbBytesMax = 128;
   std::string strInLocalCopy = strIn;
        std::ostream &os = ostrs;
   
   while (NbBytesWritten < strIn.length())
   {
      NbBytesToWrite = NbBytesToWrite > NbBytesMax ? NbBytesMax :
NbBytesToWrite;
      os.write(strInLocalCopy.c_str(), NbBytesToWrite);
      strInLocalCopy.erase(0, NbBytesToWrite);
      NbBytesWritten += NbBytesToWrite;
      NbBytesToWrite = strIn.length() - NbBytesWritten;
   }
   
#else    // !WORKAROUND
   ostrs << strIn;
   ostrs.flush();
   
#endif   // WORKAROUND

   std::cout << ostrs.str() << std::endl;

}

> cxx -w0 -D__USE_STD_IOSTREAM stream.cxx -o stream
> ./stream

> cxx -w0 -D__USE_STD_IOSTREAM -DWORKAROUND stream.cxx -o stream
> ./stream
This is a string of 129
bytes....................................................................................................


                 reply	other threads:[~2003-01-30 13:34 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox