On Friday 18 January 2002 4:29 pm, Jean-Marc Lasgouttes wrote: > >>>>> "Angus" == Angus Leeming <[EMAIL PROTECTED]> writes: > > Angus> On Friday 18 January 2002 4:04 pm, Jean-Marc Lasgouttes wrote: > Angus> Where do you want me to add the std::flush? > >> Because I know it exists and because it may magically repair some > >> broken insternal thing. I don't know really. > > Angus> That was "where" not "why". But I'll try. > > Right. I don't know actually.
Got it! The bug lies in the position counters of ostringstream. basic_stringbuf actually. Sometimes they ain't being set correctly. Importantly, they are used by the basic_stringbuf::str() function. The code does some comparisons of position variables to ascertain what to print out. We can force things to behave as we expect by making an explicit ostringstream::seekp(std::ios::beg) call before calling ostringstream::str(). For reference, here's the code in basic_stringbuf::str(). Complex! I've attached a patch that cures the problem reliablely. Angus /* * basic_string str() const */ template<class charT, class traits, class Allocator> basic_string<charT, traits, Allocator> basic_stringbuf<charT, traits, Allocator>::str() const { if ( end_pos == 0 ) return string_type(); if ( (end_pos > ( pptr() - pbase() )) && (end_pos > ( egptr() - eback() )) ) return string_type(data_, end_pos); else { if ( ( pptr() - pbase() ) > ( egptr() - eback() ) ) return string_type(data_, pptr() - pbase() ); else return string_type(data_, egptr() - eback() ); } }
Index: src/LaTeXFeatures.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/LaTeXFeatures.C,v retrieving revision 1.53 diff -u -p -r1.53 LaTeXFeatures.C --- src/LaTeXFeatures.C 2002/01/10 10:05:43 1.53 +++ src/LaTeXFeatures.C 2002/01/18 17:57:13 @@ -339,14 +339,18 @@ string const LaTeXFeatures::getTClassPre // the text class specific preamble LyXTextClass const & tclass = textclasslist.TextClass(params.textclass); ostringstream tcpreamble; - + tcpreamble << tclass.preamble(); for (layout_type i = 0; i < tclass.numLayouts(); ++i) { if (layout[i]) { - tcpreamble << tclass[i].preamble(); + tcpreamble << tclass[i].preamble(); } } + + // DEC's implementation of ostringstream has a bug which can be + // overcome with this forcing. + tcpreamble.seekp(std::ios::beg); return tcpreamble.str().c_str(); }