Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r75335 - in trunk/boost/chrono: io io_v1
From: vicente.botet_at_[hidden]
Date: 2011-11-05 23:54:40


Author: viboes
Date: 2011-11-05 23:54:39 EDT (Sat, 05 Nov 2011)
New Revision: 75335
URL: http://svn.boost.org/trac/boost/changeset/75335

Log:
Chrono: Fix some bad setting of err
Text files modified:
   trunk/boost/chrono/io/time_point_io.hpp | 10 +++++-----
   trunk/boost/chrono/io_v1/chrono_io.hpp | 27 ++++++++++++++-------------
   2 files changed, 19 insertions(+), 18 deletions(-)

Modified: trunk/boost/chrono/io/time_point_io.hpp
==============================================================================
--- trunk/boost/chrono/io/time_point_io.hpp (original)
+++ trunk/boost/chrono/io/time_point_io.hpp 2011-11-05 23:54:39 EDT (Sat, 05 Nov 2011)
@@ -48,7 +48,7 @@
         /**
          * Change the timezone_type and time format ios state;
          */
- template <typename out_stream>
+ //template <typename out_stream>
         void operator()(std::ios_base &ios) const
         {
           set_time_fmt<CharT>(ios, fmt_);
@@ -70,11 +70,11 @@
         /**
          * Change the timezone_type and time format ios state;
          */
- template <typename out_stream>
- void operator()(out_stream &ios) const
- //void operator()(std::ios_base &ios) const
+ //template <typename out_stream>
+ //void operator()(out_stream &ios) const
+ void operator()(std::ios_base &ios) const
         {
- set_time_fmt<typename out_stream::char_type>(ios, "");
+ //set_time_fmt<typename out_stream::char_type>(ios, "");
           set_timezone(ios, tz_);
         }
       };

Modified: trunk/boost/chrono/io_v1/chrono_io.hpp
==============================================================================
--- trunk/boost/chrono/io_v1/chrono_io.hpp (original)
+++ trunk/boost/chrono/io_v1/chrono_io.hpp 2011-11-05 23:54:39 EDT (Sat, 05 Nov 2011)
@@ -272,6 +272,7 @@
     const Facet& f = std::use_facet<Facet>(loc);
     typedef typename chrono_detail::duration_io_intermediate<Rep>::type intermediate_type;
     intermediate_type r;
+ std::ios_base::iostate err = std::ios_base::goodbit;
     // read value into r
     is >> r;
     if (is.good())
@@ -312,7 +313,6 @@
                         f.template plural<ratio<1> >(),
                         f.template short_name<ratio<1> >()
                     };
- std::ios_base::iostate err = std::ios_base::goodbit;
                     const std::basic_string<CharT>* k = chrono_detail::scan_keyword(i, e,
                                   units, units + sizeof(units)/sizeof(units[0]),
                                   //~ std::use_facet<std::ctype<CharT> >(loc),
@@ -390,12 +390,10 @@
                         f.template plural<ratio<3600> >(),
                         f.template short_name<ratio<3600> >()
                     };
- std::ios_base::iostate err = std::ios_base::goodbit;
                     const std::basic_string<CharT>* k = chrono_detail::scan_keyword(i, e,
                                   units, units + sizeof(units)/sizeof(units[0]),
                                   //~ std::use_facet<std::ctype<CharT> >(loc),
                                   err);
- is.setstate(err);
                     switch ((k - units) / 3)
                     {
                     case 0:
@@ -475,7 +473,7 @@
                         den = 1;
                         break;
                     default:
- is.setstate(err);
+ is.setstate(err|is.failbit);
                         return is;
                     }
                 }
@@ -492,7 +490,7 @@
                     den > (std::numeric_limits<unsigned long long>::max)() / n2)
                 {
                     // (num/den) / Period overflows
- is.setstate(is.failbit);
+ is.setstate(err|is.failbit);
                     return is;
                 }
                 num *= d2;
@@ -500,18 +498,17 @@
 
                 typedef typename common_type<intermediate_type, unsigned long long>::type common_type_t;
 
- std::ios_base::iostate err = std::ios_base::goodbit;
                 // num / den is now factor to multiply by r
                 if (!chrono_detail::reduce(r, den, err))
                 {
- is.setstate(err);
+ is.setstate(err|is.failbit);
                   return is;
                 }
 
                 if (r > ((duration_values<common_type_t>::max)() / num))
                 {
                     // Conversion to Period overflowed
- is.setstate(is.failbit);
+ is.setstate(err|is.failbit);
                     return is;
                 }
                 common_type_t t = r * num;
@@ -523,13 +520,15 @@
                   if ( (duration_values<Rep>::max)() < pt)
                   {
                     // Conversion to Period overflowed
- err |= std::ios_base::failbit;
+ is.setstate(err|is.failbit);
                     return is;
                   }
                 }
                 // Success! Store it.
                 r = Rep(t);
                 d = duration<Rep, Period>(r);
+ is.setstate(err);
+ return is;
             }
             else {
                 is.setstate(is.failbit | is.eofbit);
@@ -539,14 +538,16 @@
         else
         {
             if (i == e)
- is.setstate(is.eofbit);
- is.setstate(is.failbit);
+ is.setstate(is.failbit|is.eofbit);
+ else
+ is.setstate(is.failbit);
+ return is;
         }
     }
     else {
- is.setstate(is.failbit);
+ //is.setstate(is.failbit);
+ return is;
     }
- return is;
 }
 
 


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk