Change "id" to "idx" to be Objective C++ compatible.

Fixes #2306.
Fixes #4132.
Fixes #4191.

[SVN r61789]
This commit is contained in:
John Maddock
2010-05-05 17:40:07 +00:00
parent 87d5fd1421
commit fa96f4edf1
9 changed files with 104 additions and 103 deletions

View File

@ -769,14 +769,14 @@ void basic_regex_creator<charT, traits>::fixup_recursions(re_syntax_base* state)
case syntax_element_assert_backref: case syntax_element_assert_backref:
{ {
// just check that the index is valid: // just check that the index is valid:
int id = static_cast<const re_brace*>(state)->index; int idx = static_cast<const re_brace*>(state)->index;
if(id < 0) if(idx < 0)
{ {
id = -id-1; idx = -idx-1;
if(id >= 10000) if(idx >= 10000)
{ {
id = m_pdata->get_id(id); idx = m_pdata->get_id(idx);
if(id <= 0) if(idx <= 0)
{ {
// check of sub-expression that doesn't exist: // check of sub-expression that doesn't exist:
if(0 == this->m_pdata->m_status) // update the error code if not already set if(0 == this->m_pdata->m_status) // update the error code if not already set
@ -804,12 +804,12 @@ void basic_regex_creator<charT, traits>::fixup_recursions(re_syntax_base* state)
{ {
bool ok = false; bool ok = false;
re_syntax_base* p = base; re_syntax_base* p = base;
std::ptrdiff_t id = static_cast<re_jump*>(state)->alt.i; std::ptrdiff_t idx = static_cast<re_jump*>(state)->alt.i;
if(id > 10000) if(idx > 10000)
id = m_pdata->get_id(id); idx = m_pdata->get_id(idx);
while(p) while(p)
{ {
if((p->type == syntax_element_startmark) && (static_cast<re_brace*>(p)->index == id)) if((p->type == syntax_element_startmark) && (static_cast<re_brace*>(p)->index == idx))
{ {
// //
// We've found the target of the recursion, set the jump target: // We've found the target of the recursion, set the jump target:
@ -833,7 +833,7 @@ void basic_regex_creator<charT, traits>::fixup_recursions(re_syntax_base* state)
next_rep_id = static_cast<re_repeat*>(p)->state_id; next_rep_id = static_cast<re_repeat*>(p)->state_id;
break; break;
case syntax_element_endmark: case syntax_element_endmark:
if(static_cast<const re_brace*>(p)->index == id) if(static_cast<const re_brace*>(p)->index == idx)
next_rep_id = -1; next_rep_id = -1;
break; break;
default: default:
@ -1543,3 +1543,4 @@ void basic_regex_creator<charT, traits>::probe_leading_repeat(re_syntax_base* st
#endif #endif
#endif #endif

View File

@ -336,7 +336,7 @@ struct recursion_info
{ {
typedef typename Results::value_type value_type; typedef typename Results::value_type value_type;
typedef typename value_type::iterator iterator; typedef typename value_type::iterator iterator;
int id; int idx;
const re_syntax_base* preturn_address; const re_syntax_base* preturn_address;
Results results; Results results;
repeater_count<iterator>* repeater_stack; repeater_count<iterator>* repeater_stack;
@ -522,7 +522,7 @@ private:
void push_repeater_count(int i, repeater_count<BidiIterator>** s); void push_repeater_count(int i, repeater_count<BidiIterator>** s);
void push_single_repeat(std::size_t c, const re_repeat* r, BidiIterator last_position, int state_id); void push_single_repeat(std::size_t c, const re_repeat* r, BidiIterator last_position, int state_id);
void push_non_greedy_repeat(const re_syntax_base* ps); void push_non_greedy_repeat(const re_syntax_base* ps);
void push_recursion(int id, const re_syntax_base* p, results_type* presults); void push_recursion(int idx, const re_syntax_base* p, results_type* presults);
void push_recursion_pop(); void push_recursion_pop();
// pointer to base of stack: // pointer to base of stack:

View File

@ -732,10 +732,10 @@ inline bool perl_matcher<BidiIterator, Allocator, traits>::match_assert_backref(
{ {
// Have we recursed into subexpression "index"? // Have we recursed into subexpression "index"?
// If index == 0 then check for any recursion at all, otherwise for recursion to -index-1. // If index == 0 then check for any recursion at all, otherwise for recursion to -index-1.
int id = -index-1; int idx = -index-1;
if(id >= 10000) if(idx >= 10000)
id = re.get_data().get_id(id); idx = re.get_data().get_id(idx);
result = !recursion_stack.empty() && ((recursion_stack.back().id == id) || (index == 0)); result = !recursion_stack.empty() && ((recursion_stack.back().idx == idx) || (index == 0));
pstate = pstate->next.p; pstate = pstate->next.p;
} }
return result; return result;

View File

@ -130,8 +130,8 @@ struct saved_single_repeat : public saved_state
template <class Results> template <class Results>
struct saved_recursion : public saved_state struct saved_recursion : public saved_state
{ {
saved_recursion(int id, const re_syntax_base* p, Results* pr) saved_recursion(int idx, const re_syntax_base* p, Results* pr)
: saved_state(14), recursion_id(id), preturn_address(p), results(*pr) : saved_state(14), recursion_id(idx), preturn_address(p), results(*pr)
{} {}
int recursion_id; int recursion_id;
const re_syntax_base* preturn_address; const re_syntax_base* preturn_address;
@ -329,7 +329,7 @@ inline void perl_matcher<BidiIterator, Allocator, traits>::push_single_repeat(st
} }
template <class BidiIterator, class Allocator, class traits> template <class BidiIterator, class Allocator, class traits>
inline void perl_matcher<BidiIterator, Allocator, traits>::push_recursion(int id, const re_syntax_base* p, results_type* presults) inline void perl_matcher<BidiIterator, Allocator, traits>::push_recursion(int idx, const re_syntax_base* p, results_type* presults)
{ {
saved_recursion<results_type>* pmp = static_cast<saved_recursion<results_type>*>(m_backup_state); saved_recursion<results_type>* pmp = static_cast<saved_recursion<results_type>*>(m_backup_state);
--pmp; --pmp;
@ -339,7 +339,7 @@ inline void perl_matcher<BidiIterator, Allocator, traits>::push_recursion(int id
pmp = static_cast<saved_recursion<results_type>*>(m_backup_state); pmp = static_cast<saved_recursion<results_type>*>(m_backup_state);
--pmp; --pmp;
} }
(void) new (pmp)saved_recursion<results_type>(id, p, presults); (void) new (pmp)saved_recursion<results_type>(idx, p, presults);
m_backup_state = pmp; m_backup_state = pmp;
} }
@ -910,7 +910,7 @@ bool perl_matcher<BidiIterator, Allocator, traits>::match_recursion()
push_repeater_count(static_cast<const re_recurse*>(pstate)->state_id, &next_count); push_repeater_count(static_cast<const re_recurse*>(pstate)->state_id, &next_count);
} }
pstate = static_cast<const re_jump*>(pstate)->alt.p; pstate = static_cast<const re_jump*>(pstate)->alt.p;
recursion_stack.back().id = static_cast<const re_brace*>(pstate)->index; recursion_stack.back().idx = static_cast<const re_brace*>(pstate)->index;
return true; return true;
} }
@ -928,11 +928,11 @@ bool perl_matcher<BidiIterator, Allocator, traits>::match_endmark()
} }
if(!recursion_stack.empty()) if(!recursion_stack.empty())
{ {
if(index == recursion_stack.back().id) if(index == recursion_stack.back().idx)
{ {
pstate = recursion_stack.back().preturn_address; pstate = recursion_stack.back().preturn_address;
*m_presult = recursion_stack.back().results; *m_presult = recursion_stack.back().results;
push_recursion(recursion_stack.back().id, recursion_stack.back().preturn_address, &recursion_stack.back().results); push_recursion(recursion_stack.back().idx, recursion_stack.back().preturn_address, &recursion_stack.back().results);
recursion_stack.pop_back(); recursion_stack.pop_back();
} }
} }
@ -952,10 +952,10 @@ bool perl_matcher<BidiIterator, Allocator, traits>::match_match()
{ {
if(!recursion_stack.empty()) if(!recursion_stack.empty())
{ {
BOOST_ASSERT(0 == recursion_stack.back().id); BOOST_ASSERT(0 == recursion_stack.back().idx);
pstate = recursion_stack.back().preturn_address; pstate = recursion_stack.back().preturn_address;
*m_presult = recursion_stack.back().results; *m_presult = recursion_stack.back().results;
push_recursion(recursion_stack.back().id, recursion_stack.back().preturn_address, &recursion_stack.back().results); push_recursion(recursion_stack.back().idx, recursion_stack.back().preturn_address, &recursion_stack.back().results);
recursion_stack.pop_back(); recursion_stack.pop_back();
return true; return true;
} }
@ -1523,7 +1523,7 @@ bool perl_matcher<BidiIterator, Allocator, traits>::unwind_recursion(bool r)
if(!r) if(!r)
{ {
recursion_stack.push_back(recursion_info<results_type>()); recursion_stack.push_back(recursion_info<results_type>());
recursion_stack.back().id = pmp->recursion_id; recursion_stack.back().idx = pmp->recursion_id;
recursion_stack.back().preturn_address = pmp->preturn_address; recursion_stack.back().preturn_address = pmp->preturn_address;
recursion_stack.back().results = pmp->results; recursion_stack.back().results = pmp->results;
} }

View File

@ -866,7 +866,7 @@ bool perl_matcher<BidiIterator, Allocator, traits>::match_recursion()
recursion_stack.back().results = *m_presult; recursion_stack.back().results = *m_presult;
recursion_stack.back().repeater_stack = next_count; recursion_stack.back().repeater_stack = next_count;
pstate = static_cast<const re_jump*>(pstate)->alt.p; pstate = static_cast<const re_jump*>(pstate)->alt.p;
recursion_stack.back().id = static_cast<const re_brace*>(pstate)->index; recursion_stack.back().idx = static_cast<const re_brace*>(pstate)->index;
repeater_count<BidiIterator>* saved = next_count; repeater_count<BidiIterator>* saved = next_count;
repeater_count<BidiIterator> r(&next_count); // resets all repeat counts since we're recursing and starting fresh on those repeater_count<BidiIterator> r(&next_count); // resets all repeat counts since we're recursing and starting fresh on those
@ -897,7 +897,7 @@ bool perl_matcher<BidiIterator, Allocator, traits>::match_endmark()
} }
if(!recursion_stack.empty()) if(!recursion_stack.empty())
{ {
if(index == recursion_stack.back().id) if(index == recursion_stack.back().idx)
{ {
recursion_info<results_type> saved = recursion_stack.back(); recursion_info<results_type> saved = recursion_stack.back();
recursion_stack.pop_back(); recursion_stack.pop_back();
@ -929,7 +929,7 @@ bool perl_matcher<BidiIterator, Allocator, traits>::match_match()
{ {
if(!recursion_stack.empty()) if(!recursion_stack.empty())
{ {
BOOST_ASSERT(0 == recursion_stack.back().id); BOOST_ASSERT(0 == recursion_stack.back().idx);
const re_syntax_base* saved_state = pstate = recursion_stack.back().preturn_address; const re_syntax_base* saved_state = pstate = recursion_stack.back().preturn_address;
*m_presult = recursion_stack.back().results; *m_presult = recursion_stack.back().results;
recursion_stack.pop_back(); recursion_stack.pop_back();

View File

@ -155,16 +155,16 @@ c_regex_traits<char>::char_class_type BOOST_REGEX_CALL c_regex_traits<char>::loo
char_class_xdigit, char_class_xdigit,
}; };
int id = ::boost::re_detail::get_default_class_id(p1, p2); int idx = ::boost::re_detail::get_default_class_id(p1, p2);
if(id < 0) if(idx < 0)
{ {
std::string s(p1, p2); std::string s(p1, p2);
for(std::string::size_type i = 0; i < s.size(); ++i) for(std::string::size_type i = 0; i < s.size(); ++i)
s[i] = static_cast<char>((std::tolower)(static_cast<unsigned char>(s[i]))); s[i] = static_cast<char>((std::tolower)(static_cast<unsigned char>(s[i])));
id = ::boost::re_detail::get_default_class_id(&*s.begin(), &*s.begin() + s.size()); idx = ::boost::re_detail::get_default_class_id(&*s.begin(), &*s.begin() + s.size());
} }
BOOST_ASSERT(std::size_t(id+1) < sizeof(masks) / sizeof(masks[0])); BOOST_ASSERT(std::size_t(idx+1) < sizeof(masks) / sizeof(masks[0]));
return masks[id+1]; return masks[idx+1];
} }
bool BOOST_REGEX_CALL c_regex_traits<char>::isctype(char c, char_class_type mask) bool BOOST_REGEX_CALL c_regex_traits<char>::isctype(char c, char_class_type mask)

View File

@ -388,14 +388,14 @@ icu_regex_traits::char_class_type icu_regex_traits::lookup_classname(const char_
char_class_type(U_GC_ND_MASK) | mask_xdigit, char_class_type(U_GC_ND_MASK) | mask_xdigit,
}; };
int id = ::boost::re_detail::get_default_class_id(p1, p2); int idx = ::boost::re_detail::get_default_class_id(p1, p2);
if(id >= 0) if(idx >= 0)
return masks[id+1]; return masks[idx+1];
char_class_type result = lookup_icu_mask(p1, p2); char_class_type result = lookup_icu_mask(p1, p2);
if(result != 0) if(result != 0)
return result; return result;
if(id < 0) if(idx < 0)
{ {
string_type s(p1, p2); string_type s(p1, p2);
string_type::size_type i = 0; string_type::size_type i = 0;
@ -411,16 +411,16 @@ icu_regex_traits::char_class_type icu_regex_traits::lookup_classname(const char_
} }
} }
if(s.size()) if(s.size())
id = ::boost::re_detail::get_default_class_id(&*s.begin(), &*s.begin() + s.size()); idx = ::boost::re_detail::get_default_class_id(&*s.begin(), &*s.begin() + s.size());
if(id >= 0) if(idx >= 0)
return masks[id+1]; return masks[idx+1];
if(s.size()) if(s.size())
result = lookup_icu_mask(&*s.begin(), &*s.begin() + s.size()); result = lookup_icu_mask(&*s.begin(), &*s.begin() + s.size());
if(result != 0) if(result != 0)
return result; return result;
} }
BOOST_ASSERT(std::size_t(id+1) < sizeof(masks) / sizeof(masks[0])); BOOST_ASSERT(std::size_t(idx+1) < sizeof(masks) / sizeof(masks[0]));
return masks[id+1]; return masks[idx+1];
} }
icu_regex_traits::string_type icu_regex_traits::lookup_collatename(const char_type* p1, const char_type* p2) const icu_regex_traits::string_type icu_regex_traits::lookup_collatename(const char_type* p1, const char_type* p2) const

View File

@ -43,10 +43,10 @@ namespace std{
namespace boost{ namespace re_detail{ namespace boost{ namespace re_detail{
#ifdef BOOST_NO_ANSI_APIS #ifdef BOOST_NO_ANSI_APIS
UINT get_code_page_for_locale_id(lcid_type id) UINT get_code_page_for_locale_id(lcid_type idx)
{ {
WCHAR code_page_string[7]; WCHAR code_page_string[7];
if (::GetLocaleInfoW(id, LOCALE_IDEFAULTANSICODEPAGE, code_page_string, 7) == 0) if (::GetLocaleInfoW(idx, LOCALE_IDEFAULTANSICODEPAGE, code_page_string, 7) == 0)
return 0; return 0;
return static_cast<UINT>(_wtol(code_page_string)); return static_cast<UINT>(_wtol(code_page_string));
@ -157,15 +157,15 @@ BOOST_REGEX_DECL lcid_type BOOST_REGEX_CALL w32_get_default_locale()
return ::GetUserDefaultLCID(); return ::GetUserDefaultLCID();
} }
BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is_lower(char c, lcid_type id) BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is_lower(char c, lcid_type idx)
{ {
#ifndef BOOST_NO_ANSI_APIS #ifndef BOOST_NO_ANSI_APIS
WORD mask; WORD mask;
if(::GetStringTypeExA(id, CT_CTYPE1, &c, 1, &mask) && (mask & C1_LOWER)) if(::GetStringTypeExA(idx, CT_CTYPE1, &c, 1, &mask) && (mask & C1_LOWER))
return true; return true;
return false; return false;
#else #else
UINT code_page = get_code_page_for_locale_id(id); UINT code_page = get_code_page_for_locale_id(idx);
if (code_page == 0) if (code_page == 0)
return false; return false;
@ -174,39 +174,39 @@ BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is_lower(char c, lcid_type id)
return false; return false;
WORD mask; WORD mask;
if(::GetStringTypeExW(id, CT_CTYPE1, &wide_c, 1, &mask) && (mask & C1_LOWER)) if(::GetStringTypeExW(idx, CT_CTYPE1, &wide_c, 1, &mask) && (mask & C1_LOWER))
return true; return true;
return false; return false;
#endif #endif
} }
BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is_lower(wchar_t c, lcid_type id) BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is_lower(wchar_t c, lcid_type idx)
{ {
WORD mask; WORD mask;
if(::GetStringTypeExW(id, CT_CTYPE1, &c, 1, &mask) && (mask & C1_LOWER)) if(::GetStringTypeExW(idx, CT_CTYPE1, &c, 1, &mask) && (mask & C1_LOWER))
return true; return true;
return false; return false;
} }
#ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T #ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T
BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is_lower(unsigned short ca, lcid_type id) BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is_lower(unsigned short ca, lcid_type idx)
{ {
WORD mask; WORD mask;
wchar_t c = ca; wchar_t c = ca;
if(::GetStringTypeExW(id, CT_CTYPE1, &c, 1, &mask) && (mask & C1_LOWER)) if(::GetStringTypeExW(idx, CT_CTYPE1, &c, 1, &mask) && (mask & C1_LOWER))
return true; return true;
return false; return false;
} }
#endif #endif
BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is_upper(char c, lcid_type id) BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is_upper(char c, lcid_type idx)
{ {
#ifndef BOOST_NO_ANSI_APIS #ifndef BOOST_NO_ANSI_APIS
WORD mask; WORD mask;
if(::GetStringTypeExA(id, CT_CTYPE1, &c, 1, &mask) && (mask & C1_UPPER)) if(::GetStringTypeExA(idx, CT_CTYPE1, &c, 1, &mask) && (mask & C1_UPPER))
return true; return true;
return false; return false;
#else #else
UINT code_page = get_code_page_for_locale_id(id); UINT code_page = get_code_page_for_locale_id(idx);
if (code_page == 0) if (code_page == 0)
return false; return false;
@ -215,25 +215,25 @@ BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is_upper(char c, lcid_type id)
return false; return false;
WORD mask; WORD mask;
if(::GetStringTypeExW(id, CT_CTYPE1, &wide_c, 1, &mask) && (mask & C1_UPPER)) if(::GetStringTypeExW(idx, CT_CTYPE1, &wide_c, 1, &mask) && (mask & C1_UPPER))
return true; return true;
return false; return false;
#endif #endif
} }
BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is_upper(wchar_t c, lcid_type id) BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is_upper(wchar_t c, lcid_type idx)
{ {
WORD mask; WORD mask;
if(::GetStringTypeExW(id, CT_CTYPE1, &c, 1, &mask) && (mask & C1_UPPER)) if(::GetStringTypeExW(idx, CT_CTYPE1, &c, 1, &mask) && (mask & C1_UPPER))
return true; return true;
return false; return false;
} }
#ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T #ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T
BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is_upper(unsigned short ca, lcid_type id) BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is_upper(unsigned short ca, lcid_type idx)
{ {
WORD mask; WORD mask;
wchar_t c = ca; wchar_t c = ca;
if(::GetStringTypeExW(id, CT_CTYPE1, &c, 1, &mask) && (mask & C1_UPPER)) if(::GetStringTypeExW(idx, CT_CTYPE1, &c, 1, &mask) && (mask & C1_UPPER))
return true; return true;
return false; return false;
} }
@ -322,11 +322,11 @@ BOOST_REGEX_DECL std::basic_string<unsigned short> BOOST_REGEX_CALL w32_cat_get(
} }
#endif #endif
#endif #endif
BOOST_REGEX_DECL std::string BOOST_REGEX_CALL w32_transform(lcid_type id, const char* p1, const char* p2) BOOST_REGEX_DECL std::string BOOST_REGEX_CALL w32_transform(lcid_type idx, const char* p1, const char* p2)
{ {
#ifndef BOOST_NO_ANSI_APIS #ifndef BOOST_NO_ANSI_APIS
int bytes = ::LCMapStringA( int bytes = ::LCMapStringA(
id, // locale identifier idx, // locale identifier
LCMAP_SORTKEY, // mapping transformation type LCMAP_SORTKEY, // mapping transformation type
p1, // source string p1, // source string
static_cast<int>(p2 - p1), // number of characters in source string static_cast<int>(p2 - p1), // number of characters in source string
@ -337,7 +337,7 @@ BOOST_REGEX_DECL std::string BOOST_REGEX_CALL w32_transform(lcid_type id, const
return std::string(p1, p2); return std::string(p1, p2);
std::string result(++bytes, '\0'); std::string result(++bytes, '\0');
bytes = ::LCMapStringA( bytes = ::LCMapStringA(
id, // locale identifier idx, // locale identifier
LCMAP_SORTKEY, // mapping transformation type LCMAP_SORTKEY, // mapping transformation type
p1, // source string p1, // source string
static_cast<int>(p2 - p1), // number of characters in source string static_cast<int>(p2 - p1), // number of characters in source string
@ -345,7 +345,7 @@ BOOST_REGEX_DECL std::string BOOST_REGEX_CALL w32_transform(lcid_type id, const
bytes // size of destination buffer bytes // size of destination buffer
); );
#else #else
UINT code_page = get_code_page_for_locale_id(id); UINT code_page = get_code_page_for_locale_id(idx);
if(code_page == 0) if(code_page == 0)
return std::string(p1, p2); return std::string(p1, p2);
@ -355,7 +355,7 @@ BOOST_REGEX_DECL std::string BOOST_REGEX_CALL w32_transform(lcid_type id, const
return std::string(p1, p2); return std::string(p1, p2);
int bytes = ::LCMapStringW( int bytes = ::LCMapStringW(
id, // locale identifier idx, // locale identifier
LCMAP_SORTKEY, // mapping transformation type LCMAP_SORTKEY, // mapping transformation type
wide_p1, // source string wide_p1, // source string
src_len, // number of characters in source string src_len, // number of characters in source string
@ -366,7 +366,7 @@ BOOST_REGEX_DECL std::string BOOST_REGEX_CALL w32_transform(lcid_type id, const
return std::string(p1, p2); return std::string(p1, p2);
std::string result(++bytes, '\0'); std::string result(++bytes, '\0');
bytes = ::LCMapStringW( bytes = ::LCMapStringW(
id, // locale identifier idx, // locale identifier
LCMAP_SORTKEY, // mapping transformation type LCMAP_SORTKEY, // mapping transformation type
wide_p1, // source string wide_p1, // source string
src_len, // number of characters in source string src_len, // number of characters in source string
@ -384,10 +384,10 @@ BOOST_REGEX_DECL std::string BOOST_REGEX_CALL w32_transform(lcid_type id, const
} }
#ifndef BOOST_NO_WREGEX #ifndef BOOST_NO_WREGEX
BOOST_REGEX_DECL std::wstring BOOST_REGEX_CALL w32_transform(lcid_type id, const wchar_t* p1, const wchar_t* p2) BOOST_REGEX_DECL std::wstring BOOST_REGEX_CALL w32_transform(lcid_type idx, const wchar_t* p1, const wchar_t* p2)
{ {
int bytes = ::LCMapStringW( int bytes = ::LCMapStringW(
id, // locale identifier idx, // locale identifier
LCMAP_SORTKEY, // mapping transformation type LCMAP_SORTKEY, // mapping transformation type
p1, // source string p1, // source string
static_cast<int>(p2 - p1), // number of characters in source string static_cast<int>(p2 - p1), // number of characters in source string
@ -398,7 +398,7 @@ BOOST_REGEX_DECL std::wstring BOOST_REGEX_CALL w32_transform(lcid_type id, const
return std::wstring(p1, p2); return std::wstring(p1, p2);
std::string result(++bytes, '\0'); std::string result(++bytes, '\0');
bytes = ::LCMapStringW( bytes = ::LCMapStringW(
id, // locale identifier idx, // locale identifier
LCMAP_SORTKEY, // mapping transformation type LCMAP_SORTKEY, // mapping transformation type
p1, // source string p1, // source string
static_cast<int>(p2 - p1), // number of characters in source string static_cast<int>(p2 - p1), // number of characters in source string
@ -417,10 +417,10 @@ BOOST_REGEX_DECL std::wstring BOOST_REGEX_CALL w32_transform(lcid_type id, const
return r2; return r2;
} }
#ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T #ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T
BOOST_REGEX_DECL std::basic_string<unsigned short> BOOST_REGEX_CALL w32_transform(lcid_type id, const unsigned short* p1, const unsigned short* p2) BOOST_REGEX_DECL std::basic_string<unsigned short> BOOST_REGEX_CALL w32_transform(lcid_type idx, const unsigned short* p1, const unsigned short* p2)
{ {
int bytes = ::LCMapStringW( int bytes = ::LCMapStringW(
id, // locale identifier idx, // locale identifier
LCMAP_SORTKEY, // mapping transformation type LCMAP_SORTKEY, // mapping transformation type
(LPCWSTR)p1, // source string (LPCWSTR)p1, // source string
static_cast<int>(p2 - p1), // number of characters in source string static_cast<int>(p2 - p1), // number of characters in source string
@ -431,7 +431,7 @@ BOOST_REGEX_DECL std::basic_string<unsigned short> BOOST_REGEX_CALL w32_transfor
return std::basic_string<unsigned short>(p1, p2); return std::basic_string<unsigned short>(p1, p2);
std::string result(++bytes, '\0'); std::string result(++bytes, '\0');
bytes = ::LCMapStringW( bytes = ::LCMapStringW(
id, // locale identifier idx, // locale identifier
LCMAP_SORTKEY, // mapping transformation type LCMAP_SORTKEY, // mapping transformation type
(LPCWSTR)p1, // source string (LPCWSTR)p1, // source string
static_cast<int>(p2 - p1), // number of characters in source string static_cast<int>(p2 - p1), // number of characters in source string
@ -451,12 +451,12 @@ BOOST_REGEX_DECL std::basic_string<unsigned short> BOOST_REGEX_CALL w32_transfor
} }
#endif #endif
#endif #endif
BOOST_REGEX_DECL char BOOST_REGEX_CALL w32_tolower(char c, lcid_type id) BOOST_REGEX_DECL char BOOST_REGEX_CALL w32_tolower(char c, lcid_type idx)
{ {
char result[2]; char result[2];
#ifndef BOOST_NO_ANSI_APIS #ifndef BOOST_NO_ANSI_APIS
int b = ::LCMapStringA( int b = ::LCMapStringA(
id, // locale identifier idx, // locale identifier
LCMAP_LOWERCASE, // mapping transformation type LCMAP_LOWERCASE, // mapping transformation type
&c, // source string &c, // source string
1, // number of characters in source string 1, // number of characters in source string
@ -465,7 +465,7 @@ BOOST_REGEX_DECL char BOOST_REGEX_CALL w32_tolower(char c, lcid_type id)
if(b == 0) if(b == 0)
return c; return c;
#else #else
UINT code_page = get_code_page_for_locale_id(id); UINT code_page = get_code_page_for_locale_id(idx);
if (code_page == 0) if (code_page == 0)
return c; return c;
@ -475,7 +475,7 @@ BOOST_REGEX_DECL char BOOST_REGEX_CALL w32_tolower(char c, lcid_type id)
WCHAR wide_result; WCHAR wide_result;
int b = ::LCMapStringW( int b = ::LCMapStringW(
id, // locale identifier idx, // locale identifier
LCMAP_LOWERCASE, // mapping transformation type LCMAP_LOWERCASE, // mapping transformation type
&wide_c, // source string &wide_c, // source string
1, // number of characters in source string 1, // number of characters in source string
@ -491,11 +491,11 @@ BOOST_REGEX_DECL char BOOST_REGEX_CALL w32_tolower(char c, lcid_type id)
} }
#ifndef BOOST_NO_WREGEX #ifndef BOOST_NO_WREGEX
BOOST_REGEX_DECL wchar_t BOOST_REGEX_CALL w32_tolower(wchar_t c, lcid_type id) BOOST_REGEX_DECL wchar_t BOOST_REGEX_CALL w32_tolower(wchar_t c, lcid_type idx)
{ {
wchar_t result[2]; wchar_t result[2];
int b = ::LCMapStringW( int b = ::LCMapStringW(
id, // locale identifier idx, // locale identifier
LCMAP_LOWERCASE, // mapping transformation type LCMAP_LOWERCASE, // mapping transformation type
&c, // source string &c, // source string
1, // number of characters in source string 1, // number of characters in source string
@ -506,11 +506,11 @@ BOOST_REGEX_DECL wchar_t BOOST_REGEX_CALL w32_tolower(wchar_t c, lcid_type id)
return result[0]; return result[0];
} }
#ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T #ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T
BOOST_REGEX_DECL unsigned short BOOST_REGEX_CALL w32_tolower(unsigned short c, lcid_type id) BOOST_REGEX_DECL unsigned short BOOST_REGEX_CALL w32_tolower(unsigned short c, lcid_type idx)
{ {
wchar_t result[2]; wchar_t result[2];
int b = ::LCMapStringW( int b = ::LCMapStringW(
id, // locale identifier idx, // locale identifier
LCMAP_LOWERCASE, // mapping transformation type LCMAP_LOWERCASE, // mapping transformation type
(wchar_t const*)&c, // source string (wchar_t const*)&c, // source string
1, // number of characters in source string 1, // number of characters in source string
@ -522,12 +522,12 @@ BOOST_REGEX_DECL unsigned short BOOST_REGEX_CALL w32_tolower(unsigned short c, l
} }
#endif #endif
#endif #endif
BOOST_REGEX_DECL char BOOST_REGEX_CALL w32_toupper(char c, lcid_type id) BOOST_REGEX_DECL char BOOST_REGEX_CALL w32_toupper(char c, lcid_type idx)
{ {
char result[2]; char result[2];
#ifndef BOOST_NO_ANSI_APIS #ifndef BOOST_NO_ANSI_APIS
int b = ::LCMapStringA( int b = ::LCMapStringA(
id, // locale identifier idx, // locale identifier
LCMAP_UPPERCASE, // mapping transformation type LCMAP_UPPERCASE, // mapping transformation type
&c, // source string &c, // source string
1, // number of characters in source string 1, // number of characters in source string
@ -536,7 +536,7 @@ BOOST_REGEX_DECL char BOOST_REGEX_CALL w32_toupper(char c, lcid_type id)
if(b == 0) if(b == 0)
return c; return c;
#else #else
UINT code_page = get_code_page_for_locale_id(id); UINT code_page = get_code_page_for_locale_id(idx);
if(code_page == 0) if(code_page == 0)
return c; return c;
@ -546,7 +546,7 @@ BOOST_REGEX_DECL char BOOST_REGEX_CALL w32_toupper(char c, lcid_type id)
WCHAR wide_result; WCHAR wide_result;
int b = ::LCMapStringW( int b = ::LCMapStringW(
id, // locale identifier idx, // locale identifier
LCMAP_UPPERCASE, // mapping transformation type LCMAP_UPPERCASE, // mapping transformation type
&wide_c, // source string &wide_c, // source string
1, // number of characters in source string 1, // number of characters in source string
@ -562,11 +562,11 @@ BOOST_REGEX_DECL char BOOST_REGEX_CALL w32_toupper(char c, lcid_type id)
} }
#ifndef BOOST_NO_WREGEX #ifndef BOOST_NO_WREGEX
BOOST_REGEX_DECL wchar_t BOOST_REGEX_CALL w32_toupper(wchar_t c, lcid_type id) BOOST_REGEX_DECL wchar_t BOOST_REGEX_CALL w32_toupper(wchar_t c, lcid_type idx)
{ {
wchar_t result[2]; wchar_t result[2];
int b = ::LCMapStringW( int b = ::LCMapStringW(
id, // locale identifier idx, // locale identifier
LCMAP_UPPERCASE, // mapping transformation type LCMAP_UPPERCASE, // mapping transformation type
&c, // source string &c, // source string
1, // number of characters in source string 1, // number of characters in source string
@ -577,11 +577,11 @@ BOOST_REGEX_DECL wchar_t BOOST_REGEX_CALL w32_toupper(wchar_t c, lcid_type id)
return result[0]; return result[0];
} }
#ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T #ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T
BOOST_REGEX_DECL unsigned short BOOST_REGEX_CALL w32_toupper(unsigned short c, lcid_type id) BOOST_REGEX_DECL unsigned short BOOST_REGEX_CALL w32_toupper(unsigned short c, lcid_type idx)
{ {
wchar_t result[2]; wchar_t result[2];
int b = ::LCMapStringW( int b = ::LCMapStringW(
id, // locale identifier idx, // locale identifier
LCMAP_UPPERCASE, // mapping transformation type LCMAP_UPPERCASE, // mapping transformation type
(wchar_t const*)&c, // source string (wchar_t const*)&c, // source string
1, // number of characters in source string 1, // number of characters in source string
@ -593,14 +593,14 @@ BOOST_REGEX_DECL unsigned short BOOST_REGEX_CALL w32_toupper(unsigned short c, l
} }
#endif #endif
#endif #endif
BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is(lcid_type id, boost::uint32_t m, char c) BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is(lcid_type idx, boost::uint32_t m, char c)
{ {
WORD mask; WORD mask;
#ifndef BOOST_NO_ANSI_APIS #ifndef BOOST_NO_ANSI_APIS
if(::GetStringTypeExA(id, CT_CTYPE1, &c, 1, &mask) && (mask & m & w32_regex_traits_implementation<char>::mask_base)) if(::GetStringTypeExA(idx, CT_CTYPE1, &c, 1, &mask) && (mask & m & w32_regex_traits_implementation<char>::mask_base))
return true; return true;
#else #else
UINT code_page = get_code_page_for_locale_id(id); UINT code_page = get_code_page_for_locale_id(idx);
if(code_page == 0) if(code_page == 0)
return false; return false;
@ -608,7 +608,7 @@ BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is(lcid_type id, boost::uint32_t m, c
if (::MultiByteToWideChar(code_page, 0, &c, 1, &wide_c, 1) == 0) if (::MultiByteToWideChar(code_page, 0, &c, 1, &wide_c, 1) == 0)
return false; return false;
if(::GetStringTypeExW(id, CT_CTYPE1, &wide_c, 1, &mask) && (mask & m & w32_regex_traits_implementation<char>::mask_base)) if(::GetStringTypeExW(idx, CT_CTYPE1, &wide_c, 1, &mask) && (mask & m & w32_regex_traits_implementation<char>::mask_base))
return true; return true;
#endif #endif
if((m & w32_regex_traits_implementation<char>::mask_word) && (c == '_')) if((m & w32_regex_traits_implementation<char>::mask_word) && (c == '_'))
@ -617,10 +617,10 @@ BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is(lcid_type id, boost::uint32_t m, c
} }
#ifndef BOOST_NO_WREGEX #ifndef BOOST_NO_WREGEX
BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is(lcid_type id, boost::uint32_t m, wchar_t c) BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is(lcid_type idx, boost::uint32_t m, wchar_t c)
{ {
WORD mask; WORD mask;
if(::GetStringTypeExW(id, CT_CTYPE1, &c, 1, &mask) && (mask & m & w32_regex_traits_implementation<wchar_t>::mask_base)) if(::GetStringTypeExW(idx, CT_CTYPE1, &c, 1, &mask) && (mask & m & w32_regex_traits_implementation<wchar_t>::mask_base))
return true; return true;
if((m & w32_regex_traits_implementation<wchar_t>::mask_word) && (c == '_')) if((m & w32_regex_traits_implementation<wchar_t>::mask_word) && (c == '_'))
return true; return true;
@ -629,10 +629,10 @@ BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is(lcid_type id, boost::uint32_t m, w
return false; return false;
} }
#ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T #ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T
BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is(lcid_type id, boost::uint32_t m, unsigned short c) BOOST_REGEX_DECL bool BOOST_REGEX_CALL w32_is(lcid_type idx, boost::uint32_t m, unsigned short c)
{ {
WORD mask; WORD mask;
if(::GetStringTypeExW(id, CT_CTYPE1, (wchar_t const*)&c, 1, &mask) && (mask & m & w32_regex_traits_implementation<wchar_t>::mask_base)) if(::GetStringTypeExW(idx, CT_CTYPE1, (wchar_t const*)&c, 1, &mask) && (mask & m & w32_regex_traits_implementation<wchar_t>::mask_base))
return true; return true;
if((m & w32_regex_traits_implementation<wchar_t>::mask_word) && (c == '_')) if((m & w32_regex_traits_implementation<wchar_t>::mask_word) && (c == '_'))
return true; return true;

View File

@ -195,16 +195,16 @@ c_regex_traits<wchar_t>::char_class_type BOOST_REGEX_CALL c_regex_traits<wchar_t
char_class_xdigit, char_class_xdigit,
}; };
int id = ::boost::re_detail::get_default_class_id(p1, p2); int idx = ::boost::re_detail::get_default_class_id(p1, p2);
if(id < 0) if(idx < 0)
{ {
std::wstring s(p1, p2); std::wstring s(p1, p2);
for(std::wstring::size_type i = 0; i < s.size(); ++i) for(std::wstring::size_type i = 0; i < s.size(); ++i)
s[i] = (std::towlower)(s[i]); s[i] = (std::towlower)(s[i]);
id = ::boost::re_detail::get_default_class_id(&*s.begin(), &*s.begin() + s.size()); idx = ::boost::re_detail::get_default_class_id(&*s.begin(), &*s.begin() + s.size());
} }
BOOST_ASSERT(id+1 < static_cast<int>(sizeof(masks) / sizeof(masks[0]))); BOOST_ASSERT(idx+1 < static_cast<int>(sizeof(masks) / sizeof(masks[0])));
return masks[id+1]; return masks[idx+1];
} }
bool BOOST_REGEX_CALL c_regex_traits<wchar_t>::isctype(wchar_t c, char_class_type mask) bool BOOST_REGEX_CALL c_regex_traits<wchar_t>::isctype(wchar_t c, char_class_type mask)