From 4922ae784fcaa70bf87f1245743a6ef2c8c4d0c0 Mon Sep 17 00:00:00 2001 From: John Maddock Date: Tue, 25 Sep 2001 11:48:21 +0000 Subject: [PATCH] Fixed messed up c_regex_traits from previous commit, fixed Koenig lookup bug caused by presence of boost::re_detail::destroy [SVN r11249] --- appendix.htm | 35 +++++++++++---------- include/boost/regex.hpp | 22 ++++++------- include/boost/regex/config.hpp | 6 ++-- include/boost/regex/detail/regex_format.hpp | 4 +-- include/boost/regex/detail/regex_match.hpp | 2 +- include/boost/regex/detail/regex_stack.hpp | 6 ++-- include/boost/regex/regex_traits.hpp | 26 +++++---------- src/c_regex_traits.cpp | 24 +++++++------- test/regress/tests.txt | 5 +-- 9 files changed, 61 insertions(+), 69 deletions(-) diff --git a/appendix.htm b/appendix.htm index 8a7607a2..9acac550 100644 --- a/appendix.htm +++ b/appendix.htm @@ -226,8 +226,8 @@ treated as "unknown" graphic characters.

an operating system other than Win32, and is encapsulated by the traits class c_regex_traits, Win32 users can force this model to take effect by defining the -pre-processor symbol BOOST_REGEX_USE_C_LOCALE. When this model is in -effect there is a single global locale, as set by setlocale. +pre-processor symbol BOOST_REGEX_USE_C_LOCALE. When this model is +in effect there is a single global locale, as set by setlocale. All settings are acquired from your run time library, consequently Unicode support is dependent upon your run time library implementation. Front end localization requires a POSIX @@ -261,11 +261,11 @@ regular expression libraries including version 1 of this library.

This model is only in effect if the library is built with the -pre-processor symbol BOOST_REGEX_USE_CPP_LOCALE defined. When this model -is in effect each instance of reg_expression<> has its own -instance of std::locale, class reg_expression<> also has a -member function imbue which allows the locale for the -expression to be set on a per-instance basis. Front end +pre-processor symbol BOOST_REGEX_USE_CPP_LOCALE defined. When +this model is in effect each instance of reg_expression<> +has its own instance of std::locale, class reg_expression<> +also has a member function imbue which allows the locale +for the expression to be set on a per-instance basis. Front end localization requires a POSIX message catalogue, which will be loaded via the std::messages facet of the expression's locale, the traits class exports the symbol:

@@ -293,9 +293,9 @@ or "POSIX".

Finally note that if you build the library with a non-default localization model, then the appropriate pre-processor symbol (BOOST_REGEX_USE_C_LOCALE -or BOOST_REGEX_USE_CPP_LOCALE) must be defined both when you build the -support library, and when you include <boost/regex.hpp> or -<boost/cregex.hpp> in your code. The best way to ensure +or BOOST_REGEX_USE_CPP_LOCALE) must be defined both when you +build the support library, and when you include <boost/regex.hpp> +or <boost/cregex.hpp> in your code. The best way to ensure this is to add the #define to <boost/regex/detail/regex_options.hpp>.

@@ -1241,9 +1241,10 @@ regex++ dll's are as follows:

Note: you can disable automatic library selection by defining -the symbol BOOST_REGEX_NO_LIB when compiling, this is useful if you -want to statically link even though you're using the dll version -of your run time library, or if you need to debug regex++.

+the symbol BOOST_REGEX_NO_LIB when compiling, this is useful if +you want to statically link even though you're using the dll +version of your run time library, or if you need to debug regex++. +


@@ -1299,10 +1300,10 @@ Dennerline, Edward Diener, Peter Dimov, Robert Dunn, Fabio Forno, Tobias Gabrielsson, Rob Gillen, Marc Gregoire, Chris Hecker, Nick Hodapp, Jesse Jones, Martin Jost, Boris Krasnovskiy, Jan Hermelink, Max Leung, Wei-hao Lin, Jens Maurer, Heiko Schmidt, -Scobie Smith, Alexander Sokolovsky, Hervé Poirier, Marc Recht, -Bruno Voigt, Alexey Voinov, Jerry Waldorf, Rob Ward, Lealon -Watts, Thomas Witt and Yuval Yosef. I am also grateful to the -manuals supplied with the Henry Spencer, Perl and GNU regular +Jason Shirk, Scobie Smith, Alexander Sokolovsky, Hervé Poirier, +Marc Recht, Bruno Voigt, Alexey Voinov, Jerry Waldorf, Rob Ward, +Lealon Watts, Thomas Witt and Yuval Yosef. I am also grateful to +the manuals supplied with the Henry Spencer, Perl and GNU regular expression libraries - wherever possible I have tried to maintain compatibility with these libraries and with the POSIX standard - the code however is entirely my own, including any bugs! I can diff --git a/include/boost/regex.hpp b/include/boost/regex.hpp index 82dcc513..970adcc7 100644 --- a/include/boost/regex.hpp +++ b/include/boost/regex.hpp @@ -1074,7 +1074,7 @@ match_results_base::match_results_base(const Allocator& a) } catch(...) { - ::boost::re_detail::destroy(ref); + ::boost::re_detail::pointer_destroy(ref); throw; } } @@ -1115,10 +1115,10 @@ void BOOST_REGEX_CALL match_results_base::free() p2 = p1 + ref->cmatches; while(p1 != p2) { - ::boost::re_detail::destroy(p1); + ::boost::re_detail::pointer_destroy(p1); ++p1; } - ::boost::re_detail::destroy(ref); + ::boost::re_detail::pointer_destroy(ref); a.deallocate((char*)(void*)ref, sizeof(sub_match) * ref->cmatches + sizeof(c_reference)); } } @@ -1169,10 +1169,10 @@ void BOOST_REGEX_CALL match_results_base::set_size(size_typ p2 = (sub_match*)(newref+1); while(p2 != p1) { - ::boost::re_detail::destroy(p2); + ::boost::re_detail::pointer_destroy(p2); ++p2; } - ::boost::re_detail::destroy(ref); + ::boost::re_detail::pointer_destroy(ref); throw; } ref = newref; @@ -1211,10 +1211,10 @@ void BOOST_REGEX_CALL match_results_base::set_size(size_typ p2 = (sub_match*)(newref+1); while(p2 != p1) { - ::boost::re_detail::destroy(p2); + ::boost::re_detail::pointer_destroy(p2); ++p2; } - ::boost::re_detail::destroy(ref); + ::boost::re_detail::pointer_destroy(ref); throw; } ref = newref; @@ -1316,10 +1316,10 @@ void BOOST_REGEX_CALL match_results_base::cow() p2 = (sub_match*)(newref+1); while(p2 != p1) { - ::boost::re_detail::destroy(p2); + ::boost::re_detail::pointer_destroy(p2); ++p2; } - ::boost::re_detail::destroy(ref); + ::boost::re_detail::pointer_destroy(ref); throw; } --(ref->count); @@ -1436,10 +1436,10 @@ match_results::match_results(const match_results*)(this->ref+1); while(p2 != p1) { - re_detail::destroy(p2); + re_detail::pointer_destroy(p2); ++p2; } - re_detail::destroy(this->ref); + re_detail::pointer_destroy(this->ref); throw; } } diff --git a/include/boost/regex/config.hpp b/include/boost/regex/config.hpp index a37499ac..1876ffe2 100644 --- a/include/boost/regex/config.hpp +++ b/include/boost/regex/config.hpp @@ -523,7 +523,7 @@ namespace std{ /***************************************************************************** * - * helper functions construct/destroy: + * helper functions pointer_construct/pointer_destroy: * ****************************************************************************/ @@ -531,11 +531,11 @@ namespace std{ namespace boost{ namespace re_detail{ template -inline void destroy(T* p) +inline void pointer_destroy(T* p) { p->~T(); } template -inline void construct(T* p, const T& t) +inline void pointer_construct(T* p, const T& t) { new (p) T(t); } }} // namespaces diff --git a/include/boost/regex/detail/regex_format.hpp b/include/boost/regex/detail/regex_format.hpp index 0eb720e0..86d72e32 100644 --- a/include/boost/regex/detail/regex_format.hpp +++ b/include/boost/regex/detail/regex_format.hpp @@ -104,8 +104,8 @@ void BOOST_REGEX_CALL re_skip_format(const charT*& fmt, const traits_type& trait template inline void oi_assign(T* p, T v) { - ::boost::re_detail::destroy(p); - construct(p, v); + ::boost::re_detail::pointer_destroy(p); + pointer_construct(p, v); } #else diff --git a/include/boost/regex/detail/regex_match.hpp b/include/boost/regex/detail/regex_match.hpp index a4a6b739..1816ad3f 100644 --- a/include/boost/regex/detail/regex_match.hpp +++ b/include/boost/regex/detail/regex_match.hpp @@ -215,7 +215,7 @@ void _priv_match_data::free() i_alloc temp1(temp_match.allocator()); temp1.deallocate(accumulators, caccumulators); for(unsigned i = 0; i < caccumulators; ++i) - ::boost::re_detail::destroy(loop_starts + i); + ::boost::re_detail::pointer_destroy(loop_starts + i); it_alloc temp2(temp_match.allocator()); temp2.deallocate(loop_starts, caccumulators); } diff --git a/include/boost/regex/detail/regex_stack.hpp b/include/boost/regex/detail/regex_stack.hpp index 1ee6eb8e..0bcb03dd 100644 --- a/include/boost/regex/detail/regex_stack.hpp +++ b/include/boost/regex/detail/regex_stack.hpp @@ -119,7 +119,7 @@ public: { if(m_stack->start == m_stack->end) pop_aux(); - ::boost::re_detail::destroy(m_stack->end); + ::boost::re_detail::pointer_destroy(m_stack->end); ++(m_stack->end); } @@ -128,7 +128,7 @@ public: if(m_stack->start == m_stack->end) pop_aux(); t = *m_stack->end; - ::boost::re_detail::destroy(m_stack->end); + ::boost::re_detail::pointer_destroy(m_stack->end); ++(m_stack->end); } @@ -137,7 +137,7 @@ public: if(m_stack->end == m_stack->last) push_aux(); --(m_stack->end); - construct(m_stack->end, t); + pointer_construct(m_stack->end, t); } }; diff --git a/include/boost/regex/regex_traits.hpp b/include/boost/regex/regex_traits.hpp index d6627287..cc6b7d43 100644 --- a/include/boost/regex/regex_traits.hpp +++ b/include/boost/regex/regex_traits.hpp @@ -132,17 +132,17 @@ public: // classes (we will static-assert that later): // char_class_none = 0, - char_class_alpha = 0x0100, - char_class_cntrl = 0x0020, + char_class_alpha = 0x0001, + char_class_cntrl = 0x0002, char_class_digit = 0x0004, - char_class_lower = 0x0002, + char_class_lower = 0x0008, char_class_punct = 0x0010, - char_class_space = 0x0008, - char_class_upper = 0x0001, + char_class_space = 0x0020, + char_class_upper = 0x0040, char_class_xdigit = 0x0080, - char_class_blank = 0x0040, - char_class_unicode = 0x8000, + char_class_blank = 0x0100, char_class_underscore = 0x4000, + char_class_unicode = 0x8000, char_class_alnum = char_class_alpha | char_class_digit, char_class_graph = char_class_alpha | char_class_digit | char_class_punct | char_class_underscore, @@ -360,17 +360,6 @@ struct BOOST_REGEX_DECL w32_traits_base : public regex_traits_base char_class_win = 0x01FF }; - BOOST_STATIC_ASSERT(w32_traits_base::char_class_alpha == c_traits_base::char_class_alpha); - BOOST_STATIC_ASSERT(w32_traits_base::char_class_cntrl == c_traits_base::char_class_cntrl); - BOOST_STATIC_ASSERT(w32_traits_base::char_class_digit == c_traits_base::char_class_digit); - BOOST_STATIC_ASSERT(w32_traits_base::char_class_lower == c_traits_base::char_class_lower); - BOOST_STATIC_ASSERT(w32_traits_base::char_class_punct == c_traits_base::char_class_punct); - BOOST_STATIC_ASSERT(w32_traits_base::char_class_space == c_traits_base::char_class_space); - BOOST_STATIC_ASSERT(w32_traits_base::char_class_upper == c_traits_base::char_class_upper); - BOOST_STATIC_ASSERT(w32_traits_base::char_class_xdigit == c_traits_base::char_class_xdigit); - BOOST_STATIC_ASSERT(w32_traits_base::char_class_blank == c_traits_base::char_class_blank); - BOOST_STATIC_ASSERT(w32_traits_base::char_class_underscore == c_traits_base::char_class_underscore); - public: static std::string BOOST_REGEX_CALL set_message_catalogue(const std::string& s); @@ -394,6 +383,7 @@ public: static char* BOOST_REGEX_CALL get_catalogue() { return regex_message_catalogue; } }; + } // namespace re_detail template diff --git a/src/c_regex_traits.cpp b/src/c_regex_traits.cpp index dd9b4150..2a4955ef 100644 --- a/src/c_regex_traits.cpp +++ b/src/c_regex_traits.cpp @@ -277,13 +277,13 @@ void BOOST_REGEX_CALL re_update_collate() { char* p1, *p2, *p3, *p4;; p1 = buf; - while(*p1 && std::isspace(*p1))++p1; + while(*p1 && std::isspace((unsigned char)*p1))++p1; p2 = p1; - while(*p2 && !std::isspace(*p2))++p2; + while(*p2 && !std::isspace((unsigned char)*p2))++p2; p3 = p2; - while(*p3 && std::isspace(*p3))++p3; + while(*p3 && std::isspace((unsigned char)*p3))++p3; p4 = p3; - while(*p4 && !std::isspace(*p4))++p4; + while(*p4 && !std::isspace((unsigned char)*p4))++p4; pcoll_names->push_back(collate_name_t(p1, p2, p3, p4)); ++i; re_get_message(buf, 256, i); @@ -456,21 +456,21 @@ void BOOST_REGEX_CALL c_traits_base::do_update_ctype() std::memset(class_map, 0, map_size); for(i = 0; i < map_size; ++i) { - if(std::isalpha((char)i)) + if(std::isalpha(i)) class_map[i] |= char_class_alpha; - if(std::iscntrl((char)i)) + if(std::iscntrl(i)) class_map[i] |= char_class_cntrl; - if(std::isdigit((char)i)) + if(std::isdigit(i)) class_map[i] |= char_class_digit; - if(std::islower((char)i)) + if(std::islower(i)) class_map[i] |= char_class_lower; - if(std::isupper((char)i)) + if(std::isupper(i)) class_map[i] |= char_class_upper; - if(std::ispunct((char)i)) + if(std::ispunct(i)) class_map[i] |= char_class_punct; - if(std::isspace((char)i)) + if(std::isspace(i)) class_map[i] |= char_class_space; - if(std::isxdigit((char)i)) + if(std::isxdigit(i)) class_map[i] |= char_class_xdigit; } class_map['_'] |= char_class_underscore; diff --git a/test/regress/tests.txt b/test/regress/tests.txt index ffe0af97..3d944dae 100644 --- a/test/regress/tests.txt +++ b/test/regress/tests.txt @@ -252,8 +252,8 @@ a[[:]:]]b ! a[[:-:]]b ! a[[:alph:]] ! a[[:alphabet:]] ! -[[:alnum:]]+ -%@a0X- 3 6 -[[:alpha:]]+ -%@aX0- 3 5 +[[:alnum:]]+ -%@a0X_- 3 6 +[[:alpha:]]+ -%@aX_0- 3 5 [[:blank:]]+ "a \tb" 1 4 [[:cntrl:]]+ a\n\tb 1 3 [[:digit:]]+ a019b 1 4 @@ -879,3 +879,4 @@ a+(?#b+)b+ xaaabbba 1 7 +