2
0
mirror of https://github.com/boostorg/spirit.git synced 2026-01-19 04:42:11 +00:00

Fixes Trac #10755 "Wrong overflow checking with uint_parser<uint8_t,

10, 1, 3>"
This commit is contained in:
Joel de Guzman
2014-11-06 08:37:54 +08:00
parent 2b69f77c3a
commit c0d6ed357b
3 changed files with 13 additions and 2 deletions

2
.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
.DS_Store

View File

@@ -2,7 +2,7 @@
Copyright (c) 2001-2011 Joel de Guzman
Copyright (c) 2001-2011 Hartmut Kaiser
Copyright (c) 2011 Jan Frederick Eick
Copyright (c) 2011 Christopher Jefferson
Copyright (c) 2011 Christopher Jefferson
Copyright (c) 2006 Stephen Nutt
Distributed under the Boost Software License, Version 1.0. (See accompanying
@@ -272,8 +272,10 @@ namespace boost { namespace spirit { namespace qi { namespace detail
|| it == last) \
break; \
ch = *it; \
if (!radix_check::is_valid(ch) || !extractor::call(ch, count, val)) \
if (!radix_check::is_valid(ch)) \
break; \
if (!extractor::call(ch, count, val)) \
return false; \
++it; \
++count; \
/**/

View File

@@ -125,6 +125,13 @@ main()
BOOST_TEST(!test("1", uint4));
BOOST_TEST(!test_attr("1", uint4, u));
BOOST_TEST(test_attr("014567", uint4, u, false) && u == 145);
uint_parser<uint8_t, 10, 1, 3> uchar_3;
unsigned char uc;
BOOST_TEST(test_attr("255", uchar_3, uc, true));
BOOST_TEST(uc == 255);
BOOST_TEST(!test_attr("256", uchar_3, uc, false));
BOOST_TEST(!test_attr("257", uchar_3, uc, false));
}
///////////////////////////////////////////////////////////////////////////