diff options
Diffstat (limited to 'boost/spirit/home/qi/numeric/detail')
-rw-r--r-- | boost/spirit/home/qi/numeric/detail/numeric_utils.hpp | 37 | ||||
-rw-r--r-- | boost/spirit/home/qi/numeric/detail/real_impl.hpp | 14 |
2 files changed, 12 insertions, 39 deletions
diff --git a/boost/spirit/home/qi/numeric/detail/numeric_utils.hpp b/boost/spirit/home/qi/numeric/detail/numeric_utils.hpp index 7f466ee65b..f1154dc92a 100644 --- a/boost/spirit/home/qi/numeric/detail/numeric_utils.hpp +++ b/boost/spirit/home/qi/numeric/detail/numeric_utils.hpp @@ -101,11 +101,9 @@ namespace boost { namespace spirit { namespace qi { namespace detail template <typename Char> inline static bool is_valid(Char ch) { - if (Radix <= 10) - return (ch >= '0' && ch <= static_cast<Char>('0' + Radix -1)); - return (ch >= '0' && ch <= '9') - || (ch >= 'a' && ch <= static_cast<Char>('a' + Radix -10 -1)) - || (ch >= 'A' && ch <= static_cast<Char>('A' + Radix -10 -1)); + return (ch >= '0' && ch <= (Radix > 10 ? '9' : static_cast<Char>('0' + Radix -1))) + || (Radix > 10 && ch >= 'a' && ch <= static_cast<Char>('a' + Radix -10 -1)) + || (Radix > 10 && ch >= 'A' && ch <= static_cast<Char>('A' + Radix -10 -1)); } template <typename Char> @@ -506,35 +504,6 @@ namespace boost { namespace spirit { namespace qi { namespace detail }; #undef SPIRIT_NUMERIC_INNER_LOOP - - /////////////////////////////////////////////////////////////////////////// - // Cast an signed integer to an unsigned integer - /////////////////////////////////////////////////////////////////////////// - template <typename T, - bool force_unsigned - = mpl::and_<is_integral<T>, is_signed<T> >::value> - struct cast_unsigned; - - template <typename T> - struct cast_unsigned<T, true> - { - typedef typename make_unsigned<T>::type unsigned_type; - typedef typename make_unsigned<T>::type& unsigned_type_ref; - - inline static unsigned_type_ref call(T& n) - { - return unsigned_type_ref(n); - } - }; - - template <typename T> - struct cast_unsigned<T, false> - { - inline static T& call(T& n) - { - return n; - } - }; }}}} #if defined(BOOST_MSVC) diff --git a/boost/spirit/home/qi/numeric/detail/real_impl.hpp b/boost/spirit/home/qi/numeric/detail/real_impl.hpp index 9aa5bb8bbd..c8d20876fa 100644 --- a/boost/spirit/home/qi/numeric/detail/real_impl.hpp +++ b/boost/spirit/home/qi/numeric/detail/real_impl.hpp @@ -81,12 +81,13 @@ namespace boost { namespace spirit { namespace traits detail::compensate_roundoff(n, acc_n); n /= pow10<T>(-min_exp); - // return false if (-exp + min_exp) exceeds the -min_exp + // return false if exp still exceeds the min_exp // do this check only for primitive types! - if (is_floating_point<T>() && (-exp + min_exp) > -min_exp) + exp += -min_exp; + if (is_floating_point<T>() && exp < min_exp) return false; - n /= pow10<T>(-exp + min_exp); + n /= pow10<T>(-exp); } else { @@ -233,6 +234,7 @@ namespace boost { namespace spirit { namespace qi { namespace detail // to zero (0) only if we already got a number. if (p.parse_frac_n(first, last, acc_n, frac_digits)) { + BOOST_ASSERT(frac_digits >= 0); } else if (!got_a_number || !p.allow_trailing_dot) { @@ -285,13 +287,15 @@ namespace boost { namespace spirit { namespace qi { namespace detail // by resetting 'first' prior to the exponent prefix (e|E) first = e_pos; // Scale the number by -frac_digits. - traits::scale(-frac_digits, n, acc_n); + bool r = traits::scale(-frac_digits, n, acc_n); + BOOST_VERIFY(r); } } else if (frac_digits) { // No exponent found. Scale the number by -frac_digits. - traits::scale(-frac_digits, n, acc_n); + bool r = traits::scale(-frac_digits, n, acc_n); + BOOST_VERIFY(r); } else if (traits::is_equal_to_one(acc_n)) { |