mirror of
https://github.com/boostorg/regex.git
synced 2025-07-17 06:12:10 +02:00
Refined building without /Zc:wchar_t on msvc 7 and above
[SVN r21147]
This commit is contained in:
@ -182,28 +182,28 @@ std::size_t BOOST_REGEX_CALL _re_get_message(char* buf, std::size_t len, std::si
|
||||
|
||||
#ifndef BOOST_NO_WREGEX
|
||||
|
||||
BOOST_REGEX_DECL wchar_t re_zero_w;
|
||||
BOOST_REGEX_DECL wchar_t re_ten_w;
|
||||
BOOST_REGEX_DECL boost::regex_wchar_type re_zero_w;
|
||||
BOOST_REGEX_DECL boost::regex_wchar_type re_ten_w;
|
||||
|
||||
unsigned int nlsw_count = 0;
|
||||
std::string* wlocale_name = 0;
|
||||
|
||||
struct syntax_map_t
|
||||
{
|
||||
wchar_t c;
|
||||
boost::regex_wchar_type c;
|
||||
unsigned int type;
|
||||
};
|
||||
|
||||
std::list<syntax_map_t>* syntax;
|
||||
|
||||
std::size_t BOOST_REGEX_CALL re_get_message(wchar_t* buf, std::size_t len, std::size_t id)
|
||||
std::size_t BOOST_REGEX_CALL re_get_message(boost::regex_wchar_type* buf, std::size_t len, std::size_t id)
|
||||
{
|
||||
std::size_t size = _re_get_message(static_cast<char*>(0), 0, id);
|
||||
if(len < size)
|
||||
return size;
|
||||
boost::scoped_array<char> cb(new char[size]);
|
||||
_re_get_message(cb.get(), size, id);
|
||||
size = boost::c_regex_traits<wchar_t>::strwiden(buf, len, cb.get());
|
||||
size = boost::c_regex_traits<boost::regex_wchar_type>::strwiden(buf, len, cb.get());
|
||||
return size;
|
||||
}
|
||||
#endif
|
||||
@ -584,10 +584,10 @@ char c_traits_base::lower_case_map[map_size];
|
||||
} // namespace re_detail
|
||||
|
||||
#ifndef BOOST_NO_WREGEX
|
||||
bool BOOST_REGEX_CALL c_regex_traits<wchar_t>::lookup_collatename(std::basic_string<wchar_t>& out, const wchar_t* first, const wchar_t* last)
|
||||
bool BOOST_REGEX_CALL c_regex_traits<regex_wchar_type>::lookup_collatename(std::basic_string<regex_wchar_type>& out, const regex_wchar_type* first, const regex_wchar_type* last)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
std::basic_string<wchar_t> s(first, last);
|
||||
std::basic_string<regex_wchar_type> s(first, last);
|
||||
std::size_t len = strnarrow(static_cast<char*>(0), 0, s.c_str());
|
||||
scoped_array<char> buf(new char[len]);
|
||||
strnarrow(buf.get(), len, s.c_str());
|
||||
@ -598,13 +598,13 @@ bool BOOST_REGEX_CALL c_regex_traits<wchar_t>::lookup_collatename(std::basic_str
|
||||
{
|
||||
if(t_out[0])
|
||||
{
|
||||
len = strwiden(static_cast<wchar_t*>(0), 0, t_out.c_str());
|
||||
scoped_array<wchar_t> wb(new wchar_t[len]);
|
||||
len = strwiden(static_cast<regex_wchar_type*>(0), 0, t_out.c_str());
|
||||
scoped_array<regex_wchar_type> wb(new regex_wchar_type[len]);
|
||||
strwiden(wb.get(), len, t_out.c_str());
|
||||
out = wb.get();
|
||||
}
|
||||
else
|
||||
out.append(1, (wchar_t)0);
|
||||
out.append(1, (regex_wchar_type)0);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -773,7 +773,7 @@ int BOOST_REGEX_CALL c_regex_traits<char>::toi(const char*& first, const char* l
|
||||
|
||||
#ifndef BOOST_NO_WREGEX
|
||||
|
||||
unsigned int BOOST_REGEX_CALL c_regex_traits<wchar_t>::syntax_type(size_type c)
|
||||
unsigned int BOOST_REGEX_CALL c_regex_traits<regex_wchar_type>::syntax_type(size_type c)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
std::list<syntax_map_t>::const_iterator first, last;
|
||||
@ -788,7 +788,7 @@ unsigned int BOOST_REGEX_CALL c_regex_traits<wchar_t>::syntax_type(size_type c)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void BOOST_REGEX_CALL c_regex_traits<wchar_t>::init()
|
||||
void BOOST_REGEX_CALL c_regex_traits<regex_wchar_type>::init()
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
re_detail::re_init_threads();
|
||||
@ -818,10 +818,10 @@ void BOOST_REGEX_CALL c_regex_traits<wchar_t>::init()
|
||||
++nlsw_count;
|
||||
}
|
||||
|
||||
bool BOOST_REGEX_CALL c_regex_traits<wchar_t>::do_lookup_collate(std::basic_string<wchar_t>& out, const wchar_t* first, const wchar_t* last)
|
||||
bool BOOST_REGEX_CALL c_regex_traits<regex_wchar_type>::do_lookup_collate(std::basic_string<regex_wchar_type>& out, const regex_wchar_type* first, const regex_wchar_type* last)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
std::basic_string<wchar_t> s(first, last);
|
||||
std::basic_string<regex_wchar_type> s(first, last);
|
||||
std::size_t len = strnarrow(static_cast<char*>(0), 0, s.c_str());
|
||||
scoped_array<char> buf(new char[len]);
|
||||
strnarrow(buf.get(), len, s.c_str());
|
||||
@ -829,8 +829,8 @@ bool BOOST_REGEX_CALL c_regex_traits<wchar_t>::do_lookup_collate(std::basic_stri
|
||||
bool result = base_type::do_lookup_collate(t_out, buf.get());
|
||||
if(result)
|
||||
{
|
||||
len = strwiden(static_cast<wchar_t*>(0), 0, t_out.c_str());
|
||||
scoped_array<wchar_t> wb(new wchar_t[len]);
|
||||
len = strwiden(static_cast<regex_wchar_type*>(0), 0, t_out.c_str());
|
||||
scoped_array<regex_wchar_type> wb(new regex_wchar_type[len]);
|
||||
strwiden(wb.get(), len, t_out.c_str());
|
||||
out = wb.get();
|
||||
}
|
||||
@ -838,7 +838,7 @@ bool BOOST_REGEX_CALL c_regex_traits<wchar_t>::do_lookup_collate(std::basic_stri
|
||||
}
|
||||
|
||||
|
||||
void BOOST_REGEX_CALL c_regex_traits<wchar_t>::update()
|
||||
void BOOST_REGEX_CALL c_regex_traits<regex_wchar_type>::update()
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
#ifdef BOOST_HAS_THREADS
|
||||
@ -851,8 +851,8 @@ void BOOST_REGEX_CALL c_regex_traits<wchar_t>::update()
|
||||
if(*wlocale_name != l)
|
||||
{
|
||||
*wlocale_name = l;
|
||||
std::basic_string<wchar_t> s;
|
||||
const wchar_t* p = L"zero";
|
||||
std::basic_string<regex_wchar_type> s;
|
||||
const regex_wchar_type* p = (const regex_wchar_type*)L"zero";
|
||||
if(do_lookup_collate(s, p, p+4))
|
||||
{
|
||||
jm_assert(s.size() == 1);
|
||||
@ -861,7 +861,7 @@ void BOOST_REGEX_CALL c_regex_traits<wchar_t>::update()
|
||||
else
|
||||
re_zero_w = L'0';
|
||||
|
||||
p = L"ten";
|
||||
p = (const regex_wchar_type*)L"ten";
|
||||
if(do_lookup_collate(s, p, p+3))
|
||||
{
|
||||
jm_assert(s.size() == 1);
|
||||
@ -871,13 +871,13 @@ void BOOST_REGEX_CALL c_regex_traits<wchar_t>::update()
|
||||
re_ten_w = L'a';
|
||||
|
||||
unsigned int i;
|
||||
wchar_t buf[256];
|
||||
regex_wchar_type buf[256];
|
||||
syntax_map_t sm;
|
||||
syntax->clear();
|
||||
for(i = 1; i < syntax_max; ++i)
|
||||
{
|
||||
wchar_t* ptr = buf;
|
||||
re_get_message(static_cast<wchar_t*>(buf), 256, i+100);
|
||||
regex_wchar_type* ptr = buf;
|
||||
re_get_message(static_cast<regex_wchar_type*>(buf), 256, i+100);
|
||||
for(; *ptr; ++ptr)
|
||||
{
|
||||
sm.c = *ptr;
|
||||
@ -889,7 +889,7 @@ void BOOST_REGEX_CALL c_regex_traits<wchar_t>::update()
|
||||
}
|
||||
}
|
||||
|
||||
void BOOST_REGEX_CALL c_regex_traits<wchar_t>::m_free()
|
||||
void BOOST_REGEX_CALL c_regex_traits<regex_wchar_type>::m_free()
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
#ifdef BOOST_HAS_THREADS
|
||||
@ -901,7 +901,7 @@ void BOOST_REGEX_CALL c_regex_traits<wchar_t>::m_free()
|
||||
re_free_collate();
|
||||
// add reference to static member here to ensure
|
||||
// that the linker includes it in the .exe:
|
||||
if((nlsw_count == 0) && (0 != &c_regex_traits<wchar_t>::init_))
|
||||
if((nlsw_count == 0) && (0 != &c_regex_traits<regex_wchar_type>::init_))
|
||||
{
|
||||
// cleanup:
|
||||
delete wlocale_name;
|
||||
@ -913,7 +913,7 @@ void BOOST_REGEX_CALL c_regex_traits<wchar_t>::m_free()
|
||||
#endif
|
||||
}
|
||||
|
||||
bool BOOST_REGEX_CALL c_regex_traits<wchar_t>::do_iswclass(wchar_t c, boost::uint_fast32_t f)
|
||||
bool BOOST_REGEX_CALL c_regex_traits<regex_wchar_type>::do_iswclass(regex_wchar_type c, boost::uint_fast32_t f)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
if((c & ~0xFF) == 0)
|
||||
@ -939,7 +939,7 @@ bool BOOST_REGEX_CALL c_regex_traits<wchar_t>::do_iswclass(wchar_t c, boost::uin
|
||||
return false;
|
||||
}
|
||||
|
||||
void BOOST_REGEX_CALL c_regex_traits<wchar_t>::transform(std::basic_string<wchar_t>& out, const std::basic_string<wchar_t>& in)
|
||||
void BOOST_REGEX_CALL c_regex_traits<regex_wchar_type>::transform(std::basic_string<regex_wchar_type>& out, const std::basic_string<regex_wchar_type>& in)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
#ifndef BOOST_MSVC
|
||||
@ -954,8 +954,8 @@ void BOOST_REGEX_CALL c_regex_traits<wchar_t>::transform(std::basic_string<wchar
|
||||
out = in;
|
||||
return;
|
||||
}
|
||||
scoped_array<wchar_t> buf(new wchar_t[n+1]);
|
||||
n = std::wcsxfrm(buf.get(), in.c_str(), n+1);
|
||||
scoped_array<regex_wchar_type> buf(new regex_wchar_type[n+1]);
|
||||
n = std::wcsxfrm((wchar_t*)buf.get(), (const wchar_t*)in.c_str(), n+1);
|
||||
if(n == (std::size_t)(-1))
|
||||
{
|
||||
out = in;
|
||||
@ -964,7 +964,7 @@ void BOOST_REGEX_CALL c_regex_traits<wchar_t>::transform(std::basic_string<wchar
|
||||
out = buf.get();
|
||||
}
|
||||
|
||||
void BOOST_REGEX_CALL c_regex_traits<wchar_t>::transform_primary(std::basic_string<wchar_t>& out, const std::basic_string<wchar_t>& in)
|
||||
void BOOST_REGEX_CALL c_regex_traits<regex_wchar_type>::transform_primary(std::basic_string<regex_wchar_type>& out, const std::basic_string<regex_wchar_type>& in)
|
||||
{
|
||||
transform(out, in);
|
||||
switch(sort_type)
|
||||
@ -988,11 +988,11 @@ void BOOST_REGEX_CALL c_regex_traits<wchar_t>::transform_primary(std::basic_stri
|
||||
}
|
||||
}
|
||||
|
||||
unsigned c_regex_traits<wchar_t>::sort_type;
|
||||
wchar_t c_regex_traits<wchar_t>::sort_delim;
|
||||
unsigned c_regex_traits<regex_wchar_type>::sort_type;
|
||||
regex_wchar_type c_regex_traits<regex_wchar_type>::sort_delim;
|
||||
|
||||
|
||||
int BOOST_REGEX_CALL c_regex_traits<wchar_t>::toi(wchar_t c)
|
||||
int BOOST_REGEX_CALL c_regex_traits<regex_wchar_type>::toi(regex_wchar_type c)
|
||||
{
|
||||
if(is_class(c, char_class_digit))
|
||||
return c - re_zero_w;
|
||||
@ -1001,7 +1001,7 @@ int BOOST_REGEX_CALL c_regex_traits<wchar_t>::toi(wchar_t c)
|
||||
return -1; // error!!
|
||||
}
|
||||
|
||||
int BOOST_REGEX_CALL c_regex_traits<wchar_t>::toi(const wchar_t*& first, const wchar_t* last, int radix)
|
||||
int BOOST_REGEX_CALL c_regex_traits<regex_wchar_type>::toi(const regex_wchar_type*& first, const regex_wchar_type* last, int radix)
|
||||
{
|
||||
unsigned int maxval;
|
||||
if(radix < 0)
|
||||
@ -1031,9 +1031,9 @@ int BOOST_REGEX_CALL c_regex_traits<wchar_t>::toi(const wchar_t*& first, const w
|
||||
return result;
|
||||
}
|
||||
|
||||
boost::uint_fast32_t BOOST_REGEX_CALL c_regex_traits<wchar_t>::lookup_classname(const wchar_t* first, const wchar_t* last)
|
||||
boost::uint_fast32_t BOOST_REGEX_CALL c_regex_traits<regex_wchar_type>::lookup_classname(const regex_wchar_type* first, const regex_wchar_type* last)
|
||||
{
|
||||
std::basic_string<wchar_t> s(first, last);
|
||||
std::basic_string<regex_wchar_type> s(first, last);
|
||||
std::size_t len = strnarrow(static_cast<char*>(0), 0, s.c_str());
|
||||
scoped_array<char> buf(new char[len]);
|
||||
strnarrow(buf.get(), len, s.c_str());
|
||||
@ -1041,24 +1041,24 @@ boost::uint_fast32_t BOOST_REGEX_CALL c_regex_traits<wchar_t>::lookup_classname(
|
||||
return result;
|
||||
}
|
||||
|
||||
c_regex_traits<wchar_t> c_regex_traits<wchar_t>::init_;
|
||||
c_regex_traits<regex_wchar_type> c_regex_traits<regex_wchar_type>::init_;
|
||||
|
||||
std::size_t BOOST_REGEX_CALL c_regex_traits<wchar_t>::strnarrow(char *s1, std::size_t len, const wchar_t *s2)
|
||||
std::size_t BOOST_REGEX_CALL c_regex_traits<regex_wchar_type>::strnarrow(char *s1, std::size_t len, const regex_wchar_type *s2)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
std::size_t size = std::wcslen(s2) + 1;
|
||||
std::size_t size = std::wcslen((const wchar_t*)s2) + 1;
|
||||
if(size > len)
|
||||
return size;
|
||||
return std::wcstombs(s1, s2, len);
|
||||
return std::wcstombs(s1, (const wchar_t*)s2, len);
|
||||
}
|
||||
|
||||
std::size_t BOOST_REGEX_CALL c_regex_traits<wchar_t>::strwiden(wchar_t *s1, std::size_t len, const char *s2)
|
||||
std::size_t BOOST_REGEX_CALL c_regex_traits<regex_wchar_type>::strwiden(regex_wchar_type *s1, std::size_t len, const char *s2)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
std::size_t size = std::strlen(s2) + 1;
|
||||
if(size > len)
|
||||
return size;
|
||||
size = std::mbstowcs(s1, s2, len);
|
||||
size = std::mbstowcs((wchar_t*)s1, s2, len);
|
||||
s1[size] = 0;
|
||||
return size + 1;
|
||||
}
|
||||
|
@ -221,7 +221,7 @@ BOOST_REGEX_DECL std::size_t BOOST_REGEX_CALL re_get_default_message(char* buf,
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_WREGEX
|
||||
const wchar_t combining_ranges[] = { 0x0300, 0x0361,
|
||||
const regex_wchar_type combining_ranges[] = { 0x0300, 0x0361,
|
||||
0x0483, 0x0486,
|
||||
0x0903, 0x0903,
|
||||
0x093E, 0x0940,
|
||||
@ -260,10 +260,10 @@ const wchar_t combining_ranges[] = { 0x0300, 0x0361,
|
||||
0xFE20, 0xFE23,
|
||||
0xffff, 0xffff, };
|
||||
|
||||
BOOST_REGEX_DECL bool BOOST_REGEX_CALL is_combining(wchar_t c)
|
||||
BOOST_REGEX_DECL bool BOOST_REGEX_CALL is_combining(regex_wchar_type c)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
const wchar_t* p = combining_ranges + 1;
|
||||
const regex_wchar_type* p = combining_ranges + 1;
|
||||
while(*p < c) p += 2;
|
||||
--p;
|
||||
if((c >= *p) && (c <= *(p+1)))
|
||||
@ -531,7 +531,7 @@ BOOST_REGEX_DECL unsigned short wide_unicode_classes[] = {
|
||||
c_traits_base::char_class_alpha | c_traits_base::char_class_lower, // '<27>' 255
|
||||
};
|
||||
|
||||
BOOST_REGEX_DECL wchar_t wide_lower_case_map[] = {
|
||||
BOOST_REGEX_DECL regex_wchar_type wide_lower_case_map[] = {
|
||||
0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf,
|
||||
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
|
||||
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
|
||||
|
@ -21,6 +21,11 @@
|
||||
|
||||
#include <boost/regex/config.hpp>
|
||||
|
||||
#if defined(BOOST_MSVC) && (BOOST_MSVC >= 1300) && !defined(_NATIVE_WCHAR_T_DEFINED)
|
||||
# pragma message ("disabling support for class cpp_regex_traits<wchar_t> - rebuild with /Zc:wchar_t if you really need this")
|
||||
# define BOOST_NO_WREGEX
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_NO_STD_LOCALE)
|
||||
|
||||
# ifdef BOOST_MSVC
|
||||
|
@ -147,14 +147,14 @@ enum syntax_map_size
|
||||
|
||||
#ifndef BOOST_NO_WREGEX
|
||||
|
||||
BOOST_REGEX_DECL wchar_t re_zero_w;
|
||||
BOOST_REGEX_DECL wchar_t re_ten_w;
|
||||
BOOST_REGEX_DECL boost::regex_wchar_type re_zero_w;
|
||||
BOOST_REGEX_DECL boost::regex_wchar_type re_ten_w;
|
||||
|
||||
bool isPlatformNT = false;
|
||||
|
||||
struct syntax_map_t
|
||||
{
|
||||
wchar_t c;
|
||||
boost::regex_wchar_type c;
|
||||
unsigned int type;
|
||||
};
|
||||
|
||||
@ -164,14 +164,14 @@ std::list<syntax_map_t>* syntax;
|
||||
|
||||
std::size_t BOOST_REGEX_CALL _re_get_message(char* buf, std::size_t len, unsigned id);
|
||||
|
||||
std::size_t BOOST_REGEX_CALL get_message(wchar_t* buf, std::size_t len, unsigned id)
|
||||
std::size_t BOOST_REGEX_CALL get_message(boost::regex_wchar_type* buf, std::size_t len, unsigned id)
|
||||
{
|
||||
std::size_t size = _re_get_message(static_cast<char*>(0), 0, id);
|
||||
if(len < size)
|
||||
return size;
|
||||
boost::scoped_array<char> cb(new char[size]);
|
||||
_re_get_message(cb.get(), size, id);
|
||||
size = boost::w32_regex_traits<wchar_t>::strwiden(buf, len, cb.get());
|
||||
size = boost::w32_regex_traits<boost::regex_wchar_type>::strwiden(buf, len, cb.get());
|
||||
return size;
|
||||
}
|
||||
|
||||
@ -338,18 +338,18 @@ void BOOST_REGEX_CALL w32_traits_base::do_init()
|
||||
#ifndef BOOST_NO_WREGEX
|
||||
//
|
||||
// wide string data:
|
||||
std::basic_string<wchar_t> ws;
|
||||
const wchar_t* wp = L"zero";
|
||||
if(w32_regex_traits<wchar_t>::lookup_collatename(ws, wp, wp+4))
|
||||
std::basic_string<regex_wchar_type> ws;
|
||||
const regex_wchar_type* wp = (const regex_wchar_type*)L"zero";
|
||||
if(w32_regex_traits<regex_wchar_type>::lookup_collatename(ws, wp, wp+4))
|
||||
{
|
||||
jm_assert(ws.size() == 1);
|
||||
re_zero_w = *ws.c_str();
|
||||
}
|
||||
else
|
||||
re_zero_w = L'0';
|
||||
re_zero_w = (regex_wchar_type)L'0';
|
||||
|
||||
wp = L"ten";
|
||||
if(w32_regex_traits<wchar_t>::lookup_collatename(ws, wp, wp+3))
|
||||
wp = (const regex_wchar_type*)L"ten";
|
||||
if(w32_regex_traits<regex_wchar_type>::lookup_collatename(ws, wp, wp+3))
|
||||
{
|
||||
jm_assert(ws.size() == 1);
|
||||
re_ten_w = *ws.c_str();
|
||||
@ -357,12 +357,12 @@ void BOOST_REGEX_CALL w32_traits_base::do_init()
|
||||
else
|
||||
re_ten_w = L'a';
|
||||
|
||||
wchar_t wbuf[256];
|
||||
regex_wchar_type wbuf[256];
|
||||
syntax_map_t sm;
|
||||
syntax->clear();
|
||||
for(i = 1; i < syntax_max; ++i)
|
||||
{
|
||||
wchar_t* ptr = wbuf;
|
||||
regex_wchar_type* ptr = wbuf;
|
||||
get_message(wbuf, 256, i+100);
|
||||
for(; *ptr; ++ptr)
|
||||
{
|
||||
@ -583,10 +583,10 @@ int BOOST_REGEX_CALL w32_regex_traits<char>::toi(const char*& first, const char*
|
||||
|
||||
#ifndef BOOST_NO_WREGEX
|
||||
|
||||
bool BOOST_REGEX_CALL w32_regex_traits<wchar_t>::lookup_collatename(std::basic_string<wchar_t>& out, const wchar_t* first, const wchar_t* last)
|
||||
bool BOOST_REGEX_CALL w32_regex_traits<regex_wchar_type>::lookup_collatename(std::basic_string<regex_wchar_type>& out, const regex_wchar_type* first, const regex_wchar_type* last)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
std::basic_string<wchar_t> s(first, last);
|
||||
std::basic_string<regex_wchar_type> s(first, last);
|
||||
std::size_t len = strnarrow(static_cast<char*>(0), 0, s.c_str());
|
||||
scoped_array<char> buf(new char[len]);
|
||||
strnarrow(buf.get(), len, s.c_str());
|
||||
@ -597,18 +597,18 @@ bool BOOST_REGEX_CALL w32_regex_traits<wchar_t>::lookup_collatename(std::basic_s
|
||||
{
|
||||
if(t_out[0])
|
||||
{
|
||||
len = strwiden(static_cast<wchar_t*>(0), 0, t_out.c_str());
|
||||
scoped_array<wchar_t> wb(new wchar_t[len]);
|
||||
len = strwiden(static_cast<regex_wchar_type*>(0), 0, t_out.c_str());
|
||||
scoped_array<regex_wchar_type> wb(new regex_wchar_type[len]);
|
||||
strwiden(wb.get(), len, t_out.c_str());
|
||||
out = wb.get();
|
||||
}
|
||||
else
|
||||
out.append(1,(wchar_t)0);
|
||||
out.append(1,(regex_wchar_type)0);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
unsigned int BOOST_REGEX_CALL w32_regex_traits<wchar_t>::syntax_type(size_type c)
|
||||
unsigned int BOOST_REGEX_CALL w32_regex_traits<regex_wchar_type>::syntax_type(size_type c)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
std::list<syntax_map_t>::const_iterator first, last;
|
||||
@ -623,10 +623,10 @@ unsigned int BOOST_REGEX_CALL w32_regex_traits<wchar_t>::syntax_type(size_type c
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool BOOST_REGEX_CALL w32_regex_traits<wchar_t>::do_lookup_collate(std::basic_string<wchar_t>& out, const wchar_t* first, const wchar_t* last)
|
||||
bool BOOST_REGEX_CALL w32_regex_traits<regex_wchar_type>::do_lookup_collate(std::basic_string<regex_wchar_type>& out, const regex_wchar_type* first, const regex_wchar_type* last)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
std::basic_string<wchar_t> s(first, last);
|
||||
std::basic_string<regex_wchar_type> s(first, last);
|
||||
std::size_t len = strnarrow(static_cast<char*>(0), 0, s.c_str());
|
||||
scoped_array<char> buf(new char[len]);
|
||||
strnarrow(buf.get(), len, s.c_str());
|
||||
@ -634,8 +634,8 @@ bool BOOST_REGEX_CALL w32_regex_traits<wchar_t>::do_lookup_collate(std::basic_st
|
||||
bool result = base_type::do_lookup_collate(t_out, buf.get());
|
||||
if(result)
|
||||
{
|
||||
len = strwiden(static_cast<wchar_t*>(0), 0, t_out.c_str());
|
||||
scoped_array<wchar_t> wb(new wchar_t[len]);
|
||||
len = strwiden(static_cast<regex_wchar_type*>(0), 0, t_out.c_str());
|
||||
scoped_array<regex_wchar_type> wb(new regex_wchar_type[len]);
|
||||
strwiden(wb.get(), len, t_out.c_str());
|
||||
out = wb.get();
|
||||
}
|
||||
@ -643,7 +643,7 @@ bool BOOST_REGEX_CALL w32_regex_traits<wchar_t>::do_lookup_collate(std::basic_st
|
||||
}
|
||||
|
||||
|
||||
void BOOST_REGEX_CALL w32_regex_traits<wchar_t>::update()
|
||||
void BOOST_REGEX_CALL w32_regex_traits<regex_wchar_type>::update()
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
#ifdef BOOST_HAS_THREADS
|
||||
@ -652,7 +652,7 @@ void BOOST_REGEX_CALL w32_regex_traits<wchar_t>::update()
|
||||
do_init();
|
||||
}
|
||||
|
||||
w32_regex_traits<wchar_t>::w32_regex_traits()
|
||||
w32_regex_traits<regex_wchar_type>::w32_regex_traits()
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
#ifdef BOOST_HAS_THREADS
|
||||
@ -662,7 +662,7 @@ w32_regex_traits<wchar_t>::w32_regex_traits()
|
||||
++entry_count;
|
||||
}
|
||||
|
||||
w32_regex_traits<wchar_t>::~w32_regex_traits()
|
||||
w32_regex_traits<regex_wchar_type>::~w32_regex_traits()
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
#ifdef BOOST_HAS_THREADS
|
||||
@ -670,7 +670,7 @@ w32_regex_traits<wchar_t>::~w32_regex_traits()
|
||||
#endif
|
||||
// add reference to static member here to ensure
|
||||
// that the linker includes it in the .exe:
|
||||
if((--entry_count == 0) && (0 != &w32_regex_traits<wchar_t>::init_) && is_init)
|
||||
if((--entry_count == 0) && (0 != &w32_regex_traits<regex_wchar_type>::init_) && is_init)
|
||||
do_free();
|
||||
#ifdef BOOST_HAS_THREADS
|
||||
g.acquire(false);
|
||||
@ -678,7 +678,7 @@ w32_regex_traits<wchar_t>::~w32_regex_traits()
|
||||
#endif
|
||||
}
|
||||
|
||||
bool BOOST_REGEX_CALL w32_regex_traits<wchar_t>::do_iswclass(wchar_t c, boost::uint_fast32_t f)
|
||||
bool BOOST_REGEX_CALL w32_regex_traits<regex_wchar_type>::do_iswclass(regex_wchar_type c, boost::uint_fast32_t f)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
if((c & ~0xFF) == 0)
|
||||
@ -686,20 +686,20 @@ bool BOOST_REGEX_CALL w32_regex_traits<wchar_t>::do_iswclass(wchar_t c, boost::u
|
||||
WORD mask;
|
||||
if(f & char_class_unicode)
|
||||
return true;
|
||||
else if(isPlatformNT && GetStringTypeW(CT_CTYPE1, &c, 1, &mask))
|
||||
else if(isPlatformNT && GetStringTypeW(CT_CTYPE1, (const wchar_t*)&c, 1, &mask))
|
||||
return BOOST_REGEX_MAKE_BOOL(mask & f & char_class_win);
|
||||
else if((f & char_class_graph) == char_class_graph)
|
||||
return true; // all wide characters are considered "graphics"
|
||||
return false;
|
||||
}
|
||||
|
||||
void BOOST_REGEX_CALL w32_regex_traits<wchar_t>::transform(std::basic_string<wchar_t>& out, const std::basic_string<wchar_t>& in)
|
||||
void BOOST_REGEX_CALL w32_regex_traits<regex_wchar_type>::transform(std::basic_string<regex_wchar_type>& out, const std::basic_string<regex_wchar_type>& in)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
scoped_array<char> alt;
|
||||
size_t n;
|
||||
if(isPlatformNT)
|
||||
n = LCMapStringW(GetUserDefaultLCID(), LCMAP_SORTKEY, in.c_str(), -1, 0, 0);
|
||||
n = LCMapStringW(GetUserDefaultLCID(), LCMAP_SORTKEY, (const wchar_t*)in.c_str(), -1, 0, 0);
|
||||
else
|
||||
{
|
||||
n = strnarrow(static_cast<char*>(0), 0, in.c_str());
|
||||
@ -712,21 +712,21 @@ void BOOST_REGEX_CALL w32_regex_traits<wchar_t>::transform(std::basic_string<wch
|
||||
out = in;
|
||||
return;
|
||||
}
|
||||
scoped_array<wchar_t> buf(new wchar_t[n+1]);
|
||||
scoped_array<regex_wchar_type> buf(new regex_wchar_type[n+1]);
|
||||
// under win32 we get mapped to an array of bytes
|
||||
// not characters; since the underlying engine has to
|
||||
// deal with chars we widen the bytes to wchar_t to ensure
|
||||
// deal with chars we widen the bytes to regex_wchar_type to ensure
|
||||
// the sort order remains unchanged when we compare.
|
||||
scoped_array<char> t(new char[n+1]);
|
||||
if(isPlatformNT)
|
||||
n = LCMapStringW(GetUserDefaultLCID(), LCMAP_SORTKEY, in.c_str(), -1, reinterpret_cast<wchar_t*>(t.get()), (int)n);
|
||||
n = LCMapStringW(GetUserDefaultLCID(), LCMAP_SORTKEY, (const wchar_t*)in.c_str(), -1, reinterpret_cast<wchar_t*>(t.get()), (int)n);
|
||||
else
|
||||
n = LCMapStringA(GetUserDefaultLCID(), LCMAP_SORTKEY, alt.get(), -1, t.get(), (int)n);
|
||||
int i = -1;
|
||||
do
|
||||
{
|
||||
++i;
|
||||
buf[i] = (wchar_t)(unsigned char)t[i];
|
||||
buf[i] = (regex_wchar_type)(unsigned char)t[i];
|
||||
} while(t[i]);
|
||||
if(n == (size_t)(-1))
|
||||
{
|
||||
@ -736,7 +736,7 @@ void BOOST_REGEX_CALL w32_regex_traits<wchar_t>::transform(std::basic_string<wch
|
||||
out = buf.get();
|
||||
}
|
||||
|
||||
void BOOST_REGEX_CALL w32_regex_traits<wchar_t>::transform_primary(std::basic_string<wchar_t>& out, const std::basic_string<wchar_t>& in)
|
||||
void BOOST_REGEX_CALL w32_regex_traits<regex_wchar_type>::transform_primary(std::basic_string<regex_wchar_type>& out, const std::basic_string<regex_wchar_type>& in)
|
||||
{
|
||||
transform(out, in);
|
||||
for(unsigned int i = 0; i < out.size(); ++i)
|
||||
@ -750,7 +750,7 @@ void BOOST_REGEX_CALL w32_regex_traits<wchar_t>::transform_primary(std::basic_st
|
||||
}
|
||||
|
||||
|
||||
int BOOST_REGEX_CALL w32_regex_traits<wchar_t>::toi(wchar_t c)
|
||||
int BOOST_REGEX_CALL w32_regex_traits<regex_wchar_type>::toi(regex_wchar_type c)
|
||||
{
|
||||
if(is_class(c, char_class_digit))
|
||||
return c - re_zero_w;
|
||||
@ -759,7 +759,7 @@ int BOOST_REGEX_CALL w32_regex_traits<wchar_t>::toi(wchar_t c)
|
||||
return -1; // error!!
|
||||
}
|
||||
|
||||
int BOOST_REGEX_CALL w32_regex_traits<wchar_t>::toi(const wchar_t*& first, const wchar_t* last, int radix)
|
||||
int BOOST_REGEX_CALL w32_regex_traits<regex_wchar_type>::toi(const regex_wchar_type*& first, const regex_wchar_type* last, int radix)
|
||||
{
|
||||
unsigned int maxval;
|
||||
if(radix < 0)
|
||||
@ -789,9 +789,9 @@ int BOOST_REGEX_CALL w32_regex_traits<wchar_t>::toi(const wchar_t*& first, const
|
||||
return result;
|
||||
}
|
||||
|
||||
boost::uint_fast32_t BOOST_REGEX_CALL w32_regex_traits<wchar_t>::lookup_classname(const wchar_t* first, const wchar_t* last)
|
||||
boost::uint_fast32_t BOOST_REGEX_CALL w32_regex_traits<regex_wchar_type>::lookup_classname(const regex_wchar_type* first, const regex_wchar_type* last)
|
||||
{
|
||||
std::basic_string<wchar_t> s(first, last);
|
||||
std::basic_string<regex_wchar_type> s(first, last);
|
||||
std::size_t len = strnarrow(static_cast<char*>(0), 0, s.c_str());
|
||||
scoped_array<char> buf(new char[len]);
|
||||
strnarrow(buf.get(), len, s.c_str());
|
||||
@ -799,7 +799,7 @@ boost::uint_fast32_t BOOST_REGEX_CALL w32_regex_traits<wchar_t>::lookup_classnam
|
||||
return result;
|
||||
}
|
||||
|
||||
wchar_t BOOST_REGEX_CALL w32_regex_traits<wchar_t>::wtolower(wchar_t c)
|
||||
regex_wchar_type BOOST_REGEX_CALL w32_regex_traits<regex_wchar_type>::wtolower(regex_wchar_type c)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
if(isPlatformNT)
|
||||
@ -808,27 +808,27 @@ wchar_t BOOST_REGEX_CALL w32_regex_traits<wchar_t>::wtolower(wchar_t c)
|
||||
}
|
||||
|
||||
|
||||
w32_regex_traits<wchar_t> w32_regex_traits<wchar_t>::init_;
|
||||
w32_regex_traits<regex_wchar_type> w32_regex_traits<regex_wchar_type>::init_;
|
||||
|
||||
std::size_t BOOST_REGEX_CALL w32_regex_traits<wchar_t>::strnarrow(char *s1, std::size_t len, const wchar_t *s2)
|
||||
std::size_t BOOST_REGEX_CALL w32_regex_traits<regex_wchar_type>::strnarrow(char *s1, std::size_t len, const regex_wchar_type *s2)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
std::size_t size = WideCharToMultiByte(CP_ACP, 0, s2, -1, s1, 0, 0, 0);
|
||||
std::size_t size = WideCharToMultiByte(CP_ACP, 0, (const wchar_t*)s2, -1, s1, 0, 0, 0);
|
||||
if(size > len)
|
||||
return size;
|
||||
return WideCharToMultiByte(CP_ACP, 0, s2, -1, s1, (int)len, 0, 0);
|
||||
return WideCharToMultiByte(CP_ACP, 0, (const wchar_t*)s2, -1, s1, (int)len, 0, 0);
|
||||
}
|
||||
|
||||
std::size_t BOOST_REGEX_CALL w32_regex_traits<wchar_t>::strwiden(wchar_t *s1, std::size_t len, const char *s2)
|
||||
std::size_t BOOST_REGEX_CALL w32_regex_traits<regex_wchar_type>::strwiden(regex_wchar_type *s1, std::size_t len, const char *s2)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
std::size_t size = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, s2, -1, s1, 0);
|
||||
std::size_t size = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, s2, -1, (wchar_t*)s1, 0);
|
||||
if(size > len)
|
||||
return size;
|
||||
return MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, s2, -1, s1, (int)len);
|
||||
return MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, s2, -1, (wchar_t*)s1, (int)len);
|
||||
}
|
||||
|
||||
unsigned short w32_regex_traits<wchar_t>::wide_unicode_classes[] = {
|
||||
unsigned short w32_regex_traits<regex_wchar_type>::wide_unicode_classes[] = {
|
||||
re_detail::w32_traits_base::char_class_cntrl, // '' 0
|
||||
re_detail::w32_traits_base::char_class_cntrl, // '' 1
|
||||
re_detail::w32_traits_base::char_class_cntrl, // '' 2
|
||||
|
Reference in New Issue
Block a user