Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r77039 - trunk/boost
From: antoshkka_at_[hidden]
Date: 2012-02-16 12:56:29


Author: apolukhin
Date: 2012-02-16 12:56:27 EST (Thu, 16 Feb 2012)
New Revision: 77039
URL: http://svn.boost.org/trac/boost/changeset/77039

Log:
FIx #5689 (issue from 5th comment)
Text files modified:
   trunk/boost/lexical_cast.hpp | 15 ++++++++++++---
   1 files changed, 12 insertions(+), 3 deletions(-)

Modified: trunk/boost/lexical_cast.hpp
==============================================================================
--- trunk/boost/lexical_cast.hpp (original)
+++ trunk/boost/lexical_cast.hpp 2012-02-16 12:56:27 EST (Thu, 16 Feb 2012)
@@ -732,6 +732,15 @@
 
     namespace detail
     {
+ template <class CharT>
+ bool lc_iequal(const CharT* val, const CharT* lcase, const CharT* ucase, unsigned int len) {
+ for( unsigned int i=0; i < len; ++i ) {
+ if ( val[i] != lcase[i] && val[i] != ucase[i] ) return false;
+ }
+
+ return true;
+ }
+
         /* Returns true and sets the correct value if found NaN or Inf. */
         template <class CharT, class T>
         inline bool parse_inf_nan_impl(const CharT* begin, const CharT* end, T& value
@@ -755,7 +764,7 @@
             else if( *begin == plus ) ++begin;
 
             if( end-begin < 3 ) return false;
- if( !memcmp(begin, lc_nan, 3*sizeof(CharT)) || !memcmp(begin, lc_NAN, 3*sizeof(CharT)) )
+ if( lc_iequal(begin, lc_nan, lc_NAN, 3) )
             {
                 begin += 3;
                 if (end != begin) /* It is 'nan(...)' or some bad input*/
@@ -772,13 +781,13 @@
             if (( /* 'INF' or 'inf' */
                   end-begin==3
                   &&
- (!memcmp(begin, lc_infinity, 3*sizeof(CharT)) || !memcmp(begin, lc_INFINITY, 3*sizeof(CharT)))
+ lc_iequal(begin, lc_infinity, lc_INFINITY, 3)
                 )
                 ||
                 ( /* 'INFINITY' or 'infinity' */
                   end-begin==inifinity_size
                   &&
- (!memcmp(begin, lc_infinity, inifinity_size)|| !memcmp(begin, lc_INFINITY, inifinity_size))
+ lc_iequal(begin, lc_infinity, lc_INFINITY, inifinity_size)
                 )
              )
             {


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