Boost logo

Boost Users :

Subject: [Boost-users] [boost::property_tree] info_parser_read assert in vs2010 when use UTF8
From: ÇÇ־ǿ (qiaozhiqiang_at_[hidden])
Date: 2011-03-04 02:36:08


When use UTF8, non ASCII char is > 127, but char is signed,

So if the value > 127, the char c is < 0,
(unsigned)(c + 1) is a big value, read_info() assert in vs2010 when use UTF8 in debug build.

std::isspace() call
extern "C" int __cdecl _chvalidator(
        int c,
        int mask
        )
{
        _ASSERTE((unsigned)(c + 1) <= 256);
        return _chvalidator_l(NULL, c, mask);
}

My patch is us my_isspace():
template<class Ch>
bool my_isspace(const Ch c)
{
     if(c >= 0 && c <= 127)
        {
                return isspace(c);
        }
    return false;
}
 

 boost_1_46_0\boost\property_tree\detail\info_parser_read.hpp

   // Advance pointer past whitespace
    template<class Ch>
    void skip_whitespace(const Ch *&text)
    {
        using namespace std;
        while (isspace(*text))
            ++text;
    }

    // Extract word (whitespace delimited) and advance pointer accordingly
    template<class Ch>
    std::basic_string<Ch> read_word(const Ch *&text)
    {
        using namespace std;
        skip_whitespace(text);
        const Ch *start = text;
        while (!isspace(*text) && *text != Ch(';') && *text != Ch('\0'))
            ++text;
        return expand_escapes(start, text);
    }


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net