RE: TString bug (or feature)?

From: Arthur E. Snyder <snyder_at_slac.stanford.edu>
Date: Wed, 4 Apr 2007 09:47:34 -0700 (PDT)


Hi Philippe,

Root version is 4.04-02 currently used by BABAR.

I found the problem running gdb and don't have a simple example at hand, but I can try to make one.

-Art S.

A.E. Snyder, Group EC                        \!c*p?/
SLAC Mail Stop #95                          ((.   .))
Box 4349                                        |
Stanford, Ca, USA, 94309                      '\|/`
e-mail:snyder_at_slac.stanford.edu                 o
phone:650-926-2701                              _
http://www.slac.stanford.edu/~snyder          BaBar
FAX:650-926-2657                          Collaboration



On Wed, 4 Apr 2007, Philippe Canal wrote:

> Hi Arthur,
>
> I can not reproduce the problem (or do not understand your description :) ).
>
> Can you send me a complete running example (and the output as you see it)
> as well as the version of ROOT where it fails for you).
>
> Cheers,
> Philippe.
>
> -----Original Message-----
> From: owner-roottalk_at_pcroot.cern.ch [mailto:owner-roottalk_at_pcroot.cern.ch]
> On Behalf Of Arthur E. Snyder
> Sent: Monday, April 02, 2007 4:43 PM
> To: Rene Brun
> Cc: 'roottalk (Mailing list discussing all aspects of the ROOT system)'
> Subject: [ROOT] TString bug (or feature)?
>
> Hi Rene et al.,
>
> I find that when I try to read the blank separated charachters in a line
> into TString from an istringstream it has a strange behavior. If the last
> character is followed directly by a line-feed it gets skipped. Apparently
> eof or something is set by reading it and the loop ends w.o. giving you a
> chance at the characters just read. The result is you lose the last
> character string. If I use std::string instead, it works as I expect it
> too.
>
> The code is as follows:
>
> #include "readCard.hh"
> #include <TString.h>
> #include <iostream>
> #include <vector>
> #include <string>
>
> using std::istream;
> using std::endl;
> using std::cout;
>
> //read strings till "eol" marker or natural end; if nread!=0 read nread
> string (no marker)
> Int_t readCard(istream& card,std::vector<TString>& list,Int_t nread) {
> Int_t count=0;
>
> TString temp;
> // std::string temp;
> while(card >> temp) {
>
> cout << "count:" << count << " temp:" << temp << endl;
>
> if(nread==0 && temp=="eol") break;
> if(nread==0 && temp=="*eol") break;
> if(nread==0 && temp=="!eol") break;
> count++;
>
> list.push_back(temp);
> if(count==nread) break;
>
> } // loop
>
> return count;
> }
>
> -Art S.
>
>
>
Received on Wed Apr 04 2007 - 18:47:43 CEST

This archive was generated by hypermail 2.2.0 : Wed Apr 04 2007 - 23:50:01 CEST