mirror of
https://github.com/boostorg/regex.git
synced 2025-07-17 06:12:10 +02:00
changed all pointer casts to explicit static_cast or reinterpret_cast.
Added more tests for forward lookahead asserts. [SVN r12575]
This commit is contained in:
@ -178,7 +178,7 @@ unsigned int BOOST_REGEX_CALL _re_get_message(char* buf, unsigned int len, unsig
|
||||
template <class charT>
|
||||
unsigned int BOOST_REGEX_CALL re_get_message(charT* buf, unsigned int len, unsigned int id)
|
||||
{
|
||||
unsigned int size = _re_get_message((char*)0, 0, id);
|
||||
unsigned int size = _re_get_message(static_cast<char*>(0), 0, id);
|
||||
if(len < size)
|
||||
return size;
|
||||
boost::scoped_array<char> cb(new char[size]);
|
||||
@ -451,7 +451,7 @@ void BOOST_REGEX_CALL c_traits_base::do_update_ctype()
|
||||
for(i = 1; i < syntax_max; ++i)
|
||||
{
|
||||
char* ptr = buf;
|
||||
re_get_message((char*)buf, map_size, i+100);
|
||||
re_get_message(static_cast<char*>(buf), map_size, i+100);
|
||||
for(; *ptr; ++ptr)
|
||||
{
|
||||
syntax_map[(unsigned char)*ptr] = (unsigned char)i;
|
||||
@ -556,7 +556,7 @@ bool BOOST_REGEX_CALL c_regex_traits<wchar_t>::lookup_collatename(std::basic_str
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
std::basic_string<wchar_t> s(first, last);
|
||||
unsigned int len = strnarrow((char*)0, 0, s.c_str());
|
||||
unsigned int len = strnarrow(static_cast<char*>(0), 0, s.c_str());
|
||||
scoped_array<char> buf(new char[len]);
|
||||
strnarrow(buf.get(), len, s.c_str());
|
||||
std::string t_out;
|
||||
@ -566,7 +566,7 @@ bool BOOST_REGEX_CALL c_regex_traits<wchar_t>::lookup_collatename(std::basic_str
|
||||
{
|
||||
if(t_out[0])
|
||||
{
|
||||
len = strwiden((wchar_t*)0, 0, t_out.c_str());
|
||||
len = strwiden(static_cast<wchar_t*>(0), 0, t_out.c_str());
|
||||
scoped_array<wchar_t> wb(new wchar_t[len]);
|
||||
strwiden(wb.get(), len, t_out.c_str());
|
||||
out = wb.get();
|
||||
@ -778,14 +778,14 @@ bool BOOST_REGEX_CALL c_regex_traits<wchar_t>::do_lookup_collate(std::basic_stri
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
std::basic_string<wchar_t> s(first, last);
|
||||
unsigned int len = strnarrow((char*)0, 0, s.c_str());
|
||||
unsigned int len = strnarrow(static_cast<char*>(0), 0, s.c_str());
|
||||
scoped_array<char> buf(new char[len]);
|
||||
strnarrow(buf.get(), len, s.c_str());
|
||||
std::string t_out;
|
||||
bool result = base_type::do_lookup_collate(t_out, buf.get());
|
||||
if(result)
|
||||
{
|
||||
len = strwiden((wchar_t*)0, 0, t_out.c_str());
|
||||
len = strwiden(static_cast<wchar_t*>(0), 0, t_out.c_str());
|
||||
scoped_array<wchar_t> wb(new wchar_t[len]);
|
||||
strwiden(wb.get(), len, t_out.c_str());
|
||||
out = wb.get();
|
||||
@ -833,7 +833,7 @@ void BOOST_REGEX_CALL c_regex_traits<wchar_t>::update()
|
||||
for(i = 1; i < syntax_max; ++i)
|
||||
{
|
||||
wchar_t* ptr = buf;
|
||||
re_get_message((wchar_t*)buf, 256, i+100);
|
||||
re_get_message(static_cast<wchar_t*>(buf), 256, i+100);
|
||||
for(; *ptr; ++ptr)
|
||||
{
|
||||
sm.c = *ptr;
|
||||
@ -988,7 +988,7 @@ int BOOST_REGEX_CALL c_regex_traits<wchar_t>::toi(const wchar_t*& first, const w
|
||||
boost::uint_fast32_t BOOST_REGEX_CALL c_regex_traits<wchar_t>::lookup_classname(const wchar_t* first, const wchar_t* last)
|
||||
{
|
||||
std::basic_string<wchar_t> s(first, last);
|
||||
unsigned int len = strnarrow((char*)0, 0, s.c_str());
|
||||
unsigned int len = strnarrow(static_cast<char*>(0), 0, s.c_str());
|
||||
scoped_array<char> buf(new char[len]);
|
||||
strnarrow(buf.get(), len, s.c_str());
|
||||
len = do_lookup_class(buf.get());
|
||||
|
@ -333,7 +333,7 @@ int BOOST_REGEX_CALL cpp_regex_traits<char>::toi(char c)const
|
||||
|
||||
int BOOST_REGEX_CALL cpp_regex_traits<char>::toi(const char*& first, const char* last, int radix)const
|
||||
{
|
||||
pmd->sbuf.pubsetbuf((char*)first, last-first);
|
||||
pmd->sbuf.pubsetbuf(const_cast<char*>(first), last-first);
|
||||
pmd->is.clear();
|
||||
if(std::abs(radix) == 16) pmd->is >> std::hex;
|
||||
else if(std::abs(radix) == 8) pmd->is >> std::oct;
|
||||
@ -706,7 +706,7 @@ int BOOST_REGEX_CALL cpp_regex_traits<wchar_t>::toi(wchar_t c)const
|
||||
|
||||
int BOOST_REGEX_CALL cpp_regex_traits<wchar_t>::toi(const wchar_t*& first, const wchar_t* last, int radix)const
|
||||
{
|
||||
pmd->sbuf.pubsetbuf((wchar_t*)first, last-first);
|
||||
pmd->sbuf.pubsetbuf(const_cast<wchar_t*>(first), last-first);
|
||||
pmd->is.clear();
|
||||
if(std::abs(radix) == 16) pmd->is >> std::hex;
|
||||
else if(std::abs(radix) == 8) pmd->is >> std::oct;
|
||||
|
@ -83,7 +83,7 @@ void mapfile::open(const char* file)
|
||||
hfile = 0;
|
||||
throw std::runtime_error("Unable to create file mapping.");
|
||||
}
|
||||
_first = (const char*)MapViewOfFile(hmap, FILE_MAP_READ, 0, 0, 0);
|
||||
_first = static_cast<const char*>(MapViewOfFile(hmap, FILE_MAP_READ, 0, 0, 0));
|
||||
if(_first == 0)
|
||||
{
|
||||
CloseHandle(hmap);
|
||||
@ -227,7 +227,7 @@ void mapfile::lock(pointer* node)const
|
||||
if(condemed.empty())
|
||||
{
|
||||
*node = new char[sizeof(int) + buf_size];
|
||||
*((int*)(*node)) = 1;
|
||||
*(reinterpret_cast<int*>(*node)) = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -235,7 +235,7 @@ void mapfile::lock(pointer* node)const
|
||||
condemed.pop_front();
|
||||
*node = *p;
|
||||
*p = 0;
|
||||
*((int*)(*node)) = 1;
|
||||
*(reinterpret_cast<int*>(*node)) = 1;
|
||||
}
|
||||
std::fseek(hfile, (node - _first) * buf_size, SEEK_SET);
|
||||
if(node == _last - 1)
|
||||
@ -245,13 +245,13 @@ void mapfile::lock(pointer* node)const
|
||||
}
|
||||
else
|
||||
{
|
||||
if(*((int*)(*node)) == 0)
|
||||
if(*reinterpret_cast<int*>(*node) == 0)
|
||||
{
|
||||
*((int*)(*node)) = 1;
|
||||
*reinterpret_cast<int*>(*node) = 1;
|
||||
condemed.remove(node);
|
||||
}
|
||||
else
|
||||
++(*((int*)(*node)));
|
||||
++(*reinterpret_cast<int*>(*node));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -263,7 +263,7 @@ void mapfile::unlock(pointer* node)const
|
||||
assert(node <= _last);
|
||||
if(node < _last)
|
||||
{
|
||||
if(--(*((int*)(*node))) == 0)
|
||||
if(--(*reinterpret_cast<int*>(*node)) == 0)
|
||||
{
|
||||
condemed.push_back(node);
|
||||
}
|
||||
|
@ -79,9 +79,9 @@ BOOST_REGEX_DECL int BOOST_REGEX_CCALL regcompA(regex_tA* expression, const char
|
||||
|
||||
try{
|
||||
expression->re_magic = magic_value;
|
||||
((regex*)(expression->guts))->set_expression(ptr, p2, flags);
|
||||
expression->re_nsub = ((regex*)(expression->guts))->mark_count() - 1;
|
||||
result = ((regex*)(expression->guts))->error_code();
|
||||
static_cast<regex*>(expression->guts)->set_expression(ptr, p2, flags);
|
||||
expression->re_nsub = static_cast<regex*>(expression->guts)->mark_count() - 1;
|
||||
result = static_cast<regex*>(expression->guts)->error_code();
|
||||
} catch(...)
|
||||
{
|
||||
result = REG_E_UNKNOWN;
|
||||
@ -132,7 +132,7 @@ BOOST_REGEX_DECL unsigned int BOOST_REGEX_CCALL regerrorA(int code, const regex_
|
||||
{
|
||||
std::string p;
|
||||
if((e) && (e->re_magic == magic_value))
|
||||
p = ((regex*)(e->guts))->get_traits().error_string(code);
|
||||
p = static_cast<regex*>(e->guts)->get_traits().error_string(code);
|
||||
else
|
||||
{
|
||||
boost::regex_traits<char> t;
|
||||
@ -177,7 +177,7 @@ BOOST_REGEX_DECL int BOOST_REGEX_CCALL regexecA(const regex_tA* expression, cons
|
||||
try{
|
||||
if(expression->re_magic == magic_value)
|
||||
{
|
||||
result = regex_search(start, end, m, *(regex*)(expression->guts), flags);
|
||||
result = regex_search(start, end, m, *static_cast<regex*>(expression->guts), flags);
|
||||
}
|
||||
else
|
||||
return result;
|
||||
@ -211,7 +211,7 @@ BOOST_REGEX_DECL void BOOST_REGEX_CCALL regfreeA(regex_tA* expression)
|
||||
BOOST_RE_GUARD_STACK
|
||||
if(expression->re_magic == magic_value)
|
||||
{
|
||||
delete (regex*)(expression->guts);
|
||||
delete static_cast<regex*>(expression->guts);
|
||||
}
|
||||
expression->re_magic = 0;
|
||||
}
|
||||
|
@ -165,7 +165,7 @@ unsigned int BOOST_REGEX_CALL _re_get_message(char* buf, unsigned int len, unsig
|
||||
template <class charT>
|
||||
unsigned int BOOST_REGEX_CALL get_message(charT* buf, unsigned int len, unsigned int id)
|
||||
{
|
||||
unsigned int size = _re_get_message((char*)0, 0, id);
|
||||
unsigned int size = _re_get_message(static_cast<char*>(0), 0, id);
|
||||
if(len < size)
|
||||
return size;
|
||||
boost::scoped_array<char> cb(new char[size]);
|
||||
@ -577,7 +577,7 @@ bool BOOST_REGEX_CALL w32_regex_traits<wchar_t>::lookup_collatename(std::basic_s
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
std::basic_string<wchar_t> s(first, last);
|
||||
unsigned int len = strnarrow((char*)0, 0, s.c_str());
|
||||
unsigned int len = strnarrow(static_cast<char*>(0), 0, s.c_str());
|
||||
scoped_array<char> buf(new char[len]);
|
||||
strnarrow(buf.get(), len, s.c_str());
|
||||
std::string t_out;
|
||||
@ -587,7 +587,7 @@ bool BOOST_REGEX_CALL w32_regex_traits<wchar_t>::lookup_collatename(std::basic_s
|
||||
{
|
||||
if(t_out[0])
|
||||
{
|
||||
len = strwiden((wchar_t*)0, 0, t_out.c_str());
|
||||
len = strwiden(static_cast<wchar_t*>(0), 0, t_out.c_str());
|
||||
scoped_array<wchar_t> wb(new wchar_t[len]);
|
||||
strwiden(wb.get(), len, t_out.c_str());
|
||||
out = wb.get();
|
||||
@ -606,7 +606,7 @@ unsigned int BOOST_REGEX_CALL w32_regex_traits<wchar_t>::syntax_type(size_type c
|
||||
last = syntax->end();
|
||||
while(first != last)
|
||||
{
|
||||
if((uchar_type)(*first).c == c)
|
||||
if((size_type)(uchar_type)((*first).c) == c)
|
||||
return (*first).type;
|
||||
++first;
|
||||
}
|
||||
@ -617,14 +617,14 @@ bool BOOST_REGEX_CALL w32_regex_traits<wchar_t>::do_lookup_collate(std::basic_st
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
std::basic_string<wchar_t> s(first, last);
|
||||
unsigned int len = strnarrow((char*)0, 0, s.c_str());
|
||||
unsigned int len = strnarrow(static_cast<char*>(0), 0, s.c_str());
|
||||
scoped_array<char> buf(new char[len]);
|
||||
strnarrow(buf.get(), len, s.c_str());
|
||||
std::string t_out;
|
||||
bool result = base_type::do_lookup_collate(t_out, buf.get());
|
||||
if(result)
|
||||
{
|
||||
len = strwiden((wchar_t*)0, 0, t_out.c_str());
|
||||
len = strwiden(static_cast<wchar_t*>(0), 0, t_out.c_str());
|
||||
scoped_array<wchar_t> wb(new wchar_t[len]);
|
||||
strwiden(wb.get(), len, t_out.c_str());
|
||||
out = wb.get();
|
||||
@ -690,7 +690,7 @@ void BOOST_REGEX_CALL w32_regex_traits<wchar_t>::transform(std::basic_string<wch
|
||||
n = LCMapStringW(GetUserDefaultLCID(), LCMAP_SORTKEY, in.c_str(), -1, 0, 0);
|
||||
else
|
||||
{
|
||||
n = strnarrow((char*)0, 0, in.c_str());
|
||||
n = strnarrow(static_cast<char*>(0), 0, in.c_str());
|
||||
alt.reset(new char[n+1]);
|
||||
strnarrow(alt.get(), n+1, in.c_str());
|
||||
n = LCMapStringA(GetUserDefaultLCID(), LCMAP_SORTKEY, alt.get(), -1, 0, 0);
|
||||
@ -707,7 +707,7 @@ void BOOST_REGEX_CALL w32_regex_traits<wchar_t>::transform(std::basic_string<wch
|
||||
// the sort order remains unchanged when we compare.
|
||||
scoped_array<char> t(new char[n+1]);
|
||||
if(isPlatformNT)
|
||||
n = LCMapStringW(GetUserDefaultLCID(), LCMAP_SORTKEY, in.c_str(), -1, (wchar_t*)t.get(), n);
|
||||
n = LCMapStringW(GetUserDefaultLCID(), LCMAP_SORTKEY, in.c_str(), -1, reinterpret_cast<wchar_t*>(t.get()), n);
|
||||
else
|
||||
n = LCMapStringA(GetUserDefaultLCID(), LCMAP_SORTKEY, alt.get(), -1, t.get(), n);
|
||||
int i = -1;
|
||||
@ -780,7 +780,7 @@ int BOOST_REGEX_CALL w32_regex_traits<wchar_t>::toi(const wchar_t*& first, const
|
||||
boost::uint_fast32_t BOOST_REGEX_CALL w32_regex_traits<wchar_t>::lookup_classname(const wchar_t* first, const wchar_t* last)
|
||||
{
|
||||
std::basic_string<wchar_t> s(first, last);
|
||||
unsigned int len = strnarrow((char*)0, 0, s.c_str());
|
||||
unsigned int len = strnarrow(static_cast<char*>(0), 0, s.c_str());
|
||||
scoped_array<char> buf(new char[len]);
|
||||
strnarrow(buf.get(), len, s.c_str());
|
||||
len = do_lookup_class(buf.get());
|
||||
@ -791,7 +791,7 @@ wchar_t BOOST_REGEX_CALL w32_regex_traits<wchar_t>::wtolower(wchar_t c)
|
||||
{
|
||||
BOOST_RE_GUARD_STACK
|
||||
if(isPlatformNT)
|
||||
return LOWORD(CharLowerW((wchar_t*)(MAKELONG(c, 0))));
|
||||
return LOWORD(CharLowerW(reinterpret_cast<wchar_t*>(static_cast<unsigned short>(c))));
|
||||
return c;
|
||||
}
|
||||
|
||||
|
@ -87,9 +87,9 @@ BOOST_REGEX_DECL int BOOST_REGEX_CCALL regcompW(regex_tW* expression, const wcha
|
||||
|
||||
try{
|
||||
expression->re_magic = wmagic_value;
|
||||
((wregex*)(expression->guts))->set_expression(ptr, p2, flags);
|
||||
expression->re_nsub = ((wregex*)(expression->guts))->mark_count() - 1;
|
||||
result = ((wregex*)(expression->guts))->error_code();
|
||||
static_cast<wregex*>(expression->guts)->set_expression(ptr, p2, flags);
|
||||
expression->re_nsub = static_cast<wregex*>(expression->guts)->mark_count() - 1;
|
||||
result = static_cast<wregex*>(expression->guts)->error_code();
|
||||
} catch(...)
|
||||
{
|
||||
result = REG_E_UNKNOWN;
|
||||
@ -143,10 +143,10 @@ BOOST_REGEX_DECL unsigned int BOOST_REGEX_CCALL regerrorW(int code, const regex_
|
||||
regex_traits<wchar_t> rt;
|
||||
const regex_traits<wchar_t>* pt = &rt;
|
||||
if(e && (e->re_magic == wmagic_value))
|
||||
pt = &((wregex*)(e->guts))->get_traits();
|
||||
pt = &static_cast<wregex*>(e->guts)->get_traits();
|
||||
(void)pt; // warning suppression
|
||||
std::string p = pt->error_string(code);
|
||||
unsigned int len = pt->strwiden((wchar_t*)0, 0, p.c_str());
|
||||
unsigned int len = pt->strwiden(static_cast<wchar_t*>(0), 0, p.c_str());
|
||||
if(len < buf_size)
|
||||
{
|
||||
pt->strwiden(buf, buf_size, p.c_str());
|
||||
@ -185,7 +185,7 @@ BOOST_REGEX_DECL int BOOST_REGEX_CCALL regexecW(const regex_tW* expression, cons
|
||||
try{
|
||||
if(expression->re_magic == wmagic_value)
|
||||
{
|
||||
result = regex_search(start, end, m, *(wregex*)(expression->guts), flags);
|
||||
result = regex_search(start, end, m, *static_cast<wregex*>(expression->guts), flags);
|
||||
}
|
||||
else
|
||||
return result;
|
||||
@ -219,7 +219,7 @@ BOOST_REGEX_DECL void BOOST_REGEX_CCALL regfreeW(regex_tW* expression)
|
||||
BOOST_RE_GUARD_STACK
|
||||
if(expression->re_magic == wmagic_value)
|
||||
{
|
||||
delete (wregex*)(expression->guts);
|
||||
delete static_cast<wregex*>(expression->guts);
|
||||
}
|
||||
expression->re_magic = 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user