boost::regex locale problem

Hi, I'm having a lot of trouble with boost::regexp and locales, even trying to change it makes the program fail. Can anybody help? #include <iostream> #include <string> #include <cstdlib> #include <cassert> #include <vector> #include <stdexcept> #include <locale> #include <boost/regex.hpp> using namespace std; using namespace boost; int main(int argc, char *argv[]) { string regexp, text; if( argc != 3 ) { exit(EXIT_FAILURE); } else { regexp = argv[1]; text = argv[2]; } cout << "regexp: " << regexp << endl; cout << "text: " << text << endl; regex re(regexp,regex_constants::perl); re.imbue(locale("es_ES.UTF-8")); smatch match; if(regex_match(text, match, re)) { cout << "MATCH" << endl; for(smatch::const_iterator i = match.begin(); i != match.end(); ++i) { cout << i->str() << endl; } } else { cout << "NO match" << endl; } } ./testre '\w' "é" Program terminated with signal 8, Arithmetic exception. #0 0xb7ea0883 in boost::re_detail::perl_matcher<__gnu_cxx::__normal_iterator<char const*, std::string>, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::string> > >, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::construct_init () from /usr/lib/libboost_regex-gcc-mt-1_33_1.so.1.33.1 (gdb) bt #0 0xb7ea0883 in boost::re_detail::perl_matcher<__gnu_cxx::__normal_iterator<char const*, std::string>, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::string> > >, boost::regex_traits<char, boost::cpp_regex_traits<char> > >::construct_init () from /usr/lib/libboost_regex-gcc-mt-1_33_1.so.1.33.1 #1 0x08049ea9 in perl_matcher (this=0xbf806c24, first={_M_current = 0x804c02c "é"}, end= {_M_current = 0x804c02d ""}, what=@0xbf806d20, e=@0xbf806d3c, f=boost::regex_constants::match_default, b={_M_current = 0x804c02c "é"}) at /usr/include/boost/regex/v4/perl_matcher_common.hpp:44 #2 0x08049f27 in boost::regex_match<__gnu_cxx::__normal_iterator<char const*, std::string>, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::string> > >, char, boost::regex_traits<char, boost::cpp_regex_traits<char> > > (first= {_M_current = 0x804c02c "é"}, last={_M_current = 0x804c02d ""}, m=@0xbf806d20, e=@0xbf806d3c, flags=boost::regex_constants::match_default) at /usr/include/boost/regex/v4/regex_match.hpp:42 #3 0x08049fd3 in boost::regex_match<std::char_traits<char>, std::allocator<char>, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*, std::string> > >, char, boost::regex_traits<char, boost::cpp_regex_traits<char> > > (s=@0xbf806d44, m=@0xbf806d20, e=@0xbf806d3c, flags=boost::regex_constants::match_default) at /usr/include/boost/regex/v4/regex_match.hpp:75 #4 0x0804926b in main (argc=3, argv=0xbf806df4) at testre.cpp:25 -- Pedro Larroy Tovar, pedro at larroy dot com | http://pedro.larroy.com/ * Las patentes de programación son nocivas para la innovación * http://proinnova.hispalinux.es/
participants (2)
-
boost@larroy.com
-
John Maddock