diff options
author | DongHun Kwak <dh0128.kwak@samsung.com> | 2019-12-05 15:12:59 +0900 |
---|---|---|
committer | DongHun Kwak <dh0128.kwak@samsung.com> | 2019-12-05 15:12:59 +0900 |
commit | b8cf34c691623e4ec329053cbbf68522a855882d (patch) | |
tree | 34da08632a99677f6b79ecb65e5b655a5b69a67f /boost/spirit/home/qi/numeric | |
parent | 3fdc3e5ee96dca5b11d1694975a65200787eab86 (diff) | |
download | boost-b8cf34c691623e4ec329053cbbf68522a855882d.tar.gz boost-b8cf34c691623e4ec329053cbbf68522a855882d.tar.bz2 boost-b8cf34c691623e4ec329053cbbf68522a855882d.zip |
Imported Upstream version 1.67.0upstream/1.67.0
Diffstat (limited to 'boost/spirit/home/qi/numeric')
-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 | ||||
-rw-r--r-- | boost/spirit/home/qi/numeric/numeric_utils.hpp | 3 |
3 files changed, 13 insertions, 41 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)) { diff --git a/boost/spirit/home/qi/numeric/numeric_utils.hpp b/boost/spirit/home/qi/numeric/numeric_utils.hpp index c37044a3b6..a1fb4730b3 100644 --- a/boost/spirit/home/qi/numeric/numeric_utils.hpp +++ b/boost/spirit/home/qi/numeric/numeric_utils.hpp @@ -69,8 +69,7 @@ namespace boost { namespace spirit { namespace qi extract_type; Iterator save = first; - if (!extract_type::parse(first, last, - detail::cast_unsigned<T>::call(attr_))) + if (!extract_type::parse(first, last, attr_)) { first = save; return false; |