Index: boost/token_functions.hpp =================================================================== --- boost/token_functions.hpp (revision 68230) +++ boost/token_functions.hpp (working copy) @@ -218,11 +218,12 @@ { #if !defined(BOOST_NO_CWCTYPE) if (sizeof(char_type) == 1) - return std::isspace(static_cast(c)) != 0; + return std::isspace(static_cast(c)) != 0; else return std::iswspace(static_cast(c)) != 0; #else - return static_cast< unsigned >(c) <= 255 && std::isspace(c) != 0; + return static_cast< unsigned >(c) <= 255 && + std::isspace(static_cast(c)) != 0; #endif } @@ -230,11 +231,12 @@ { #if !defined(BOOST_NO_CWCTYPE) if (sizeof(char_type) == 1) - return std::ispunct(static_cast(c)) != 0; + return std::ispunct(static_cast(c)) != 0; else return std::iswpunct(static_cast(c)) != 0; #else - return static_cast< unsigned >(c) <= 255 && std::ispunct(c) != 0; + return static_cast< unsigned >(c) <= 255 + && std::ispunct(static_cast(c)) != 0; #endif } }; Index: libs/tokenizer/test/tolerate_negative_char.cpp =================================================================== --- libs/tokenizer/test/tolerate_negative_char.cpp (revision 0) +++ libs/tokenizer/test/tolerate_negative_char.cpp (revision 0) @@ -0,0 +1,22 @@ +// (c) Copyright Kazutoshi Satoda 2010. + +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org/libs/tokenizer for documenation + +/// Test to tolerate negative chars in input +#include +#include + +int main() +{ + char const negative_char = -123; + char const* p = &negative_char; + std::string token; + boost::char_separator()(p, &negative_char + 1, token); + // This is a very specific test for MSVC which can detect invalid + // arguments for std::isXXX() (isspace(), ispunct(), ...) functions, + // as assertion failure. +} Index: libs/tokenizer/test/Jamfile.v2 =================================================================== --- libs/tokenizer/test/Jamfile.v2 (revision 68230) +++ libs/tokenizer/test/Jamfile.v2 (working copy) @@ -12,4 +12,5 @@ [ run simple_example_3.cpp ] [ run simple_example_4.cpp ] [ run simple_example_5.cpp ] + [ run tolerate_negative_char.cpp ] ;