Boost logo

Boost-Commit :

From: john_at_[hidden]
Date: 2008-06-05 13:07:42


Author: johnmaddock
Date: 2008-06-05 13:07:42 EDT (Thu, 05 Jun 2008)
New Revision: 46170
URL: http://svn.boost.org/trac/boost/changeset/46170

Log:
Changed POSIX API functions to use the global C locale.
Fixes #1446.
Text files modified:
   trunk/libs/regex/src/posix_api.cpp | 16 +++++++++-------
   trunk/libs/regex/src/wide_posix_api.cpp | 16 +++++++++-------
   2 files changed, 18 insertions(+), 14 deletions(-)

Modified: trunk/libs/regex/src/posix_api.cpp
==============================================================================
--- trunk/libs/regex/src/posix_api.cpp (original)
+++ trunk/libs/regex/src/posix_api.cpp 2008-06-05 13:07:42 EDT (Thu, 05 Jun 2008)
@@ -62,6 +62,8 @@
 };
 } // namespace
 
+typedef boost::basic_regex<char, c_regex_traits<char> > c_regex_type;
+
 BOOST_REGEX_DECL int BOOST_REGEX_CCALL regcompA(regex_tA* expression, const char* ptr, int f)
 {
    if(expression->re_magic != magic_value)
@@ -70,7 +72,7 @@
 #ifndef BOOST_NO_EXCEPTIONS
       try{
 #endif
- expression->guts = new regex();
+ expression->guts = new c_regex_type();
 #ifndef BOOST_NO_EXCEPTIONS
       } catch(...)
       {
@@ -120,9 +122,9 @@
    try{
 #endif
       expression->re_magic = magic_value;
- 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();
+ static_cast<c_regex_type*>(expression->guts)->set_expression(ptr, p2, flags);
+ expression->re_nsub = static_cast<c_regex_type*>(expression->guts)->mark_count() - 1;
+ result = static_cast<c_regex_type*>(expression->guts)->error_code();
 #ifndef BOOST_NO_EXCEPTIONS
    }
    catch(const boost::regex_error& be)
@@ -187,7 +189,7 @@
    {
       std::string p;
       if((e) && (e->re_magic == magic_value))
- p = static_cast<regex*>(e->guts)->get_traits().error_string(static_cast< ::boost::regex_constants::error_type>(code));
+ p = static_cast<c_regex_type*>(e->guts)->get_traits().error_string(static_cast< ::boost::regex_constants::error_type>(code));
       else
       {
          p = re_detail::get_default_error_string(static_cast< ::boost::regex_constants::error_type>(code));
@@ -236,7 +238,7 @@
 #endif
    if(expression->re_magic == magic_value)
    {
- result = regex_search(start, end, m, *static_cast<regex*>(expression->guts), flags);
+ result = regex_search(start, end, m, *static_cast<c_regex_type*>(expression->guts), flags);
    }
    else
       return result;
@@ -274,7 +276,7 @@
 {
    if(expression->re_magic == magic_value)
    {
- delete static_cast<regex*>(expression->guts);
+ delete static_cast<c_regex_type*>(expression->guts);
    }
    expression->re_magic = 0;
 }

Modified: trunk/libs/regex/src/wide_posix_api.cpp
==============================================================================
--- trunk/libs/regex/src/wide_posix_api.cpp (original)
+++ trunk/libs/regex/src/wide_posix_api.cpp 2008-06-05 13:07:42 EDT (Thu, 05 Jun 2008)
@@ -69,6 +69,8 @@
 };
 }
 
+typedef boost::basic_regex<wchar_t, c_regex_traits<wchar_t> > c_regex_type;
+
 BOOST_REGEX_DECL int BOOST_REGEX_CCALL regcompW(regex_tW* expression, const wchar_t* ptr, int f)
 {
    if(expression->re_magic != wmagic_value)
@@ -77,7 +79,7 @@
 #ifndef BOOST_NO_EXCEPTIONS
       try{
 #endif
- expression->guts = new wregex();
+ expression->guts = new c_regex_type();
 #ifndef BOOST_NO_EXCEPTIONS
       } catch(...)
       {
@@ -127,9 +129,9 @@
    try{
 #endif
       expression->re_magic = wmagic_value;
- 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();
+ static_cast<c_regex_type*>(expression->guts)->set_expression(ptr, p2, flags);
+ expression->re_nsub = static_cast<c_regex_type*>(expression->guts)->mark_count() - 1;
+ result = static_cast<c_regex_type*>(expression->guts)->error_code();
 #ifndef BOOST_NO_EXCEPTIONS
    }
    catch(const boost::regex_error& be)
@@ -208,7 +210,7 @@
    {
       std::string p;
       if((e) && (e->re_magic == wmagic_value))
- p = static_cast<wregex*>(e->guts)->get_traits().error_string(static_cast< ::boost::regex_constants::error_type>(code));
+ p = static_cast<c_regex_type*>(e->guts)->get_traits().error_string(static_cast< ::boost::regex_constants::error_type>(code));
       else
       {
          p = re_detail::get_default_error_string(static_cast< ::boost::regex_constants::error_type>(code));
@@ -257,7 +259,7 @@
 #endif
    if(expression->re_magic == wmagic_value)
    {
- result = regex_search(start, end, m, *static_cast<wregex*>(expression->guts), flags);
+ result = regex_search(start, end, m, *static_cast<c_regex_type*>(expression->guts), flags);
    }
    else
       return result;
@@ -294,7 +296,7 @@
 {
    if(expression->re_magic == wmagic_value)
    {
- delete static_cast<wregex*>(expression->guts);
+ delete static_cast<c_regex_type*>(expression->guts);
    }
    expression->re_magic = 0;
 }


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk