Ticket #12178: reset_stream_state.patch

File reset_stream_state.patch, 1.8 KB (added by oe@…, 6 years ago)
  • boost/log/sources/record_ostream.hpp

    diff -rupN boost_1_60_0/boost/log/sources/record_ostream.hpp boost_1_60_0.new/boost/log/sources/record_ostream.hpp
    old new struct stream_provider  
    252252        //! Log record stream adapter
    253253        basic_record_ostream< char_type > stream;
    254254
     255        //! Stream format flags
     256        std::ios_base::fmtflags fmtflags;
     257
     258        //! Stream precision
     259        std::streamsize precision;
     260
     261        //! Stream field width
     262        std::streamsize width;
     263
     264        //! Stream fill character
     265        char_type fill;
     266
    255267        //! Initializing constructor
    256         explicit stream_compound(record& rec) : next(NULL), stream(rec) {}
     268        explicit stream_compound(record& rec) :
     269            next(NULL),
     270            stream(rec),
     271            fmtflags(stream.flags()),
     272            precision(stream.precision()),
     273            width(stream.width()),
     274            fill(stream.fill())
     275        {
     276        }
    257277    };
    258278
    259279    //! The method returns an allocated stream compound
  • libs/log/src/record_ostream.cpp

    diff -rupN boost_1_60_0/libs/log/src/record_ostream.cpp boost_1_60_0.new/libs/log/src/record_ostream.cpp
    old new stream_provider< CharT >::allocate_compo  
    139139        stream_compound* p = pool.m_Top;
    140140        pool.m_Top = p->next;
    141141        p->next = NULL;
     142
     143        // restore the original stream state saved at construction
     144        p->stream.flags(p->fmtflags);
     145        p->stream.precision(p->precision);
     146        p->stream.width(p->width);
     147        p->stream.fill(p->fill);
     148
    142149        p->stream.attach_record(rec);
    143150        return p;
    144151    }