Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r54800 - in trunk/boost/spirit/home/karma: detail numeric/detail
From: hartmut.kaiser_at_[hidden]
Date: 2009-07-08 14:28:43


Author: hkaiser
Date: 2009-07-08 14:28:42 EDT (Wed, 08 Jul 2009)
New Revision: 54800
URL: http://svn.boost.org/trac/boost/changeset/54800

Log:
Spirit: fixing Karma output_iterator and tweaks to numeric utils
Text files modified:
   trunk/boost/spirit/home/karma/detail/output_iterator.hpp | 9 ++++++---
   trunk/boost/spirit/home/karma/numeric/detail/numeric_utils.hpp | 13 +++++++------
   2 files changed, 13 insertions(+), 9 deletions(-)

Modified: trunk/boost/spirit/home/karma/detail/output_iterator.hpp
==============================================================================
--- trunk/boost/spirit/home/karma/detail/output_iterator.hpp (original)
+++ trunk/boost/spirit/home/karma/detail/output_iterator.hpp 2009-07-08 14:28:42 EDT (Wed, 08 Jul 2009)
@@ -297,9 +297,12 @@
         }
         output_iterator operator++(int)
         {
- output_iterator t(*this);
- ++sink;
- return t;
+ if (NULL == buffer) {
+ output_iterator t(*this);
+ ++sink;
+ return t;
+ }
+ return *this;
         }
 
         template <typename T>

Modified: trunk/boost/spirit/home/karma/numeric/detail/numeric_utils.hpp
==============================================================================
--- trunk/boost/spirit/home/karma/numeric/detail/numeric_utils.hpp (original)
+++ trunk/boost/spirit/home/karma/numeric/detail/numeric_utils.hpp 2009-07-08 14:28:42 EDT (Wed, 08 Jul 2009)
@@ -362,7 +362,7 @@
                 // than Radix
                 return static_cast<long>(n % Radix);
             }
-
+
             template <typename T>
             static long call(T n, mpl::false_)
             {
@@ -370,7 +370,7 @@
                 using namespace std;
                 return cast_to_long::call(fmod(n, T(Radix)));
             }
-
+
             template <typename T>
             static long call(T n)
             {
@@ -485,7 +485,7 @@
                 *sink = is_negative ? '-' : '+';
             else
                 *sink = ' ';
-
+
             ++sink;
             return true;
         }
@@ -629,17 +629,18 @@
             fractional_part = floor(fractional_part * precexp + U(0.5));
             if (fractional_part >= precexp)
             {
- fractional_part -= precexp;
+ fractional_part = floor(fractional_part - precexp);
                 integer_part += 1; // handle rounding overflow
             }
 
         // if trailing zeros are to be omitted, normalize the precision and
         // fractional part
             U long_int_part = floor(integer_part);
- U long_frac_part = floor(fractional_part);
+ U long_frac_part = fractional_part;
             unsigned prec = precision;
             if (!p.trailing_zeros(n))
             {
+ U frac_part_floor = long_frac_part;
                 if (0 != long_frac_part) {
                     // remove the trailing zeros
                     while (0 != prec &&
@@ -657,7 +658,7 @@
 
                 if (precision != prec)
                 {
- long_frac_part = floor(fractional_part) /
+ long_frac_part = frac_part_floor /
                         spirit::detail::pow10<U>(precision-prec);
                 }
             }


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