From b1b53059847d8c5eb891e65387c4b0c044fdc58f Mon Sep 17 00:00:00 2001 From: Antony Polukhin Date: Thu, 26 Apr 2012 17:59:17 +0000 Subject: [PATCH] Merge from trunk: * fixed #6812 (now converting "." to float type throws bad_lexical_cast) [SVN r78211] --- include/boost/lexical_cast.hpp | 3 ++- test/lexical_cast_float_types_test.cpp | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/include/boost/lexical_cast.hpp b/include/boost/lexical_cast.hpp index 2e5c140..fb76d29 100644 --- a/include/boost/lexical_cast.hpp +++ b/include/boost/lexical_cast.hpp @@ -1062,9 +1062,10 @@ namespace boost { ) return false; #endif - if(*begin == decimal_point){ + if(*begin == decimal_point) { ++ begin; found_decimal = true; + if (!found_number_before_exp && begin==end) return false; continue; }else { if (!found_number_before_exp) return false; diff --git a/test/lexical_cast_float_types_test.cpp b/test/lexical_cast_float_types_test.cpp index 808f456..60db0e1 100755 --- a/test/lexical_cast_float_types_test.cpp +++ b/test/lexical_cast_float_types_test.cpp @@ -261,6 +261,7 @@ void test_converion_to_float_types() BOOST_CHECK_THROW(lexical_cast(".e"), bad_lexical_cast); BOOST_CHECK_THROW(lexical_cast(".11111111111111111111111111111111111111111111111111111111111111111111ee"), bad_lexical_cast); BOOST_CHECK_THROW(lexical_cast(".11111111111111111111111111111111111111111111111111111111111111111111e-"), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast("."), bad_lexical_cast); BOOST_CHECK_THROW(lexical_cast("-B"), bad_lexical_cast); BOOST_CHECK_THROW(lexical_cast("0xB"), bad_lexical_cast); @@ -276,6 +277,7 @@ void test_converion_to_float_types() BOOST_CHECK_THROW(lexical_cast("-"), bad_lexical_cast); BOOST_CHECK_THROW(lexical_cast('\0'), bad_lexical_cast); BOOST_CHECK_THROW(lexical_cast('-'), bad_lexical_cast); + BOOST_CHECK_THROW(lexical_cast('.'), bad_lexical_cast); } template