diff --git a/include/boost/cregex.hpp b/include/boost/cregex.hpp index 2cb2b5a4..3a6f4502 100644 --- a/include/boost/cregex.hpp +++ b/include/boost/cregex.hpp @@ -36,7 +36,13 @@ namespace boost{ extern "C" { #endif -typedef int regoff_t; +#if defined(__cplusplus) && !defined(BOOST_NO_STDC_NAMESPACE) +typedef std::ptrdiff_t regoff_t; +typedef std::size_t regsize_t; +#else +typedef ptrdiff_t regoff_t; +typedef size_t regsize_t; +#endif typedef struct { @@ -97,14 +103,14 @@ typedef enum{ } reg_exec_flags; BOOST_REGEX_DECL int BOOST_REGEX_CCALL regcompA(regex_tA*, const char*, int); -BOOST_REGEX_DECL unsigned int BOOST_REGEX_CCALL regerrorA(int, const regex_tA*, char*, unsigned int); -BOOST_REGEX_DECL int BOOST_REGEX_CCALL regexecA(const regex_tA*, const char*, unsigned int, regmatch_t*, int); +BOOST_REGEX_DECL regsize_t BOOST_REGEX_CCALL regerrorA(int, const regex_tA*, char*, regsize_t); +BOOST_REGEX_DECL int BOOST_REGEX_CCALL regexecA(const regex_tA*, const char*, regsize_t, regmatch_t*, int); BOOST_REGEX_DECL void BOOST_REGEX_CCALL regfreeA(regex_tA*); #ifndef BOOST_NO_WREGEX BOOST_REGEX_DECL int BOOST_REGEX_CCALL regcompW(regex_tW*, const wchar_t*, int); -BOOST_REGEX_DECL unsigned int BOOST_REGEX_CCALL regerrorW(int, const regex_tW*, wchar_t*, unsigned int); -BOOST_REGEX_DECL int BOOST_REGEX_CCALL regexecW(const regex_tW*, const wchar_t*, unsigned int, regmatch_t*, int); +BOOST_REGEX_DECL regsize_t BOOST_REGEX_CCALL regerrorW(int, const regex_tW*, wchar_t*, regsize_t); +BOOST_REGEX_DECL int BOOST_REGEX_CCALL regexecW(const regex_tW*, const wchar_t*, regsize_t, regmatch_t*, int); BOOST_REGEX_DECL void BOOST_REGEX_CCALL regfreeW(regex_tW*); #endif @@ -254,8 +260,8 @@ public: unsigned int Grep(GrepCallback cb, const std::string& s, unsigned int flags = match_default) { return Grep(cb, s.c_str(), flags); } unsigned int Grep(std::vector& v, const char* p, unsigned int flags = match_default); unsigned int Grep(std::vector& v, const std::string& s, unsigned int flags = match_default) { return Grep(v, s.c_str(), flags); } - unsigned int Grep(std::vector& v, const char* p, unsigned int flags = match_default); - unsigned int Grep(std::vector& v, const std::string& s, unsigned int flags = match_default) { return Grep(v, s.c_str(), flags); } + unsigned int Grep(std::vector& v, const char* p, unsigned int flags = match_default); + unsigned int Grep(std::vector& v, const std::string& s, unsigned int flags = match_default) { return Grep(v, s.c_str(), flags); } unsigned int GrepFiles(GrepFileCallback cb, const char* files, bool recurse = false, unsigned int flags = match_default); unsigned int GrepFiles(GrepFileCallback cb, const std::string& files, bool recurse = false, unsigned int flags = match_default) { return GrepFiles(cb, files.c_str(), recurse, flags); } unsigned int FindFiles(FindFilesCallback cb, const char* files, bool recurse = false, unsigned int flags = match_default); @@ -266,12 +272,12 @@ public: std::string Merge(const char* in, const char* fmt, bool copy = true, unsigned int flags = match_default); - unsigned int Split(std::vector& v, std::string& s, unsigned flags = match_default, unsigned max_count = ~0); + std::size_t Split(std::vector& v, std::string& s, unsigned flags = match_default, unsigned max_count = ~0); // // now operators for returning what matched in more detail: // - unsigned int Position(int i = 0)const; - unsigned int Length(int i = 0)const; + std::size_t Position(int i = 0)const; + std::size_t Length(int i = 0)const; bool Matched(int i = 0)const; unsigned int Line()const; unsigned int Marks()const; diff --git a/include/boost/regex.hpp b/include/boost/regex.hpp index 3c2ae0a0..6d00503b 100644 --- a/include/boost/regex.hpp +++ b/include/boost/regex.hpp @@ -199,7 +199,7 @@ std::ostream& operator<<(std::ostream&, syntax_element_type); union offset_type { re_syntax_base* p; - unsigned i; + std::size_t i; }; // @@ -660,10 +660,10 @@ private: unsigned marks; int repeats; unsigned char* startmap; - unsigned _expression_len; - unsigned int _leading_len; + std::size_t _expression_len; + std::size_t _leading_len; const charT* _leading_string; - unsigned int _leading_string_len; + std::size_t _leading_string_len; re_detail::kmp_info* pkmp; unsigned error_code_; charT* _expression; @@ -698,7 +698,7 @@ protected: { return (const re_detail::re_syntax_base*)e.data.data(); } static const unsigned char* BOOST_REGEX_CALL get_map(const reg_expression& e) { return e.startmap; } - static unsigned int BOOST_REGEX_CALL leading_length(const reg_expression& e) + static std::size_t BOOST_REGEX_CALL leading_length(const reg_expression& e) { return e._leading_len; } static const re_detail::kmp_info* get_kmp(const reg_expression& e) { return e.pkmp; } @@ -744,7 +744,7 @@ struct sub_match operator std::basic_string ()const { std::basic_string result; - unsigned len = boost::re_detail::distance((iterator)first, (iterator)second); + std::size_t len = boost::re_detail::distance((iterator)first, (iterator)second); result.reserve(len); iterator i = first; while(i != second) @@ -877,7 +877,7 @@ protected: struct c_reference : public c_alloc { - unsigned int cmatches; + std::size_t cmatches; unsigned count; sub_match head, tail, null; unsigned int lines; @@ -1298,11 +1298,11 @@ void BOOST_REGEX_CALL match_results_base::maybe_assign(cons p1 = (sub_match*)(ref+1); p2 = (sub_match*)(m.ref+1); iterator base = (*this)[-1].first; - unsigned int len1 = 0; - unsigned int len2 = 0; - unsigned int base1 = 0; - unsigned int base2 = 0; - unsigned int i; + std::size_t len1 = 0; + std::size_t len2 = 0; + std::size_t base1 = 0; + std::size_t base2 = 0; + std::size_t i; for(i = 0; i < ref->cmatches; ++i) { // diff --git a/include/boost/regex/config.hpp b/include/boost/regex/config.hpp index ec43aead..768589d1 100644 --- a/include/boost/regex/config.hpp +++ b/include/boost/regex/config.hpp @@ -85,6 +85,7 @@ // do C++ specific things in future... // # include +# include # ifdef _MSC_VER # define BOOST_MSVC _MSC_VER # endif @@ -277,6 +278,18 @@ using std::distance; # include #endif +#ifdef MAXPATH +# define BOOST_REGEX_MAX_PATH MAXPATH +#elif defined(MAX_PATH) +# define BOOST_REGEX_MAX_PATH MAX_PATH +#elif defined(FILENAME_MAX) +# define BOOST_REGEX_MAX_PATH FILENAME_MAX +#else +# define BOOST_REGEX_MAX_PATH 200 +#endif + + + /***************************************************************************** * * Error Handling for exception free compilers: @@ -568,7 +581,7 @@ namespace boost{ namespace re_detail{ template inline void pointer_destroy(T* p) -{ p->~T(); } +{ p->~T(); (void)p; } template inline void pointer_construct(T* p, const T& t) diff --git a/include/boost/regex/detail/regex_compile.hpp b/include/boost/regex/detail/regex_compile.hpp index df3914c4..687ea1fe 100644 --- a/include/boost/regex/detail/regex_compile.hpp +++ b/include/boost/regex/detail/regex_compile.hpp @@ -711,7 +711,7 @@ re_detail::re_syntax_base* BOOST_REGEX_CALL reg_expression(data.extend(len)), s.c_str(), len); singles.pop(); } @@ -1023,7 +1023,7 @@ re_detail::re_syntax_base* BOOST_REGEX_CALL reg_expression(data.extend(len)), s.c_str(), len); equivalents.pop(); } @@ -1272,9 +1272,9 @@ unsigned int BOOST_REGEX_CALL reg_expression::set_expr const charT* ptr = p; marks = 0; - re_detail::jstack mark(64, data.allocator()); + re_detail::jstack mark(64, data.allocator()); re_detail::jstack markid(64, data.allocator()); - unsigned int last_mark_popped = 0; + std::size_t last_mark_popped = 0; register traits_size_type c; register re_detail::re_syntax_base* dat; @@ -1635,7 +1635,7 @@ unsigned int BOOST_REGEX_CALL reg_expression::set_expr repeat_jump: { - unsigned offset; + std::ptrdiff_t offset; if(dat == 0) { fail(REG_BADRPT); @@ -1776,7 +1776,7 @@ unsigned int BOOST_REGEX_CALL reg_expression::set_expr static_cast(dat)->alt.i = INT_MAX/2; // now work out where to insert: - unsigned int offset = 0; + std::size_t offset = 0; if(mark.empty() == false) { // we have a '(' or '|' to go back to: diff --git a/include/boost/regex/detail/regex_kmp.hpp b/include/boost/regex/detail/regex_kmp.hpp index 3572858b..97b5c348 100644 --- a/include/boost/regex/detail/regex_kmp.hpp +++ b/include/boost/regex/detail/regex_kmp.hpp @@ -40,10 +40,10 @@ namespace boost{ template struct kmp_info { - unsigned int size; - unsigned int len; + std::size_t size; + std::size_t len; const charT* pstr; - int kmp_next[1]; + std::ptrdiff_t kmp_next[1]; }; template @@ -57,11 +57,11 @@ template kmp_info* kmp_compile(iterator first, iterator last, charT, Trans translate, const Allocator& a) { typedef typename boost::detail::rebind_allocator::type atype; - int i, j, m; + std::ptrdiff_t i, j, m; i = 0; m = boost::re_detail::distance(first, last); ++m; - unsigned int size = sizeof(kmp_info) + sizeof(int)*m + sizeof(charT)*m; + std::size_t size = sizeof(kmp_info) + sizeof(int)*m + sizeof(charT)*m; --m; // // allocate struct and fill it in: diff --git a/include/boost/regex/detail/regex_match.hpp b/include/boost/regex/detail/regex_match.hpp index fbd37971..4f27fc08 100644 --- a/include/boost/regex/detail/regex_match.hpp +++ b/include/boost/regex/detail/regex_match.hpp @@ -254,7 +254,7 @@ struct access_t : public reg_expression { return base_type::first(b); } static const unsigned char* get_map(const base_type& b) { return base_type::get_map(b); } - static unsigned int leading_length(const base_type& b) + static std::size_t leading_length(const base_type& b) { return base_type::leading_length(b); } static const kmp_info* get_kmp(const base_type& b) { return base_type::get_kmp(b); } @@ -1052,10 +1052,10 @@ void _skip_and_inc(unsigned int& clines, iterator& last_line, iterator& first, c } template -void _skip_and_dec(unsigned int& clines, iterator& last_line, iterator& first, iterator base, unsigned int len) +void _skip_and_dec(unsigned int& clines, iterator& last_line, iterator& first, iterator base, std::size_t len) { bool need_line = false; - for(unsigned int i = 0; i < len; ++i) + for(std::size_t i = 0; i < len; ++i) { --first; if(*first == '\n') @@ -1257,9 +1257,9 @@ unsigned int reg_grep2(Predicate foo, I first, I last, const reg_expression* info = access::get_kmp(e); - int len = info->len; + std::ptrdiff_t len = info->len; const charT* x = info->pstr; - int j = 0; + std::ptrdiff_t j = 0; bool icase = e.flags() & regbase::icase; while (first != last) { diff --git a/include/boost/regex/regex_traits.hpp b/include/boost/regex/regex_traits.hpp index d3267700..8de2283e 100644 --- a/include/boost/regex/regex_traits.hpp +++ b/include/boost/regex/regex_traits.hpp @@ -45,7 +45,7 @@ struct mss }; BOOST_REGEX_DECL bool BOOST_REGEX_CALL re_lookup_def_collate_name(std::string& buf, const char* name); -BOOST_REGEX_DECL unsigned int BOOST_REGEX_CALL re_get_default_message(char* buf, unsigned int len, unsigned int id); +BOOST_REGEX_DECL std::size_t BOOST_REGEX_CALL re_get_default_message(char* buf, std::size_t len, std::size_t id); extern BOOST_REGEX_DECL const char *re_default_error_messages[]; BOOST_REGEX_DECL bool BOOST_REGEX_CALL re_lookup_def_collate_name(std::string& buf, const char* name); BOOST_REGEX_DECL bool BOOST_REGEX_CALL is_combining(wchar_t c); @@ -154,7 +154,7 @@ protected: friend class c_regex_traits; #endif - static char regex_message_catalogue[200]; + static char regex_message_catalogue[BOOST_REGEX_MAX_PATH]; enum syntax_map_size { map_size = UCHAR_MAX + 1 @@ -318,8 +318,8 @@ public: operator void*() { return this; } }; static void BOOST_REGEX_CALL update(); - static unsigned int BOOST_REGEX_CALL strnarrow(char *s1, unsigned int len, const wchar_t *s2); - static unsigned int BOOST_REGEX_CALL strwiden(wchar_t *s1, unsigned int len, const char *s2); + static std::size_t BOOST_REGEX_CALL strnarrow(char *s1, std::size_t len, const wchar_t *s2); + static std::size_t BOOST_REGEX_CALL strwiden(wchar_t *s1, std::size_t len, const char *s2); private: static bool BOOST_REGEX_CALL do_iswclass(wchar_t c, boost::uint_fast32_t f); static void BOOST_REGEX_CALL m_free(); @@ -362,7 +362,7 @@ struct BOOST_REGEX_DECL w32_traits_base : public regex_traits_base public: static std::string BOOST_REGEX_CALL set_message_catalogue(const std::string& s); protected: - static char regex_message_catalogue[200]; + static char regex_message_catalogue[BOOST_REGEX_MAX_PATH]; enum syntax_map_size { map_size = UCHAR_MAX + 1 @@ -519,8 +519,8 @@ public: static void BOOST_REGEX_CALL update(); w32_regex_traits(); ~w32_regex_traits(); - static unsigned int BOOST_REGEX_CALL strnarrow(char *s1, unsigned int len, const wchar_t *s2); - static unsigned int BOOST_REGEX_CALL strwiden(wchar_t *s1, unsigned int len, const char *s2); + static std::size_t BOOST_REGEX_CALL strnarrow(char *s1, std::size_t len, const wchar_t *s2); + static std::size_t BOOST_REGEX_CALL strwiden(wchar_t *s1, std::size_t len, const char *s2); private: static bool BOOST_REGEX_CALL do_iswclass(wchar_t c, boost::uint_fast32_t f); @@ -580,7 +580,7 @@ struct BOOST_REGEX_DECL cpp_regex_traits_base : public regex_traits_base static std::string BOOST_REGEX_CALL set_message_catalogue(const std::string& s); protected: - static char regex_message_cat[200]; + static char regex_message_cat[BOOST_REGEX_MAX_PATH]; }; } // namespace re_detail @@ -752,7 +752,7 @@ public: ~cpp_regex_traits(); locale_type BOOST_REGEX_CALL imbue(locale_type l); locale_type BOOST_REGEX_CALL getloc()const{ return locale_inst; } - unsigned int BOOST_REGEX_CALL strwiden(wchar_t *s1, unsigned int len, const char *s2)const; + std::size_t BOOST_REGEX_CALL strwiden(wchar_t *s1, std::size_t len, const char *s2)const; struct sentry {