Changed all pointer casts to either static_cast or reinterpret_cast as appropriate.

[SVN r12574]
This commit is contained in:
John Maddock
2002-01-30 12:16:28 +00:00
parent 6463dcfb07
commit 5613d77433
6 changed files with 173 additions and 173 deletions

View File

@ -1462,7 +1462,7 @@ namespace re_detail{
template <class iterator, class charT, class traits_type, class Allocator> template <class iterator, class charT, class traits_type, class Allocator>
iterator BOOST_REGEX_CALL re_is_set_member(iterator next, iterator BOOST_REGEX_CALL re_is_set_member(iterator next,
iterator last, iterator last,
re_set_long* set_, const re_set_long* set_,
const reg_expression<charT, traits_type, Allocator>& e); const reg_expression<charT, traits_type, Allocator>& e);
} // namepsace re_detail } // namepsace re_detail

View File

@ -47,10 +47,10 @@ struct kmp_translator
template <class charT, class traits_type, class Allocator> template <class charT, class traits_type, class Allocator>
bool BOOST_REGEX_CALL re_maybe_set_member(charT c, bool BOOST_REGEX_CALL re_maybe_set_member(charT c,
re_set_long* set_, const re_set_long* set_,
const reg_expression<charT, traits_type, Allocator>& e) const reg_expression<charT, traits_type, Allocator>& e)
{ {
const charT* p = (const charT*)(set_+1); const charT* p = reinterpret_cast<const charT*>(set_+1);
bool icase = e.flags() & regbase::icase; bool icase = e.flags() & regbase::icase;
charT col = e.get_traits().translate(c, icase); charT col = e.get_traits().translate(c, icase);
for(unsigned int i = 0; i < set_->csingles; ++i) for(unsigned int i = 0; i < set_->csingles; ++i)
@ -410,7 +410,7 @@ charT BOOST_REGEX_CALL reg_expression<charT, traits, Allocator>::parse_escape(co
template <class charT, class traits, class Allocator> template <class charT, class traits, class Allocator>
void BOOST_REGEX_CALL reg_expression<charT, traits, Allocator>::compile_maps() void BOOST_REGEX_CALL reg_expression<charT, traits, Allocator>::compile_maps()
{ {
re_detail::re_syntax_base* record = (re_detail::re_syntax_base*)data.data(); re_detail::re_syntax_base* record = static_cast<re_detail::re_syntax_base*>(data.data());
// always compile the first _map: // always compile the first _map:
std::memset(startmap, 0, 256); std::memset(startmap, 0, 256);
record->can_be_null = 0; record->can_be_null = 0;
@ -420,10 +420,10 @@ void BOOST_REGEX_CALL reg_expression<charT, traits, Allocator>::compile_maps()
{ {
if((record->type == re_detail::syntax_element_alt) || (record->type == re_detail::syntax_element_rep)) if((record->type == re_detail::syntax_element_alt) || (record->type == re_detail::syntax_element_rep))
{ {
std::memset(&(((re_detail::re_jump*)record)->_map), 0, 256); std::memset(&(static_cast<re_detail::re_jump*>(record)->_map), 0, 256);
record->can_be_null = 0; record->can_be_null = 0;
compile_map(record->next.p, ((re_detail::re_jump*)record)->_map, &(record->can_be_null), re_detail::mask_take, ((re_detail::re_jump*)record)->alt.p); compile_map(record->next.p, static_cast<re_detail::re_jump*>(record)->_map, &(record->can_be_null), re_detail::mask_take, static_cast<re_detail::re_jump*>(record)->alt.p);
compile_map(((re_detail::re_jump*)record)->alt.p, ((re_detail::re_jump*)record)->_map, &(record->can_be_null), re_detail::mask_skip); compile_map(static_cast<re_detail::re_jump*>(record)->alt.p, static_cast<re_detail::re_jump*>(record)->_map, &(record->can_be_null), re_detail::mask_skip);
} }
else else
{ {
@ -460,7 +460,7 @@ bool BOOST_REGEX_CALL reg_expression<charT, traits, Allocator>::probe_start(
case re_detail::syntax_element_literal: case re_detail::syntax_element_literal:
// only the first character of the literal can match: // only the first character of the literal can match:
// note these have already been translated: // note these have already been translated:
if(*(charT*)(((re_detail::re_literal*)node)+1) == traits_inst.translate(cc, (_flags & regbase::icase))) if(*reinterpret_cast<charT*>(static_cast<re_detail::re_literal*>(node)+1) == traits_inst.translate(cc, (_flags & regbase::icase)))
return true; return true;
return false; return false;
case re_detail::syntax_element_end_line: case re_detail::syntax_element_end_line:
@ -499,13 +499,13 @@ bool BOOST_REGEX_CALL reg_expression<charT, traits, Allocator>::probe_start(
// we can not be null, // we can not be null,
// we need to add already translated values in the set // we need to add already translated values in the set
// to values in the _map // to values in the _map
return re_detail::re_maybe_set_member(cc, (re_detail::re_set_long*)node, *this) || (re_detail::re_is_set_member((const charT*)&cc, (const charT*)(&cc+1), (re_detail::re_set_long*)node, *this) != &cc); return re_detail::re_maybe_set_member(cc, static_cast<const re_detail::re_set_long*>(node), *this) || (re_detail::re_is_set_member(static_cast<const charT*>(&cc), static_cast<const charT*>(&cc+1), static_cast<re_detail::re_set_long*>(node), *this) != &cc);
case re_detail::syntax_element_set: case re_detail::syntax_element_set:
// set all the elements that are set in corresponding set: // set all the elements that are set in corresponding set:
c = (traits_size_type)(traits_uchar_type)traits_inst.translate(cc, (_flags & regbase::icase)); c = (traits_size_type)(traits_uchar_type)traits_inst.translate(cc, (_flags & regbase::icase));
return ((re_detail::re_set*)node)->_map[c] != 0; return static_cast<re_detail::re_set*>(node)->_map[c] != 0;
case re_detail::syntax_element_jump: case re_detail::syntax_element_jump:
if(((re_detail::re_jump*)node)->alt.p < node) if(static_cast<re_detail::re_jump*>(node)->alt.p < node)
{ {
// backwards jump, // backwards jump,
// caused only by end of repeat section, we'll treat this // caused only by end of repeat section, we'll treat this
@ -519,27 +519,27 @@ bool BOOST_REGEX_CALL reg_expression<charT, traits, Allocator>::probe_start(
// repeat that we're jumping to has non-zero minimum count // repeat that we're jumping to has non-zero minimum count
// then we need to add in the possiblity that we could still // then we need to add in the possiblity that we could still
// skip that repeat. // skip that repeat.
re_detail::re_syntax_base* next = ((re_detail::re_jump*)node)->alt.p; re_detail::re_syntax_base* next = static_cast<re_detail::re_jump*>(node)->alt.p;
bool b = probe_start(next, cc, terminal); bool b = probe_start(next, cc, terminal);
if((next->type == re_detail::syntax_element_rep) && (((re_detail::re_repeat*)next)->min != 0)) if((next->type == re_detail::syntax_element_rep) && (static_cast<re_detail::re_repeat*>(next)->min != 0))
{ {
b = b || probe_start(((re_detail::re_jump*)next)->alt.p, cc, terminal); b = b || probe_start(static_cast<re_detail::re_jump*>(next)->alt.p, cc, terminal);
} }
return b; return b;
} }
} }
else else
// take the jump and compile: // take the jump and compile:
return probe_start(((re_detail::re_jump*)node)->alt.p, cc, terminal); return probe_start(static_cast<re_detail::re_jump*>(node)->alt.p, cc, terminal);
case re_detail::syntax_element_alt: case re_detail::syntax_element_alt:
// we need to take the OR of the two alternatives: // we need to take the OR of the two alternatives:
return probe_start(((re_detail::re_jump*)node)->alt.p, cc, terminal) || probe_start(node->next.p, cc, terminal); return probe_start(static_cast<re_detail::re_jump*>(node)->alt.p, cc, terminal) || probe_start(node->next.p, cc, terminal);
case re_detail::syntax_element_rep: case re_detail::syntax_element_rep:
// we need to take the OR of the two alternatives // we need to take the OR of the two alternatives
if(((re_detail::re_repeat*)node)->min == 0) if(static_cast<re_detail::re_repeat*>(node)->min == 0)
return probe_start(node->next.p, cc, ((re_detail::re_jump*)node)->alt.p) || probe_start(((re_detail::re_jump*)node)->alt.p, cc, terminal); return probe_start(node->next.p, cc, static_cast<re_detail::re_jump*>(node)->alt.p) || probe_start(static_cast<re_detail::re_jump*>(node)->alt.p, cc, terminal);
else else
return probe_start(node->next.p, cc, ((re_detail::re_jump*)node)->alt.p); return probe_start(node->next.p, cc, static_cast<re_detail::re_jump*>(node)->alt.p);
case re_detail::syntax_element_combining: case re_detail::syntax_element_combining:
return !traits_inst.is_combining(traits_inst.translate(cc, (_flags & regbase::icase))); return !traits_inst.is_combining(traits_inst.translate(cc, (_flags & regbase::icase)));
} }
@ -567,7 +567,7 @@ bool BOOST_REGEX_CALL reg_expression<charT, traits, Allocator>::probe_start_null
case re_detail::syntax_element_backref: case re_detail::syntax_element_backref:
return true; return true;
case re_detail::syntax_element_jump: case re_detail::syntax_element_jump:
if(((re_detail::re_jump*)node)->alt.p < node) if(static_cast<re_detail::re_jump*>(node)->alt.p < node)
{ {
// backwards jump, // backwards jump,
// caused only by end of repeat section, we'll treat this // caused only by end of repeat section, we'll treat this
@ -578,17 +578,17 @@ bool BOOST_REGEX_CALL reg_expression<charT, traits, Allocator>::probe_start_null
if(node->next.p == terminal) if(node->next.p == terminal)
return true; return true;
else else
return probe_start_null(((re_detail::re_jump*)node)->alt.p, terminal); return probe_start_null(static_cast<re_detail::re_jump*>(node)->alt.p, terminal);
} }
else else
// take the jump and compile: // take the jump and compile:
return probe_start_null(((re_detail::re_jump*)node)->alt.p, terminal); return probe_start_null(static_cast<re_detail::re_jump*>(node)->alt.p, terminal);
case re_detail::syntax_element_alt: case re_detail::syntax_element_alt:
// we need to take the OR of the two alternatives: // we need to take the OR of the two alternatives:
return probe_start_null(((re_detail::re_jump*)node)->alt.p, terminal) || probe_start_null(node->next.p, terminal); return probe_start_null(static_cast<re_detail::re_jump*>(node)->alt.p, terminal) || probe_start_null(node->next.p, terminal);
case re_detail::syntax_element_rep: case re_detail::syntax_element_rep:
// only need to consider skipping the repeat: // only need to consider skipping the repeat:
return probe_start_null(((re_detail::re_jump*)node)->alt.p, terminal); return probe_start_null(static_cast<re_detail::re_jump*>(node)->alt.p, terminal);
default: default:
break; break;
} }
@ -617,18 +617,18 @@ void BOOST_REGEX_CALL reg_expression<charT, traits, Allocator>::move_offsets(re_
{ {
// move all offsets starting with j->link forward by size // move all offsets starting with j->link forward by size
// called after an insert: // called after an insert:
j = (re_detail::re_syntax_base*)((const char*)data.data() + j->next.i); j = reinterpret_cast<re_detail::re_syntax_base*>(reinterpret_cast<char*>(data.data()) + j->next.i);
while(true) while(true)
{ {
switch(j->type) switch(j->type)
{ {
case re_detail::syntax_element_rep: case re_detail::syntax_element_rep:
((re_detail::re_jump*)j)->alt.i += size; static_cast<re_detail::re_jump*>(j)->alt.i += size;
j->next.i += size; j->next.i += size;
break; break;
case re_detail::syntax_element_jump: case re_detail::syntax_element_jump:
case re_detail::syntax_element_alt: case re_detail::syntax_element_alt:
((re_detail::re_jump*)j)->alt.i += size; static_cast<re_detail::re_jump*>(j)->alt.i += size;
j->next.i += size; j->next.i += size;
break; break;
default: default:
@ -637,7 +637,7 @@ void BOOST_REGEX_CALL reg_expression<charT, traits, Allocator>::move_offsets(re_
} }
if(j->next.i == size) if(j->next.i == size)
break; break;
j = (re_detail::re_syntax_base*)((const char*)data.data() + j->next.i); j = reinterpret_cast<re_detail::re_syntax_base*>(reinterpret_cast<char*>(data.data()) + j->next.i);
} }
} }
@ -990,7 +990,7 @@ re_detail::re_syntax_base* BOOST_REGEX_CALL reg_expression<charT, traits, Alloca
++csingles; ++csingles;
const traits_string_type& s = singles.peek(); const traits_string_type& s = singles.peek();
unsigned len = (s.size() + 1) * sizeof(charT); unsigned len = (s.size() + 1) * sizeof(charT);
std::memcpy((charT*)data.extend(len), s.c_str(), len); std::memcpy(reinterpret_cast<charT*>(data.extend(len)), s.c_str(), len);
singles.pop(); singles.pop();
} }
while(ranges.empty() == false) while(ranges.empty() == false)
@ -1038,11 +1038,11 @@ re_detail::re_syntax_base* BOOST_REGEX_CALL reg_expression<charT, traits, Alloca
++cequivalents; ++cequivalents;
const traits_string_type& s = equivalents.peek(); const traits_string_type& s = equivalents.peek();
unsigned len = (re_detail::re_strlen(s.c_str()) + 1) * sizeof(charT); unsigned len = (re_detail::re_strlen(s.c_str()) + 1) * sizeof(charT);
std::memcpy((charT*)data.extend(len), s.c_str(), len); std::memcpy(reinterpret_cast<charT*>(data.extend(len)), s.c_str(), len);
equivalents.pop(); equivalents.pop();
} }
re_detail::re_set_long* dat = (re_detail::re_set_long*)((unsigned char*)data.data() + base); re_detail::re_set_long* dat = reinterpret_cast<re_detail::re_set_long*>(reinterpret_cast<unsigned char*>(data.data()) + base);
dat->type = re_detail::syntax_element_long_set; dat->type = re_detail::syntax_element_long_set;
dat->csingles = csingles; dat->csingles = csingles;
dat->cranges = cranges; dat->cranges = cranges;
@ -1056,7 +1056,7 @@ re_detail::re_syntax_base* BOOST_REGEX_CALL reg_expression<charT, traits, Alloca
template <class charT, class traits, class Allocator> template <class charT, class traits, class Allocator>
re_detail::re_syntax_base* BOOST_REGEX_CALL reg_expression<charT, traits, Allocator>::compile_set_aux(re_detail::jstack<traits_string_type, Allocator>& singles, re_detail::jstack<traits_string_type, Allocator>& ranges, re_detail::jstack<boost::uint_fast32_t, Allocator>& classes, re_detail::jstack<traits_string_type, Allocator>& equivalents, bool isnot, const re_detail::_narrow_type&) re_detail::re_syntax_base* BOOST_REGEX_CALL reg_expression<charT, traits, Allocator>::compile_set_aux(re_detail::jstack<traits_string_type, Allocator>& singles, re_detail::jstack<traits_string_type, Allocator>& ranges, re_detail::jstack<boost::uint_fast32_t, Allocator>& classes, re_detail::jstack<traits_string_type, Allocator>& equivalents, bool isnot, const re_detail::_narrow_type&)
{ {
re_detail::re_set* dat = (re_detail::re_set*)data.extend(sizeof(re_detail::re_set)); re_detail::re_set* dat = reinterpret_cast<re_detail::re_set*>(data.extend(sizeof(re_detail::re_set)));
std::memset(dat, 0, sizeof(re_detail::re_set)); std::memset(dat, 0, sizeof(re_detail::re_set));
while(singles.empty() == false) while(singles.empty() == false)
@ -1154,7 +1154,7 @@ inline
#endif #endif
re_detail::re_syntax_base* add_offset(void* base, std::ptrdiff_t off) re_detail::re_syntax_base* add_offset(void* base, std::ptrdiff_t off)
{ {
return (re_detail::re_syntax_base*)((char*)base + off); return reinterpret_cast<re_detail::re_syntax_base*>(reinterpret_cast<char*>(base) + off);
} }
@ -1163,7 +1163,7 @@ void BOOST_REGEX_CALL reg_expression<charT, traits, Allocator>::fixup_apply(re_d
{ {
typedef typename boost::detail::rebind_allocator<bool, Allocator>::type b_alloc; typedef typename boost::detail::rebind_allocator<bool, Allocator>::type b_alloc;
register unsigned char* base = (unsigned char*)b; register unsigned char* base = reinterpret_cast<unsigned char*>(b);
register re_detail::re_syntax_base* ptr = b; register re_detail::re_syntax_base* ptr = b;
bool* pb = 0; bool* pb = 0;
b_alloc a(data.allocator()); b_alloc a(data.allocator());
@ -1180,32 +1180,32 @@ void BOOST_REGEX_CALL reg_expression<charT, traits, Allocator>::fixup_apply(re_d
switch(ptr->type) switch(ptr->type)
{ {
case re_detail::syntax_element_rep: case re_detail::syntax_element_rep:
jm_assert(data.size() > ((re_detail::re_jump*)ptr)->alt.i); jm_assert(data.size() > static_cast<re_detail::re_jump*>(ptr)->alt.i);
((re_detail::re_jump*)ptr)->alt.p = add_offset(base, ((re_detail::re_jump*)ptr)->alt.i); static_cast<re_detail::re_jump*>(ptr)->alt.p = add_offset(base, static_cast<re_detail::re_jump*>(ptr)->alt.i);
#ifdef BOOST_REGEX_DEBUG #ifdef BOOST_REGEX_DEBUG
if((re_detail::padding_mask & (int)((re_detail::re_jump*)ptr)->alt.p) && (((re_detail::re_jump*)ptr)->alt.p != b)) if((re_detail::padding_mask & reinterpret_cast<int>(static_cast<re_detail::re_jump*>(ptr)->alt.p)) && (static_cast<re_detail::re_jump*>(ptr)->alt.p != b))
{ {
jm_trace("padding mis-aligment in repeat jump to object type: " << ((re_detail::re_jump*)ptr)->alt.p->type) jm_trace("padding mis-aligment in repeat jump to object type: " << static_cast<re_detail::re_jump*>(ptr)->alt.p->type)
//jm_assert(0 == (padding_mask & (int)((re_detail::re_jump*)ptr)->alt.p)); //jm_assert(0 == (padding_mask & (int)((re_detail::re_jump*)ptr)->alt.p));
} }
#endif #endif
((re_detail::re_repeat*)ptr)->id = repeats; static_cast<re_detail::re_repeat*>(ptr)->id = repeats;
++repeats; ++repeats;
goto rebase; goto rebase;
case re_detail::syntax_element_jump: case re_detail::syntax_element_jump:
case re_detail::syntax_element_alt: case re_detail::syntax_element_alt:
jm_assert(data.size() > ((re_detail::re_jump*)ptr)->alt.i); jm_assert(data.size() > static_cast<re_detail::re_jump*>(ptr)->alt.i);
((re_detail::re_jump*)ptr)->alt.p = add_offset(base, ((re_detail::re_jump*)ptr)->alt.i); static_cast<re_detail::re_jump*>(ptr)->alt.p = add_offset(base, static_cast<re_detail::re_jump*>(ptr)->alt.i);
#ifdef BOOST_REGEX_DEBUG #ifdef BOOST_REGEX_DEBUG
if((re_detail::padding_mask & (int)((re_detail::re_jump*)ptr)->alt.p) && (((re_detail::re_jump*)ptr)->alt.p != b)) if((re_detail::padding_mask & reinterpret_cast<int>(static_cast<re_detail::re_jump*>(ptr)->alt.p) && (static_cast<re_detail::re_jump*>(ptr)->alt.p != b)))
{ {
jm_trace("padding mis-aligment in alternation jump to object type: " << ((re_detail::re_jump*)ptr)->alt.p->type) jm_trace("padding mis-aligment in alternation jump to object type: " << static_cast<re_detail::re_jump*>(ptr)->alt.p->type)
//jm_assert(0 == (padding_mask & (int)((re_detail::re_jump*)ptr)->alt.p)); //jm_assert(0 == (padding_mask & (int)((re_detail::re_jump*)ptr)->alt.p));
} }
#endif #endif
goto rebase; goto rebase;
case re_detail::syntax_element_backref: case re_detail::syntax_element_backref:
if((((re_detail::re_brace*)ptr)->index >= cbraces) || (pb[((re_detail::re_brace*)ptr)->index] == false) ) if((static_cast<re_detail::re_brace*>(ptr)->index >= (int)cbraces) || (pb[static_cast<re_detail::re_brace*>(ptr)->index] == false) )
{ {
fail(REG_ESUBREG); fail(REG_ESUBREG);
a.deallocate(pb, cbraces); a.deallocate(pb, cbraces);
@ -1213,15 +1213,15 @@ void BOOST_REGEX_CALL reg_expression<charT, traits, Allocator>::fixup_apply(re_d
} }
goto rebase; goto rebase;
case re_detail::syntax_element_endmark: case re_detail::syntax_element_endmark:
if(((re_detail::re_brace*)ptr)->index > 0) if(static_cast<re_detail::re_brace*>(ptr)->index > 0)
pb[((re_detail::re_brace*)ptr)->index] = true; pb[static_cast<re_detail::re_brace*>(ptr)->index] = true;
goto rebase; goto rebase;
default: default:
rebase: rebase:
jm_assert(data.size() > ptr->next.i); jm_assert(data.size() > ptr->next.i);
ptr->next.p = add_offset(base, ptr->next.i); ptr->next.p = add_offset(base, ptr->next.i);
#ifdef BOOST_REGEX_DEBUG #ifdef BOOST_REGEX_DEBUG
if((re_detail::padding_mask & (int)(ptr->next.p)) && (((re_detail::re_jump*)ptr)->alt.p != b)) if((re_detail::padding_mask & (int)(ptr->next.p)) && (static_cast<re_detail::re_jump*>(ptr)->alt.p != b))
{ {
jm_trace("padding mis-alignment in next record of type " << ptr->next.p->type) jm_trace("padding mis-alignment in next record of type " << ptr->next.p->type)
jm_assert(0 == (re_detail::padding_mask & (int)(ptr->next.p))); jm_assert(0 == (re_detail::padding_mask & (int)(ptr->next.p)));
@ -1310,7 +1310,7 @@ unsigned int BOOST_REGEX_CALL reg_expression<charT, traits, Allocator>::set_expr
// extend: // extend:
dat = add_simple(dat, re_detail::syntax_element_startmark, sizeof(re_detail::re_brace)); dat = add_simple(dat, re_detail::syntax_element_startmark, sizeof(re_detail::re_brace));
markid.push(marks); markid.push(marks);
((re_detail::re_brace*)dat)->index = marks++; static_cast<re_detail::re_brace*>(dat)->index = marks++;
mark.push(data.index(dat)); mark.push(data.index(dat));
++ptr; ++ptr;
// //
@ -1326,14 +1326,14 @@ unsigned int BOOST_REGEX_CALL reg_expression<charT, traits, Allocator>::set_expr
switch(syntax) switch(syntax)
{ {
case traits_type::syntax_colon: case traits_type::syntax_colon:
((re_detail::re_brace*)dat)->index = 0; static_cast<re_detail::re_brace*>(dat)->index = 0;
--marks; --marks;
markid.pop(); markid.pop();
markid.push(0); markid.push(0);
++ptr; ++ptr;
continue; continue;
case traits_type::syntax_equal: case traits_type::syntax_equal:
((re_detail::re_brace*)dat)->index = -1; static_cast<re_detail::re_brace*>(dat)->index = -1;
markid.pop(); markid.pop();
markid.push(-1); markid.push(-1);
common_forward_assert: common_forward_assert:
@ -1346,17 +1346,17 @@ unsigned int BOOST_REGEX_CALL reg_expression<charT, traits, Allocator>::set_expr
// we don't know what value to put here yet, // we don't know what value to put here yet,
// use an arbitrarily large value for now // use an arbitrarily large value for now
// and check it later: // and check it later:
((re_detail::re_jump*)dat)->alt.i = INT_MAX/2; static_cast<re_detail::re_jump*>(dat)->alt.i = INT_MAX/2;
mark.push(data.size() - re_detail::re_jump_size); mark.push(data.size() - re_detail::re_jump_size);
continue; continue;
case traits_type::syntax_not: case traits_type::syntax_not:
((re_detail::re_brace*)dat)->index = -2; static_cast<re_detail::re_brace*>(dat)->index = -2;
markid.pop(); markid.pop();
markid.push(-2); markid.push(-2);
goto common_forward_assert; goto common_forward_assert;
case traits_type::syntax_hash: case traits_type::syntax_hash:
// comment just skip it: // comment just skip it:
((re_detail::re_brace*)dat)->index = 0; static_cast<re_detail::re_brace*>(dat)->index = 0;
--marks; --marks;
markid.pop(); markid.pop();
mark.pop(); mark.pop();
@ -1397,7 +1397,7 @@ unsigned int BOOST_REGEX_CALL reg_expression<charT, traits, Allocator>::set_expr
// see if we have an empty alternative: // see if we have an empty alternative:
if(mark.peek() == data.index(dat) ) if(mark.peek() == data.index(dat) )
{ {
re_detail::re_syntax_base* para = (re_detail::re_syntax_base*)((char*)data.data() + mark.peek()); re_detail::re_syntax_base* para = reinterpret_cast<re_detail::re_syntax_base*>(reinterpret_cast<char*>(data.data()) + mark.peek());
if(para->type == re_detail::syntax_element_jump) if(para->type == re_detail::syntax_element_jump)
{ {
fail(REG_EMPTY); fail(REG_EMPTY);
@ -1406,21 +1406,21 @@ unsigned int BOOST_REGEX_CALL reg_expression<charT, traits, Allocator>::set_expr
} }
// pop any pushed alternatives and set the target end destination: // pop any pushed alternatives and set the target end destination:
dat = (re_detail::re_syntax_base*)((unsigned char*)data.data() + mark.peek()); dat = reinterpret_cast<re_detail::re_syntax_base*>(reinterpret_cast<unsigned char*>(data.data()) + mark.peek());
while(dat->type == re_detail::syntax_element_jump) while(dat->type == re_detail::syntax_element_jump)
{ {
((re_detail::re_jump*)dat)->alt.i = data.size(); static_cast<re_detail::re_jump*>(dat)->alt.i = data.size();
mark.pop(); mark.pop();
if(mark.empty()) if(mark.empty())
{ {
fail(REG_EPAREN); fail(REG_EPAREN);
return error_code(); return error_code();
} }
dat = (re_detail::re_jump*)((unsigned char*)data.data() + mark.peek()); dat = reinterpret_cast<re_detail::re_jump*>(reinterpret_cast<unsigned char*>(data.data()) + mark.peek());
} }
dat = add_simple(0, re_detail::syntax_element_endmark, sizeof(re_detail::re_brace)); dat = add_simple(0, re_detail::syntax_element_endmark, sizeof(re_detail::re_brace));
((re_detail::re_brace*)dat)->index = markid.peek(); static_cast<re_detail::re_brace*>(dat)->index = markid.peek();
markid.pop(); markid.pop();
last_mark_popped = mark.peek(); last_mark_popped = mark.peek();
mark.pop(); mark.pop();
@ -1493,7 +1493,7 @@ unsigned int BOOST_REGEX_CALL reg_expression<charT, traits, Allocator>::set_expr
break; break;
} }
dat = add_simple(dat, re_detail::syntax_element_backref, sizeof(re_detail::re_brace)); dat = add_simple(dat, re_detail::syntax_element_backref, sizeof(re_detail::re_brace));
((re_detail::re_brace*)dat)->index = i; static_cast<re_detail::re_brace*>(dat)->index = i;
++ptr; ++ptr;
continue; continue;
} }
@ -1642,16 +1642,16 @@ unsigned int BOOST_REGEX_CALL reg_expression<charT, traits, Allocator>::set_expr
offset = last_mark_popped; offset = last_mark_popped;
break; break;
case re_detail::syntax_element_literal: case re_detail::syntax_element_literal:
if(((re_detail::re_literal*)dat)->length > 1) if(static_cast<re_detail::re_literal*>(dat)->length > 1)
{ {
// update previous: // update previous:
charT lit = *(charT*)((char*)dat + sizeof(re_detail::re_literal) + ((((re_detail::re_literal*)dat)->length-1)*sizeof(charT))); charT lit = *reinterpret_cast<charT*>(reinterpret_cast<char*>(dat) + sizeof(re_detail::re_literal) + ((static_cast<re_detail::re_literal*>(dat)->length-1)*sizeof(charT)));
--((re_detail::re_literal*)dat)->length; --static_cast<re_detail::re_literal*>(dat)->length;
dat = add_simple(dat, re_detail::syntax_element_literal, sizeof(re_detail::re_literal) + sizeof(charT)); dat = add_simple(dat, re_detail::syntax_element_literal, sizeof(re_detail::re_literal) + sizeof(charT));
((re_detail::re_literal*)dat)->length = 1; static_cast<re_detail::re_literal*>(dat)->length = 1;
*((charT*)(((re_detail::re_literal*)dat)+1)) = lit; *reinterpret_cast<charT*>(static_cast<re_detail::re_literal*>(dat)+1) = lit;
} }
offset = (char*)dat - (char*)data.data(); offset = reinterpret_cast<char*>(dat) - reinterpret_cast<char*>(data.data());
break; break;
case re_detail::syntax_element_backref: case re_detail::syntax_element_backref:
case re_detail::syntax_element_long_set: case re_detail::syntax_element_long_set:
@ -1659,7 +1659,7 @@ unsigned int BOOST_REGEX_CALL reg_expression<charT, traits, Allocator>::set_expr
case re_detail::syntax_element_wild: case re_detail::syntax_element_wild:
case re_detail::syntax_element_combining: case re_detail::syntax_element_combining:
// we're repeating a single item: // we're repeating a single item:
offset = (char*)dat - (char*)data.data(); offset = reinterpret_cast<char*>(dat) - reinterpret_cast<char*>(data.data());
break; break;
default: default:
fail(REG_BADRPT); fail(REG_BADRPT);
@ -1671,17 +1671,17 @@ unsigned int BOOST_REGEX_CALL reg_expression<charT, traits, Allocator>::set_expr
// add the trailing jump: // add the trailing jump:
dat = add_simple(dat, re_detail::syntax_element_jump, re_detail::re_jump_size); dat = add_simple(dat, re_detail::syntax_element_jump, re_detail::re_jump_size);
((re_detail::re_jump*)dat)->alt.i = 0; static_cast<re_detail::re_jump*>(dat)->alt.i = 0;
// now insert the leading repeater: // now insert the leading repeater:
dat = (re_detail::re_syntax_base*)data.insert(offset, re_detail::re_repeater_size); dat = static_cast<re_detail::re_syntax_base*>(data.insert(offset, re_detail::re_repeater_size));
dat->next.i = ((char*)dat - (char*)data.data()) + re_detail::re_repeater_size; dat->next.i = (reinterpret_cast<char*>(dat) - reinterpret_cast<char*>(data.data())) + re_detail::re_repeater_size;
dat->type = re_detail::syntax_element_rep; dat->type = re_detail::syntax_element_rep;
((re_detail::re_repeat*)dat)->alt.i = data.size(); static_cast<re_detail::re_repeat*>(dat)->alt.i = data.size();
((re_detail::re_repeat*)dat)->min = rep_min; static_cast<re_detail::re_repeat*>(dat)->min = rep_min;
((re_detail::re_repeat*)dat)->max = rep_max; static_cast<re_detail::re_repeat*>(dat)->max = rep_max;
((re_detail::re_repeat*)dat)->leading = false; static_cast<re_detail::re_repeat*>(dat)->leading = false;
((re_detail::re_repeat*)dat)->greedy = true; static_cast<re_detail::re_repeat*>(dat)->greedy = true;
move_offsets(dat, re_detail::re_repeater_size); move_offsets(dat, re_detail::re_repeater_size);
++ptr; ++ptr;
// //
@ -1692,12 +1692,12 @@ unsigned int BOOST_REGEX_CALL reg_expression<charT, traits, Allocator>::set_expr
if(traits_type::syntax_question == traits_inst.syntax_type(c)) if(traits_type::syntax_question == traits_inst.syntax_type(c))
{ {
// OK repeat is non-greedy: // OK repeat is non-greedy:
((re_detail::re_repeat*)dat)->greedy = false; static_cast<re_detail::re_repeat*>(dat)->greedy = false;
++ptr; ++ptr;
} }
} }
dat = (re_detail::re_syntax_base*)((char*)data.data() + data.size() - re_detail::re_jump_size); dat = reinterpret_cast<re_detail::re_syntax_base*>(reinterpret_cast<char*>(data.data()) + data.size() - re_detail::re_jump_size);
((re_detail::re_repeat*)dat)->alt.i = offset; static_cast<re_detail::re_repeat*>(dat)->alt.i = offset;
continue; continue;
} }
case traits_type::syntax_plus: case traits_type::syntax_plus:
@ -1768,7 +1768,7 @@ unsigned int BOOST_REGEX_CALL reg_expression<charT, traits, Allocator>::set_expr
// we don't know what value to put here yet, // we don't know what value to put here yet,
// use an arbitrarily large value for now // use an arbitrarily large value for now
// and check it later (TODO!) // and check it later (TODO!)
((re_detail::re_jump*)dat)->alt.i = INT_MAX/2; static_cast<re_detail::re_jump*>(dat)->alt.i = INT_MAX/2;
// now work out where to insert: // now work out where to insert:
unsigned int offset = 0; unsigned int offset = 0;
@ -1776,15 +1776,15 @@ unsigned int BOOST_REGEX_CALL reg_expression<charT, traits, Allocator>::set_expr
{ {
// we have a '(' or '|' to go back to: // we have a '(' or '|' to go back to:
offset = mark.peek(); offset = mark.peek();
re_detail::re_syntax_base* base = (re_detail::re_syntax_base*)((unsigned char*)data.data() + offset); re_detail::re_syntax_base* base = reinterpret_cast<re_detail::re_syntax_base*>(reinterpret_cast<unsigned char*>(data.data()) + offset);
offset = base->next.i; offset = base->next.i;
} }
re_detail::re_jump* j = (re_detail::re_jump*)data.insert(offset, re_detail::re_jump_size); re_detail::re_jump* j = static_cast<re_detail::re_jump*>(data.insert(offset, re_detail::re_jump_size));
j->type = re_detail::syntax_element_alt; j->type = re_detail::syntax_element_alt;
j->next.i = offset + re_detail::re_jump_size; j->next.i = offset + re_detail::re_jump_size;
j->alt.i = data.size(); j->alt.i = data.size();
move_offsets(j, re_detail::re_jump_size); move_offsets(j, re_detail::re_jump_size);
dat = (re_detail::re_syntax_base*)((unsigned char*)data.data() + data.size() - re_detail::re_jump_size); dat = reinterpret_cast<re_detail::re_syntax_base*>(reinterpret_cast<unsigned char*>(data.data()) + data.size() - re_detail::re_jump_size);
mark.push(data.size() - re_detail::re_jump_size); mark.push(data.size() - re_detail::re_jump_size);
++ptr; ++ptr;
break; break;
@ -1833,7 +1833,7 @@ unsigned int BOOST_REGEX_CALL reg_expression<charT, traits, Allocator>::set_expr
if(mark.empty() == false) if(mark.empty() == false)
if(mark.peek() == data.index(dat) ) if(mark.peek() == data.index(dat) )
{ {
re_detail::re_syntax_base* para = (re_detail::re_syntax_base*)((char*)data.data() + mark.peek()); re_detail::re_syntax_base* para = reinterpret_cast<re_detail::re_syntax_base*>(reinterpret_cast<char*>(data.data()) + mark.peek());
if(para->type == re_detail::syntax_element_jump) if(para->type == re_detail::syntax_element_jump)
{ {
fail(REG_EMPTY); fail(REG_EMPTY);
@ -1846,18 +1846,18 @@ unsigned int BOOST_REGEX_CALL reg_expression<charT, traits, Allocator>::set_expr
if(mark.empty() == false) if(mark.empty() == false)
{ {
// pop any pushed alternatives and set the target end destination: // pop any pushed alternatives and set the target end destination:
dat = (re_detail::re_syntax_base*)((unsigned char*)data.data() + mark.peek()); dat = reinterpret_cast<re_detail::re_syntax_base*>(reinterpret_cast<unsigned char*>(data.data()) + mark.peek());
while(dat->type == re_detail::syntax_element_jump) while(dat->type == re_detail::syntax_element_jump)
{ {
((re_detail::re_jump*)dat)->alt.i = data.size(); static_cast<re_detail::re_jump*>(dat)->alt.i = data.size();
mark.pop(); mark.pop();
if(mark.empty() == true) if(mark.empty() == true)
break; break;
dat = (re_detail::re_jump*)((unsigned char*)data.data() + mark.peek()); dat = reinterpret_cast<re_detail::re_jump*>(reinterpret_cast<unsigned char*>(data.data()) + mark.peek());
} }
} }
dat = (re_detail::re_brace*)data.extend(sizeof(re_detail::re_syntax_base)); dat = static_cast<re_detail::re_brace*>(data.extend(sizeof(re_detail::re_syntax_base)));
dat->type = re_detail::syntax_element_match; dat->type = re_detail::syntax_element_match;
dat->next.i = 0; dat->next.i = 0;
@ -1869,10 +1869,10 @@ unsigned int BOOST_REGEX_CALL reg_expression<charT, traits, Allocator>::set_expr
// //
// allocate space for start _map: // allocate space for start _map:
startmap = (unsigned char*)data.extend(256 + ((end - base + 1) * sizeof(charT))); startmap = reinterpret_cast<unsigned char*>(data.extend(256 + ((end - base + 1) * sizeof(charT))));
// //
// and copy the expression we just compiled: // and copy the expression we just compiled:
_expression = (charT*)((const char*)startmap + 256); _expression = reinterpret_cast<charT*>(reinterpret_cast<char*>(startmap) + 256);
_expression_len = end - base; _expression_len = end - base;
std::memcpy(_expression, base, _expression_len * sizeof(charT)); std::memcpy(_expression, base, _expression_len * sizeof(charT));
*(_expression + _expression_len) = charT(0); *(_expression + _expression_len) = charT(0);
@ -1880,7 +1880,7 @@ unsigned int BOOST_REGEX_CALL reg_expression<charT, traits, Allocator>::set_expr
// //
// now we need to apply fixups to the array // now we need to apply fixups to the array
// so that we can use pointers and not indexes // so that we can use pointers and not indexes
fixup_apply((re_detail::re_syntax_base*)data.data(), marks); fixup_apply(static_cast<re_detail::re_syntax_base*>(data.data()), marks);
// check for error during fixup: // check for error during fixup:
if(_flags & regbase::failbit) if(_flags & regbase::failbit)
@ -1895,7 +1895,7 @@ unsigned int BOOST_REGEX_CALL reg_expression<charT, traits, Allocator>::set_expr
re_detail::kmp_free(pkmp, data.allocator()); re_detail::kmp_free(pkmp, data.allocator());
pkmp = 0; pkmp = 0;
} }
re_detail::re_syntax_base* sbase = (re_detail::re_syntax_base*)data.data(); re_detail::re_syntax_base* sbase = static_cast<re_detail::re_syntax_base*>(data.data());
_restart_type = probe_restart(sbase); _restart_type = probe_restart(sbase);
_leading_len = fixup_leading_rep(sbase, 0); _leading_len = fixup_leading_rep(sbase, 0);
if((sbase->type == re_detail::syntax_element_literal) && (sbase->next.p->type == re_detail::syntax_element_match)) if((sbase->type == re_detail::syntax_element_literal) && (sbase->next.p->type == re_detail::syntax_element_match))
@ -1903,8 +1903,8 @@ unsigned int BOOST_REGEX_CALL reg_expression<charT, traits, Allocator>::set_expr
_restart_type = restart_fixed_lit; _restart_type = restart_fixed_lit;
if(0 == pkmp) if(0 == pkmp)
{ {
charT* p1 = (charT*)((char*)sbase + sizeof(re_detail::re_literal)); charT* p1 = reinterpret_cast<charT*>(reinterpret_cast<char*>(sbase) + sizeof(re_detail::re_literal));
charT* p2 = p1 + ((re_detail::re_literal*)sbase)->length; charT* p2 = p1 + static_cast<re_detail::re_literal*>(sbase)->length;
pkmp = re_detail::kmp_compile(p1, p2, charT(), re_detail::kmp_translator<traits>(_flags&regbase::icase, &traits_inst), data.allocator()); pkmp = re_detail::kmp_compile(p1, p2, charT(), re_detail::kmp_translator<traits>(_flags&regbase::icase, &traits_inst), data.allocator());
} }
} }
@ -1924,7 +1924,7 @@ re_detail::re_syntax_base* BOOST_REGEX_CALL reg_expression<charT, traits, Alloca
} }
if(size < sizeof(re_detail::re_syntax_base)) if(size < sizeof(re_detail::re_syntax_base))
size = sizeof(re_detail::re_syntax_base); size = sizeof(re_detail::re_syntax_base);
dat = (re_detail::re_syntax_base*)data.extend(size); dat = static_cast<re_detail::re_syntax_base*>(data.extend(size));
dat->type = type; dat->type = type;
dat->next.i = 0; dat->next.i = 0;
return dat; return dat;
@ -1936,17 +1936,17 @@ re_detail::re_syntax_base* BOOST_REGEX_CALL reg_expression<charT, traits, Alloca
if(dat && (dat->type == re_detail::syntax_element_literal)) if(dat && (dat->type == re_detail::syntax_element_literal))
{ {
// add another charT to the list: // add another charT to the list:
std::ptrdiff_t pos = (unsigned char*)dat - (unsigned char*)data.data(); std::ptrdiff_t pos = reinterpret_cast<unsigned char*>(dat) - reinterpret_cast<unsigned char*>(data.data());
*(charT*)data.extend(sizeof(charT)) = traits_inst.translate(c, (_flags & regbase::icase)); *reinterpret_cast<charT*>(data.extend(sizeof(charT))) = traits_inst.translate(c, (_flags & regbase::icase));
dat = (re_detail::re_syntax_base*)((unsigned char*)data.data() + pos); dat = reinterpret_cast<re_detail::re_syntax_base*>(reinterpret_cast<unsigned char*>(data.data()) + pos);
++(((re_detail::re_literal*)dat)->length); ++(static_cast<re_detail::re_literal*>(dat)->length);
} }
else else
{ {
// extend: // extend:
dat = add_simple(dat, re_detail::syntax_element_literal, sizeof(re_detail::re_literal) + sizeof(charT)); dat = add_simple(dat, re_detail::syntax_element_literal, sizeof(re_detail::re_literal) + sizeof(charT));
((re_detail::re_literal*)dat)->length = 1; static_cast<re_detail::re_literal*>(dat)->length = 1;
*((charT*)(((re_detail::re_literal*)dat)+1)) = traits_inst.translate(c, (_flags & regbase::icase)); *reinterpret_cast<charT*>(reinterpret_cast<re_detail::re_literal*>(dat)+1) = traits_inst.translate(c, (_flags & regbase::icase));
} }
return dat; return dat;
} }
@ -1982,15 +1982,15 @@ unsigned int BOOST_REGEX_CALL reg_expression<charT, traits, Allocator>::fixup_le
switch(dat->type) switch(dat->type)
{ {
case re_detail::syntax_element_literal: case re_detail::syntax_element_literal:
len += ((re_detail::re_literal*)dat)->length; len += static_cast<re_detail::re_literal*>(dat)->length;
if((leading_lit) && (((re_detail::re_literal*)dat)->length > 2)) if((leading_lit) && (static_cast<re_detail::re_literal*>(dat)->length > 2))
{ {
// we can do a literal search for the leading literal string // we can do a literal search for the leading literal string
// using Knuth-Morris-Pratt (or whatever), and only then check for // using Knuth-Morris-Pratt (or whatever), and only then check for
// matches. We need a decent length string though to make it // matches. We need a decent length string though to make it
// worth while. // worth while.
_leading_string = (charT*)((char*)dat + sizeof(re_detail::re_literal)); _leading_string = reinterpret_cast<charT*>(reinterpret_cast<char*>(dat) + sizeof(re_detail::re_literal));
_leading_string_len = ((re_detail::re_literal*)dat)->length; _leading_string_len = static_cast<re_detail::re_literal*>(dat)->length;
_restart_type = restart_lit; _restart_type = restart_lit;
leading_lit = false; leading_lit = false;
const charT* p1 = _leading_string; const charT* p1 = _leading_string;
@ -2014,8 +2014,8 @@ unsigned int BOOST_REGEX_CALL reg_expression<charT, traits, Allocator>::fixup_le
{ {
// we need to verify that there are no multi-character // we need to verify that there are no multi-character
// collating elements inside the repeat: // collating elements inside the repeat:
const charT* p = (const charT*)((const char*)dat + sizeof(re_detail::re_set_long)); const charT* p = reinterpret_cast<const charT*>(reinterpret_cast<const char*>(dat) + sizeof(re_detail::re_set_long));
unsigned int csingles = ((re_detail::re_set_long*)dat)->csingles; unsigned int csingles = static_cast<re_detail::re_set_long*>(dat)->csingles;
for(unsigned int i = 0; i < csingles; ++i) for(unsigned int i = 0; i < csingles; ++i)
{ {
if(re_detail::re_strlen(p) > 1) if(re_detail::re_strlen(p) > 1)
@ -2032,9 +2032,9 @@ unsigned int BOOST_REGEX_CALL reg_expression<charT, traits, Allocator>::fixup_le
leading_lit = false; leading_lit = false;
break; break;
case re_detail::syntax_element_rep: case re_detail::syntax_element_rep:
if((len == 0) && (1 == fixup_leading_rep(dat->next.p, ((re_detail::re_repeat*)dat)->alt.p) )) if((len == 0) && (1 == fixup_leading_rep(dat->next.p, static_cast<re_detail::re_repeat*>(dat)->alt.p) ))
{ {
((re_detail::re_repeat*)dat)->leading = true; static_cast<re_detail::re_repeat*>(dat)->leading = true;
return len; return len;
} }
return len; return len;

View File

@ -50,7 +50,7 @@ template <class charT, class Allocator>
void kmp_free(kmp_info<charT>* pinfo, const Allocator& a) void kmp_free(kmp_info<charT>* pinfo, const Allocator& a)
{ {
typedef typename boost::detail::rebind_allocator<char, Allocator>::type atype; typedef typename boost::detail::rebind_allocator<char, Allocator>::type atype;
atype(a).deallocate((char*)pinfo, pinfo->size); atype(a).deallocate(reinterpret_cast<char*>(pinfo), pinfo->size);
} }
template <class iterator, class charT, class Trans, class Allocator> template <class iterator, class charT, class Trans, class Allocator>
@ -66,10 +66,10 @@ kmp_info<charT>* kmp_compile(iterator first, iterator last, charT, Trans transla
// //
// allocate struct and fill it in: // allocate struct and fill it in:
// //
kmp_info<charT>* pinfo = (kmp_info<charT>*)atype(a).allocate(size); kmp_info<charT>* pinfo = reinterpret_cast<kmp_info<charT>*>(atype(a).allocate(size));
pinfo->size = size; pinfo->size = size;
pinfo->len = m; pinfo->len = m;
charT* p = (charT*)((char*)pinfo + sizeof(kmp_info<charT>) + sizeof(int)*(m+1)); charT* p = reinterpret_cast<charT*>(reinterpret_cast<char*>(pinfo) + sizeof(kmp_info<charT>) + sizeof(int)*(m+1));
pinfo->pstr = p; pinfo->pstr = p;
while(first != last) while(first != last)
{ {

View File

@ -58,10 +58,10 @@ inline int string_compare(const std::wstring& s, const wchar_t* p)
template <class iterator, class charT, class traits_type, class Allocator> template <class iterator, class charT, class traits_type, class Allocator>
iterator BOOST_REGEX_CALL re_is_set_member(iterator next, iterator BOOST_REGEX_CALL re_is_set_member(iterator next,
iterator last, iterator last,
re_set_long* set_, const re_set_long* set_,
const reg_expression<charT, traits_type, Allocator>& e) const reg_expression<charT, traits_type, Allocator>& e)
{ {
const charT* p = (const charT*)(set_+1); const charT* p = reinterpret_cast<const charT*>(set_+1);
iterator ptr; iterator ptr;
unsigned int i; unsigned int i;
bool icase = e.flags() & regbase::icase; bool icase = e.flags() & regbase::icase;
@ -359,13 +359,13 @@ bool query_match_aux(iterator first,
goto failure; goto failure;
case syntax_element_startmark: case syntax_element_startmark:
start_mark_jump: start_mark_jump:
if(((re_brace*)ptr)->index > 0) if(static_cast<const re_brace*>(ptr)->index > 0)
{ {
temp_match.set_first(first, ((re_brace*)ptr)->index); temp_match.set_first(first, static_cast<const re_brace*>(ptr)->index);
} }
else if( else if(
(((re_brace*)ptr)->index == -1) (static_cast<const re_brace*>(ptr)->index == -1)
|| (((re_brace*)ptr)->index == -2) || (static_cast<const re_brace*>(ptr)->index == -2)
) )
{ {
matches.push(temp_match); matches.push(temp_match);
@ -385,13 +385,13 @@ bool query_match_aux(iterator first,
break; break;
case syntax_element_endmark: case syntax_element_endmark:
end_mark_jump: end_mark_jump:
if(((re_brace*)ptr)->index > 0) if(static_cast<const re_brace*>(ptr)->index > 0)
{ {
temp_match.set_second(first, ((re_brace*)ptr)->index); temp_match.set_second(first, static_cast<const re_brace*>(ptr)->index);
} }
else if( else if(
(((re_brace*)ptr)->index == -1) (static_cast<const re_brace*>(ptr)->index == -1)
|| (((re_brace*)ptr)->index == -2) || (static_cast<const re_brace*>(ptr)->index == -2)
) )
{ {
match_found = true; match_found = true;
@ -402,8 +402,8 @@ bool query_match_aux(iterator first,
break; break;
case syntax_element_literal: case syntax_element_literal:
{ {
unsigned int len = ((re_literal*)ptr)->length; unsigned int len = static_cast<const re_literal*>(ptr)->length;
charT* what = (charT*)(((re_literal*)ptr) + 1); const charT* what = reinterpret_cast<const charT*>(static_cast<const re_literal*>(ptr) + 1);
// //
// compare string with what we stored in // compare string with what we stored in
// our records: // our records:
@ -582,8 +582,8 @@ bool query_match_aux(iterator first,
case syntax_element_backref: case syntax_element_backref:
{ {
// compare with what we previously matched: // compare with what we previously matched:
iterator i = temp_match[((re_brace*)ptr)->index].first; iterator i = temp_match[static_cast<const re_brace*>(ptr)->index].first;
iterator j = temp_match[((re_brace*)ptr)->index].second; iterator j = temp_match[static_cast<const re_brace*>(ptr)->index].second;
while(i != j) while(i != j)
{ {
if((first == last) || (traits_inst.translate(*first, icase) != traits_inst.translate(*i, icase))) if((first == last) || (traits_inst.translate(*first, icase) != traits_inst.translate(*i, icase)))
@ -597,7 +597,7 @@ bool query_match_aux(iterator first,
case syntax_element_long_set: case syntax_element_long_set:
{ {
// let the traits class do the work: // let the traits class do the work:
iterator t = re_is_set_member(first, last, (re_set_long*)ptr, e); iterator t = re_is_set_member(first, last, static_cast<const re_set_long*>(ptr), e);
if(t != first) if(t != first)
{ {
ptr = ptr->next.p; ptr = ptr->next.p;
@ -608,7 +608,7 @@ bool query_match_aux(iterator first,
} }
case syntax_element_set: case syntax_element_set:
// lookup character in table: // lookup character in table:
if(((re_set*)ptr)->_map[(traits_uchar_type)traits_inst.translate(*first, icase)]) if(static_cast<const re_set*>(ptr)->_map[(traits_uchar_type)traits_inst.translate(*first, icase)])
{ {
ptr = ptr->next.p; ptr = ptr->next.p;
++first; ++first;
@ -616,16 +616,16 @@ bool query_match_aux(iterator first,
} }
goto failure; goto failure;
case syntax_element_jump: case syntax_element_jump:
ptr = ((re_jump*)ptr)->alt.p; ptr = static_cast<const re_jump*>(ptr)->alt.p;
continue; continue;
case syntax_element_alt: case syntax_element_alt:
{ {
// alt_jump: // alt_jump:
if(access::can_start(*first, ((re_jump*)ptr)->_map, (unsigned char)mask_take)) if(access::can_start(*first, static_cast<const re_jump*>(ptr)->_map, (unsigned char)mask_take))
{ {
// we can take the first alternative, // we can take the first alternative,
// see if we need to push next alternative: // see if we need to push next alternative:
if(access::can_start(*first, ((re_jump*)ptr)->_map, mask_skip)) if(access::can_start(*first, static_cast<const re_jump*>(ptr)->_map, mask_skip))
{ {
if(need_push_match) if(need_push_match)
matches.push(temp_match); matches.push(temp_match);
@ -640,9 +640,9 @@ bool query_match_aux(iterator first,
ptr = ptr->next.p; ptr = ptr->next.p;
continue; continue;
} }
if(access::can_start(*first, ((re_jump*)ptr)->_map, mask_skip)) if(access::can_start(*first, static_cast<const re_jump*>(ptr)->_map, mask_skip))
{ {
ptr = ((re_jump*)ptr)->alt.p; ptr = static_cast<const re_jump*>(ptr)->alt.p;
continue; continue;
} }
goto failure; // neither option is possible goto failure; // neither option is possible
@ -652,16 +652,16 @@ bool query_match_aux(iterator first,
// repeater_jump: // repeater_jump:
// if we're moving to a higher id (nested repeats etc) // if we're moving to a higher id (nested repeats etc)
// zero out our accumualtors: // zero out our accumualtors:
if(cur_acc < ((re_repeat*)ptr)->id) if(cur_acc < static_cast<const re_repeat*>(ptr)->id)
{ {
cur_acc = ((re_repeat*)ptr)->id; cur_acc = static_cast<const re_repeat*>(ptr)->id;
accumulators[cur_acc] = 0; accumulators[cur_acc] = 0;
start_loop[cur_acc] = first; start_loop[cur_acc] = first;
} }
cur_acc = ((re_repeat*)ptr)->id; cur_acc = static_cast<const re_repeat*>(ptr)->id;
if(((re_repeat*)ptr)->leading) if(static_cast<const re_repeat*>(ptr)->leading)
*restart = first; *restart = first;
//charT c = traits_inst.translate(*first); //charT c = traits_inst.translate(*first);
@ -670,17 +670,17 @@ bool query_match_aux(iterator first,
// if that is the case then repeat as many times as possible, // if that is the case then repeat as many times as possible,
// as long as the repeat is greedy: // as long as the repeat is greedy:
if((((re_repeat*)ptr)->alt.p->type == syntax_element_match) if((static_cast<const re_repeat*>(ptr)->alt.p->type == syntax_element_match)
&& (((re_repeat*)ptr)->greedy == true)) && (static_cast<const re_repeat*>(ptr)->greedy == true))
{ {
// see if we can take the repeat: // see if we can take the repeat:
if(((unsigned int)accumulators[cur_acc] < ((re_repeat*)ptr)->max) if(((unsigned int)accumulators[cur_acc] < static_cast<const re_repeat*>(ptr)->max)
&& access::can_start(*first, ((re_repeat*)ptr)->_map, mask_take)) && access::can_start(*first, static_cast<const re_repeat*>(ptr)->_map, mask_take))
{ {
// push terminating match as fallback: // push terminating match as fallback:
if((unsigned int)accumulators[cur_acc] >= ((re_repeat*)ptr)->min) if((unsigned int)accumulators[cur_acc] >= static_cast<const re_repeat*>(ptr)->min)
{ {
if((prev_record.empty() == false) && (prev_record.peek() == ((re_repeat*)ptr)->alt.p)) if((prev_record.empty() == false) && (prev_record.peek() == static_cast<const re_repeat*>(ptr)->alt.p))
{ {
// we already have the required fallback // we already have the required fallback
// don't add any more, just update this one: // don't add any more, just update this one:
@ -693,7 +693,7 @@ bool query_match_aux(iterator first,
if(need_push_match) if(need_push_match)
matches.push(temp_match); matches.push(temp_match);
prev_pos.push(first); prev_pos.push(first);
prev_record.push(((re_repeat*)ptr)->alt.p); prev_record.push(static_cast<const re_repeat*>(ptr)->alt.p);
} }
} }
// move to next item in list: // move to next item in list:
@ -707,10 +707,10 @@ bool query_match_aux(iterator first,
goto failure; goto failure;
} }
// see if we can skip the repeat: // see if we can skip the repeat:
if(((unsigned int)accumulators[cur_acc] >= ((re_repeat*)ptr)->min) if(((unsigned int)accumulators[cur_acc] >= static_cast<const re_repeat*>(ptr)->min)
&& access::can_start(*first, ((re_repeat*)ptr)->_map, mask_skip)) && access::can_start(*first, static_cast<const re_repeat*>(ptr)->_map, mask_skip))
{ {
ptr = ((re_repeat*)ptr)->alt.p; ptr = static_cast<const re_repeat*>(ptr)->alt.p;
continue; continue;
} }
// otherwise fail: // otherwise fail:
@ -719,16 +719,16 @@ bool query_match_aux(iterator first,
// OK if we get to here then the repeat is either non-terminal or non-greedy, // OK if we get to here then the repeat is either non-terminal or non-greedy,
// see if we can skip the repeat: // see if we can skip the repeat:
if(((unsigned int)accumulators[cur_acc] >= ((re_repeat*)ptr)->min) if(((unsigned int)accumulators[cur_acc] >= static_cast<const re_repeat*>(ptr)->min)
&& access::can_start(*first, ((re_repeat*)ptr)->_map, mask_skip)) && access::can_start(*first, static_cast<const re_repeat*>(ptr)->_map, mask_skip))
{ {
// see if we can push failure info: // see if we can push failure info:
if(((unsigned int)accumulators[cur_acc] < ((re_repeat*)ptr)->max) if(((unsigned int)accumulators[cur_acc] < static_cast<const re_repeat*>(ptr)->max)
&& access::can_start(*first, ((re_repeat*)ptr)->_map, mask_take)) && access::can_start(*first, static_cast<const re_repeat*>(ptr)->_map, mask_take))
{ {
// check to see if the last loop matched a NULL string // check to see if the last loop matched a NULL string
// if so then we really don't want to loop again: // if so then we really don't want to loop again:
if(((unsigned int)accumulators[cur_acc] == ((re_repeat*)ptr)->min) if(((unsigned int)accumulators[cur_acc] == static_cast<const re_repeat*>(ptr)->min)
|| (first != start_loop[cur_acc])) || (first != start_loop[cur_acc]))
{ {
if(need_push_match) if(need_push_match)
@ -738,20 +738,20 @@ bool query_match_aux(iterator first,
for(k = 0; k <= cur_acc; ++k) for(k = 0; k <= cur_acc; ++k)
prev_acc.push(accumulators[k]); prev_acc.push(accumulators[k]);
// for non-greedy repeats save whether we have a match already: // for non-greedy repeats save whether we have a match already:
if(((re_repeat*)ptr)->greedy == false) if(static_cast<const re_repeat*>(ptr)->greedy == false)
{ {
prev_acc.push(match_found); prev_acc.push(match_found);
match_found = false; match_found = false;
} }
} }
} }
ptr = ((re_repeat*)ptr)->alt.p; ptr = static_cast<const re_repeat*>(ptr)->alt.p;
continue; continue;
} }
// otherwise see if we can take the repeat: // otherwise see if we can take the repeat:
if(((unsigned int)accumulators[cur_acc] < ((re_repeat*)ptr)->max) if(((unsigned int)accumulators[cur_acc] < static_cast<const re_repeat*>(ptr)->max)
&& access::can_start(*first, ((re_repeat*)ptr)->_map, mask_take) && && access::can_start(*first, static_cast<const re_repeat*>(ptr)->_map, mask_take) &&
((first != start_loop[cur_acc]) || !accumulators[cur_acc])) ((first != start_loop[cur_acc]) || !accumulators[cur_acc]))
{ {
// move to next item in list: // move to next item in list:
@ -841,7 +841,7 @@ bool query_match_aux(iterator first,
ptr = ptr->next.p; ptr = ptr->next.p;
break; break;
case syntax_element_jump: case syntax_element_jump:
ptr = ((re_jump*)ptr)->alt.p; ptr = static_cast<const re_jump*>(ptr)->alt.p;
continue; continue;
case syntax_element_alt: case syntax_element_alt:
if(ptr->can_be_null & mask_take) if(ptr->can_be_null & mask_take)
@ -865,33 +865,33 @@ bool query_match_aux(iterator first,
} }
if(ptr->can_be_null & mask_skip) if(ptr->can_be_null & mask_skip)
{ {
ptr = ((re_jump*)ptr)->alt.p; ptr = static_cast<const re_jump*>(ptr)->alt.p;
continue; continue;
} }
goto failure; // neither option is possible goto failure; // neither option is possible
case syntax_element_rep: case syntax_element_rep:
// if we're moving to a higher id (nested repeats etc) // if we're moving to a higher id (nested repeats etc)
// zero out our accumualtors: // zero out our accumualtors:
if(cur_acc < ((re_repeat*)ptr)->id) if(cur_acc < static_cast<const re_repeat*>(ptr)->id)
{ {
cur_acc = ((re_repeat*)ptr)->id; cur_acc = static_cast<const re_repeat*>(ptr)->id;
accumulators[cur_acc] = 0; accumulators[cur_acc] = 0;
start_loop[cur_acc] = first; start_loop[cur_acc] = first;
} }
cur_acc = ((re_repeat*)ptr)->id; cur_acc = static_cast<const re_repeat*>(ptr)->id;
// see if we can skip the repeat: // see if we can skip the repeat:
if(((unsigned int)accumulators[cur_acc] >= ((re_repeat*)ptr)->min) if(((unsigned int)accumulators[cur_acc] >= static_cast<const re_repeat*>(ptr)->min)
&& ((ptr->can_be_null & mask_skip) || (flags & match_partial))) && ((ptr->can_be_null & mask_skip) || (flags & match_partial)))
{ {
// don't push failure info, there's no point: // don't push failure info, there's no point:
ptr = ((re_repeat*)ptr)->alt.p; ptr = static_cast<const re_repeat*>(ptr)->alt.p;
continue; continue;
} }
// otherwise see if we can take the repeat: // otherwise see if we can take the repeat:
if(((unsigned int)accumulators[cur_acc] < ((re_repeat*)ptr)->max) if(((unsigned int)accumulators[cur_acc] < static_cast<const re_repeat*>(ptr)->max)
&& (((ptr->can_be_null & (mask_take | mask_skip)) == (mask_take | mask_skip))) || (flags & match_partial)) && (((ptr->can_be_null & (mask_take | mask_skip)) == (mask_take | mask_skip))) || (flags & match_partial))
{ {
// move to next item in list: // move to next item in list:
@ -935,7 +935,7 @@ bool query_match_aux(iterator first,
{ {
case syntax_element_alt: case syntax_element_alt:
// get next alternative: // get next alternative:
ptr = ((re_jump*)ptr)->alt.p; ptr = static_cast<const re_jump*>(ptr)->alt.p;
if(need_push_match) if(need_push_match)
matches.pop(temp_match); matches.pop(temp_match);
prev_acc.pop(cur_acc); prev_acc.pop(cur_acc);
@ -955,8 +955,8 @@ bool query_match_aux(iterator first,
if(need_push_match) if(need_push_match)
matches.pop(temp_match); matches.pop(temp_match);
prev_pos.pop(first); prev_pos.pop(first);
cur_acc = ((re_repeat*)ptr)->id; cur_acc = static_cast<const re_repeat*>(ptr)->id;
if(((re_repeat*)ptr)->greedy == false) if(static_cast<const re_repeat*>(ptr)->greedy == false)
{ {
saved_matched = prev_acc.peek(); saved_matched = prev_acc.peek();
prev_acc.pop(); prev_acc.pop();
@ -965,11 +965,11 @@ bool query_match_aux(iterator first,
prev_acc.pop(accumulators[k]); prev_acc.pop(accumulators[k]);
prev_record.pop(); prev_record.pop();
if(unwind_stack) goto failure; // unwinding forward assert if(unwind_stack) goto failure; // unwinding forward assert
if((unsigned int)++accumulators[cur_acc] > ((re_repeat*)ptr)->max) if((unsigned int)++accumulators[cur_acc] > static_cast<const re_repeat*>(ptr)->max)
goto failure; // repetions exhausted. goto failure; // repetions exhausted.
// //
// if the repeat is non-greedy, and we found a match then fail again: // if the repeat is non-greedy, and we found a match then fail again:
if((((re_repeat*)ptr)->greedy == false) && (match_found == true)) if((static_cast<const re_repeat*>(ptr)->greedy == false) && (match_found == true))
{ {
goto failure; goto failure;
} }

View File

@ -157,7 +157,7 @@ public:
size_type BOOST_REGEX_CALL index(void* ptr) size_type BOOST_REGEX_CALL index(void* ptr)
{ {
return (unsigned char*)ptr - (unsigned char*)data(); return reinterpret_cast<unsigned char*>(ptr) - reinterpret_cast<unsigned char*>(data());
} }
void BOOST_REGEX_CALL clear() void BOOST_REGEX_CALL clear()
@ -168,7 +168,7 @@ public:
void BOOST_REGEX_CALL align() void BOOST_REGEX_CALL align()
{ {
// move end up to a boundary: // move end up to a boundary:
end = (unsigned char*)start + ((((unsigned char*)end - (unsigned char*)start) + padding_mask) & ~padding_mask); end = reinterpret_cast<unsigned char*>(start) + (((reinterpret_cast<unsigned char*>(end) - reinterpret_cast<unsigned char*>(start)) + padding_mask) & ~padding_mask);
} }
Allocator BOOST_REGEX_CALL allocator()const; Allocator BOOST_REGEX_CALL allocator()const;

View File

@ -84,8 +84,8 @@ public:
node* BOOST_REGEX_CALL get_node() node* BOOST_REGEX_CALL get_node()
{ {
node* new_stack = (node*)alloc_inst.allocate(sizeof(node) + sizeof(T) * block_size); node* new_stack = reinterpret_cast<node*>(alloc_inst.allocate(sizeof(node) + sizeof(T) * block_size));
new_stack->last = (T*)(new_stack+1); new_stack->last = reinterpret_cast<T*>(new_stack+1);
new_stack->start = new_stack->end = new_stack->last + block_size; new_stack->start = new_stack->end = new_stack->last + block_size;
new_stack->next = 0; new_stack->next = 0;
return new_stack; return new_stack;
@ -196,13 +196,13 @@ jstack<T, Allocator>::~jstack()
{ {
condemned = unused; condemned = unused;
unused = unused->next; unused = unused->next;
alloc_inst.deallocate((unsigned char*)condemned, sizeof(node) + sizeof(T) * block_size); alloc_inst.deallocate(reinterpret_cast<unsigned char*>(condemned), sizeof(node) + sizeof(T) * block_size);
} }
while(m_stack != &base) while(m_stack != &base)
{ {
condemned = m_stack; condemned = m_stack;
m_stack = m_stack->next; m_stack = m_stack->next;
alloc_inst.deallocate((unsigned char*)condemned, sizeof(node) + sizeof(T) * block_size); alloc_inst.deallocate(reinterpret_cast<unsigned char*>(condemned), sizeof(node) + sizeof(T) * block_size);
} }
} }