Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r74831 - in trunk/boost/spirit/home: qi/binary support/detail support/detail/endian
From: hartmut.kaiser_at_[hidden]
Date: 2011-10-08 20:42:36


Author: hkaiser
Date: 2011-10-08 20:42:35 EDT (Sat, 08 Oct 2011)
New Revision: 74831
URL: http://svn.boost.org/trac/boost/changeset/74831

Log:
Adding safe-guards
Text files modified:
   trunk/boost/spirit/home/qi/binary/binary.hpp | 9 +++++++++
   trunk/boost/spirit/home/support/detail/endian.hpp | 4 ----
   trunk/boost/spirit/home/support/detail/endian/endian.hpp | 6 ++++++
   trunk/boost/spirit/home/support/detail/pow10.hpp | 6 +++---
   4 files changed, 18 insertions(+), 7 deletions(-)

Modified: trunk/boost/spirit/home/qi/binary/binary.hpp
==============================================================================
--- trunk/boost/spirit/home/qi/binary/binary.hpp (original)
+++ trunk/boost/spirit/home/qi/binary/binary.hpp 2011-10-08 20:42:35 EDT (Sat, 08 Oct 2011)
@@ -112,18 +112,21 @@
         template <>
         struct integer<8>
         {
+ enum { size = 1 };
             typedef uint_least8_t type;
         };
 
         template <>
         struct integer<16>
         {
+ enum { size = 2 };
             typedef uint_least16_t type;
         };
 
         template <>
         struct integer<32>
         {
+ enum { size = 4 };
             typedef uint_least32_t type;
         };
 
@@ -131,6 +134,7 @@
         template <>
         struct integer<64>
         {
+ enum { size = 8 };
             typedef uint_least64_t type;
         };
 #endif
@@ -185,6 +189,11 @@
           , Context& /*context*/, Skipper const& skipper
           , Attribute& attr) const
         {
+ // This assertion makes sure that the supplied attribute type is
+ // large enough to hold the amount of bytes to be read from the
+ // input.
+ BOOST_STATIC_ASSERT(sizeof(Attribute) < qi::detail::integer<bits>::size);
+
             qi::skip_over(first, last, skipper);
 
             typename attribute<Context, Iterator>::type attr_;

Modified: trunk/boost/spirit/home/support/detail/endian.hpp
==============================================================================
--- trunk/boost/spirit/home/support/detail/endian.hpp (original)
+++ trunk/boost/spirit/home/support/detail/endian.hpp 2011-10-08 20:42:35 EDT (Sat, 08 Oct 2011)
@@ -24,10 +24,6 @@
 #include <boost/endian/integers.hpp>
 #else
 #include <boost/spirit/home/support/detail/endian/endian.hpp>
-namespace boost { namespace endian
-{
- using namespace boost::spirit::endian;
-}}
 #endif
 
 #endif

Modified: trunk/boost/spirit/home/support/detail/endian/endian.hpp
==============================================================================
--- trunk/boost/spirit/home/support/detail/endian/endian.hpp (original)
+++ trunk/boost/spirit/home/support/detail/endian/endian.hpp 2011-10-08 20:42:35 EDT (Sat, 08 Oct 2011)
@@ -419,6 +419,12 @@
   } // namespace endian
 }} // namespace boost::spirit
 
+// import the namespace above into boost::endian
+namespace boost { namespace endian
+{
+ using namespace boost::spirit::endian;
+}}
+
 #if defined(__BORLANDC__) || defined( __CODEGEARC__)
 # pragma pack(pop)
 #endif

Modified: trunk/boost/spirit/home/support/detail/pow10.hpp
==============================================================================
--- trunk/boost/spirit/home/support/detail/pow10.hpp (original)
+++ trunk/boost/spirit/home/support/detail/pow10.hpp 2011-10-08 20:42:35 EDT (Sat, 08 Oct 2011)
@@ -44,7 +44,7 @@
         }
     };
 
-#if (DBL_MAX_EXP == 308) // for IEEE-754
+#if (DBL_MAX_10_EXP == 308) // for IEEE-754
     template <>
     struct pow10_helper<double>
     {
@@ -90,9 +90,9 @@
     };
 
     template <>
- struct pow10_helper<double>
+ struct pow10_helper<float>
     {
- inline float pow10<float>(unsigned dim)
+ inline float call(unsigned dim)
         {
             return pow10_helper<double>::call(dim);
         }


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