diff --git a/src/c_regex_traits.cpp b/src/c_regex_traits.cpp index c41a0260..4f2ae209 100644 --- a/src/c_regex_traits.cpp +++ b/src/c_regex_traits.cpp @@ -178,7 +178,7 @@ unsigned int BOOST_REGEX_CALL _re_get_message(char* buf, unsigned int len, unsig template 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(0), 0, id); if(len < size) return size; boost::scoped_array 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(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::lookup_collatename(std::basic_str { BOOST_RE_GUARD_STACK std::basic_string s(first, last); - unsigned int len = strnarrow((char*)0, 0, s.c_str()); + unsigned int len = strnarrow(static_cast(0), 0, s.c_str()); scoped_array 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::lookup_collatename(std::basic_str { if(t_out[0]) { - len = strwiden((wchar_t*)0, 0, t_out.c_str()); + len = strwiden(static_cast(0), 0, t_out.c_str()); scoped_array 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::do_lookup_collate(std::basic_stri { BOOST_RE_GUARD_STACK std::basic_string s(first, last); - unsigned int len = strnarrow((char*)0, 0, s.c_str()); + unsigned int len = strnarrow(static_cast(0), 0, s.c_str()); scoped_array 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(0), 0, t_out.c_str()); scoped_array 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::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(buf), 256, i+100); for(; *ptr; ++ptr) { sm.c = *ptr; @@ -988,7 +988,7 @@ int BOOST_REGEX_CALL c_regex_traits::toi(const wchar_t*& first, const w boost::uint_fast32_t BOOST_REGEX_CALL c_regex_traits::lookup_classname(const wchar_t* first, const wchar_t* last) { std::basic_string s(first, last); - unsigned int len = strnarrow((char*)0, 0, s.c_str()); + unsigned int len = strnarrow(static_cast(0), 0, s.c_str()); scoped_array buf(new char[len]); strnarrow(buf.get(), len, s.c_str()); len = do_lookup_class(buf.get()); diff --git a/src/cpp_regex_traits.cpp b/src/cpp_regex_traits.cpp index e5b93163..6beb0a07 100644 --- a/src/cpp_regex_traits.cpp +++ b/src/cpp_regex_traits.cpp @@ -333,7 +333,7 @@ int BOOST_REGEX_CALL cpp_regex_traits::toi(char c)const int BOOST_REGEX_CALL cpp_regex_traits::toi(const char*& first, const char* last, int radix)const { - pmd->sbuf.pubsetbuf((char*)first, last-first); + pmd->sbuf.pubsetbuf(const_cast(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::toi(wchar_t c)const int BOOST_REGEX_CALL cpp_regex_traits::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(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; diff --git a/src/fileiter.cpp b/src/fileiter.cpp index 5eca80a5..3a4b9c86 100644 --- a/src/fileiter.cpp +++ b/src/fileiter.cpp @@ -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(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(*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(*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(*node) == 0) { - *((int*)(*node)) = 1; + *reinterpret_cast(*node) = 1; condemed.remove(node); } else - ++(*((int*)(*node))); + ++(*reinterpret_cast(*node)); } } } @@ -263,7 +263,7 @@ void mapfile::unlock(pointer* node)const assert(node <= _last); if(node < _last) { - if(--(*((int*)(*node))) == 0) + if(--(*reinterpret_cast(*node)) == 0) { condemed.push_back(node); } diff --git a/src/posix_api.cpp b/src/posix_api.cpp index fc467511..f64755a0 100644 --- a/src/posix_api.cpp +++ b/src/posix_api.cpp @@ -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(expression->guts)->set_expression(ptr, p2, flags); + expression->re_nsub = static_cast(expression->guts)->mark_count() - 1; + result = static_cast(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(e->guts)->get_traits().error_string(code); else { boost::regex_traits 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(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(expression->guts); } expression->re_magic = 0; } diff --git a/src/w32_regex_traits.cpp b/src/w32_regex_traits.cpp index 0549c3bb..07e62fee 100644 --- a/src/w32_regex_traits.cpp +++ b/src/w32_regex_traits.cpp @@ -165,7 +165,7 @@ unsigned int BOOST_REGEX_CALL _re_get_message(char* buf, unsigned int len, unsig template 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(0), 0, id); if(len < size) return size; boost::scoped_array cb(new char[size]); @@ -577,7 +577,7 @@ bool BOOST_REGEX_CALL w32_regex_traits::lookup_collatename(std::basic_s { BOOST_RE_GUARD_STACK std::basic_string s(first, last); - unsigned int len = strnarrow((char*)0, 0, s.c_str()); + unsigned int len = strnarrow(static_cast(0), 0, s.c_str()); scoped_array 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::lookup_collatename(std::basic_s { if(t_out[0]) { - len = strwiden((wchar_t*)0, 0, t_out.c_str()); + len = strwiden(static_cast(0), 0, t_out.c_str()); scoped_array 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::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::do_lookup_collate(std::basic_st { BOOST_RE_GUARD_STACK std::basic_string s(first, last); - unsigned int len = strnarrow((char*)0, 0, s.c_str()); + unsigned int len = strnarrow(static_cast(0), 0, s.c_str()); scoped_array 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(0), 0, t_out.c_str()); scoped_array 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::transform(std::basic_string(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::transform(std::basic_string 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(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::toi(const wchar_t*& first, const boost::uint_fast32_t BOOST_REGEX_CALL w32_regex_traits::lookup_classname(const wchar_t* first, const wchar_t* last) { std::basic_string s(first, last); - unsigned int len = strnarrow((char*)0, 0, s.c_str()); + unsigned int len = strnarrow(static_cast(0), 0, s.c_str()); scoped_array 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::wtolower(wchar_t c) { BOOST_RE_GUARD_STACK if(isPlatformNT) - return LOWORD(CharLowerW((wchar_t*)(MAKELONG(c, 0)))); + return LOWORD(CharLowerW(reinterpret_cast(static_cast(c)))); return c; } diff --git a/src/wide_posix_api.cpp b/src/wide_posix_api.cpp index 059a286c..7db03d6a 100644 --- a/src/wide_posix_api.cpp +++ b/src/wide_posix_api.cpp @@ -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(expression->guts)->set_expression(ptr, p2, flags); + expression->re_nsub = static_cast(expression->guts)->mark_count() - 1; + result = static_cast(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 rt; const regex_traits* pt = &rt; if(e && (e->re_magic == wmagic_value)) - pt = &((wregex*)(e->guts))->get_traits(); + pt = &static_cast(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(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(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(expression->guts); } expression->re_magic = 0; } diff --git a/test/regress/tests.cpp b/test/regress/tests.cpp index bbcaf67d..559a2cc2 100644 --- a/test/regress/tests.cpp +++ b/test/regress/tests.cpp @@ -365,7 +365,7 @@ void cpp_tests(const reg_expression& e, bool recurse = true) } } } - if((false == recurse) && (matches[0] == 0) && (matches[1] == search_text.size())) + if((false == recurse) && (matches[0] == 0) && (matches[1] == static_cast(search_text.size()))) { // // match expected on whole string, so all versions diff --git a/test/regress/tests.txt b/test/regress/tests.txt index 60f7e460..e93f8a67 100644 --- a/test/regress/tests.txt +++ b/test/regress/tests.txt @@ -871,7 +871,7 @@ a+(?#b+)b+ xaaabbba 1 7 ; ; forward lookahead asserts added 21/01/02 -- match_default normal REG_EXTENDED +- match_default normal REG_EXTENDED REG_NO_POSIX_TEST ((?:(?!a|b)\w)+)(\w+) " xxxabaxxx " 2 11 2 5 5 11 /\*(?:(?!\*/).)*\*/ " /**/ " 2 6 @@ -885,3 +885,18 @@ a+(?#b+)b+ xaaabbba 1 7 <\s*a[^>]*>((?:(?!<\s*/\s*a\s*>).)*)(?=<\s*/\s*a\s*>) " here " 1 20 16 20 <\s*a[^>]*>((?:(?!<\s*/\s*a\s*>).)*)(?=<\s*/\s*a\s*>) " here< / a > " 1 20 16 20 +; filename matching: +^(?!^(?:PRN|AUX|CLOCK\$|NUL|CON|COM\d|LPT\d|\..*)(?:\..+)?$)[^\x00-\x1f\\?*:\"|/]+$ command.com 0 11 +^(?!^(?:PRN|AUX|CLOCK\$|NUL|CON|COM\d|LPT\d|\..*)(?:\..+)?$)[^\x00-\x1f\\?*:\"|/]+$ PRN -1 -1 +^(?!^(?:PRN|AUX|CLOCK\$|NUL|CON|COM\d|LPT\d|\..*)(?:\..+)?$)[^\x00-\x1f\\?*:\"|/]+$ COM2 -1 -1 + +; password checking: +^(?=.*\d).{4,8}$ abc3 0 4 +^(?=.*\d).{4,8}$ abc3def4 0 8 +^(?=.*\d).{4,8}$ ab2 -1 -1 +^(?=.*\d).{4,8}$ abcdefg -1 -1 +^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{4,8}$ abc3 -1 -1 +^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{4,8}$ abC3 0 4 +^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{4,8}$ ABCD3 -1 -1 + +