boostorg / spirit

Boost.org spirit module
http://boost.org/libs/spirit
383 stars 159 forks source link

iso8859_1::isgraph doesn't work correctly #741

Open WitekT opened 1 year ago

WitekT commented 1 year ago

I parse such string: "¶" (0xb6 character) with such parser:

boost::spirit::qi::rule< std::string::const_iterator > validCharRule
    = +( boost::spirit::qi::iso8859_1::graph );

std::string test = "\xb6";
auto it = test.cbegin();
auto end = test.cend();

if ( !boost::spirit::qi::parse( it, end, validCharRule ) || it != end )
    std::cout << "error: " << std::string( it, end ) << std::endl;
else
    std::cout << "ok" << std::endl;

The problem is here, but may be also cause by cast_char from BOOST_SPIRIT_CLASSIFY:

isgraph(int ch)
        {
            return ('\x21' <= ch && ch <= '\x7e') || ('\xa1' <= ch && ch <= '\xff');
        }

ch is equal to 182 and it is compared eg. with -95 ('\xa1') -1 ('\xff').