"Kayvan A. Sylvan" <[EMAIL PROTECTED]> writes:

| On Wed, May 01, 2002 at 07:01:49PM +0200, Lars Gullik Bjønnes wrote:
>> [EMAIL PROTECTED] (Lars Gullik Bjønnes) writes:
>> 
>> | Dekel Tsur <[EMAIL PROTECTED]> writes:
>> >
>> | | The bug was due to a bug in lyxstring (operator <<)
>> | | The problem was that the code did not skip the whitespace before the first
>> | | non whitespace char.
>> | | Attached are two possible fixes:
>> | | The first one was copied from g++-2/std/bastring.cc
>> | | (I don't know what side-effects is.ipfx0 has).
>> >
>> | except that it does not exist in a standard stream?
>> >
>> | Also I am not sure that your change is according to the standard.
>> >
>> | | The second one does the whitespace skipping manually.
>> 
>> Can you sheck if this is possible to use with lyxstring:
>> (it probably require a istream that is pretty standard conforming)

What about this version then:
(and it is probably not correct anymore)

istream & operator>>(istream & is, lyxstring & str)
{
        typedef istream            istream_type;
        typedef int         int_type;
        typedef std::streambuf streambuf_type;
        typedef string     string_type;
        typedef string::size_type         size_type;
        size_type extracted = 0;

        str.erase();
        std::streamsize w = is.width();
        size_type n;
        n = w > 0 ? static_cast<size_type>(w) : str.max_size();
        int_type const eof = EOF;
        streambuf_type * sb = is.rdbuf();
        int_type c = sb->sgetc();

        while (extracted < n
               && c != eof && !isspace(c)) {
                str += c;
                ++extracted;
                c = sb->snextc();
        }
        if (c == eof)
                is.setstate(std::ios::eofbit);
        is.width(0);
        if (!extracted)
                is.setstate(std::ios::failbit);
        return is;
}

-- 
        Lgb

Reply via email to