Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r71240 - in trunk: boost/regex/pending boost/regex/v4 libs/regex/test libs/regex/test/noeh_test libs/regex/test/regress
From: john_at_[hidden]
Date: 2011-04-14 03:53:30


Author: johnmaddock
Date: 2011-04-14 03:53:28 EDT (Thu, 14 Apr 2011)
New Revision: 71240
URL: http://svn.boost.org/trac/boost/changeset/71240

Log:
Apply patches from #5462.
Add new test case to verify patches are actually working and prevent future breakage!
Fixes #5462.
Added:
   trunk/libs/regex/test/noeh_test/
   trunk/libs/regex/test/noeh_test/Jamfile.v2 (contents, props changed)
Text files modified:
   trunk/boost/regex/pending/object_cache.hpp | 2 +-
   trunk/boost/regex/v4/basic_regex.hpp | 8 ++++----
   trunk/boost/regex/v4/cpp_regex_traits.hpp | 12 ++++++++++--
   trunk/libs/regex/test/Jamfile.v2 | 12 ++++++++++++
   trunk/libs/regex/test/regress/main.cpp | 12 ++++++++++++
   5 files changed, 39 insertions(+), 7 deletions(-)

Modified: trunk/boost/regex/pending/object_cache.hpp
==============================================================================
--- trunk/boost/regex/pending/object_cache.hpp (original)
+++ trunk/boost/regex/pending/object_cache.hpp 2011-04-14 03:53:28 EDT (Thu, 14 Apr 2011)
@@ -73,7 +73,7 @@
    // for now just throw, but we should never really get here...
    //
    ::boost::throw_exception(std::runtime_error("Error in thread safety code: could not acquire a lock"));
-#ifdef BOOST_NO_UNREACHABLE_RETURN_DETECTION
+#if defined(BOOST_NO_UNREACHABLE_RETURN_DETECTION) || defined(BOOST_NO_EXCEPTIONS)
    return boost::shared_ptr<Object>();
 #endif
 #else

Modified: trunk/boost/regex/v4/basic_regex.hpp
==============================================================================
--- trunk/boost/regex/v4/basic_regex.hpp (original)
+++ trunk/boost/regex/v4/basic_regex.hpp 2011-04-14 03:53:28 EDT (Thu, 14 Apr 2011)
@@ -1,7 +1,7 @@
 /*
  *
- * Copyright (c) 1998-2004
- * John Maddock
+ * Copyright (c) 1998-2004 John Maddock
+ * Copyright 2011 Garmin Ltd. or its subsidiaries
  *
  * Distributed under the Boost Software License, Version 1.0.
  * (See accompanying file LICENSE_1_0.txt or copy at
@@ -234,7 +234,7 @@
    std::pair<const_iterator, const_iterator> BOOST_REGEX_CALL subexpression(std::size_t n)const
    {
       if(n == 0)
- throw std::out_of_range("0 is not a valid subexpression index.");
+ boost::throw_exception(std::out_of_range("0 is not a valid subexpression index."));
       const std::pair<std::size_t, std::size_t>& pi = this->m_subs.at(n - 1);
       std::pair<const_iterator, const_iterator> p(expression() + pi.first, expression() + pi.second);
       return p;
@@ -487,7 +487,7 @@
    std::pair<const_iterator, const_iterator> BOOST_REGEX_CALL subexpression(std::size_t n)const
    {
       if(!m_pimpl.get())
- throw std::logic_error("Can't access subexpressions in an invalid regex.");
+ boost::throw_exception(std::logic_error("Can't access subexpressions in an invalid regex."));
       return m_pimpl->subexpression(n);
    }
    const_iterator BOOST_REGEX_CALL begin()const

Modified: trunk/boost/regex/v4/cpp_regex_traits.hpp
==============================================================================
--- trunk/boost/regex/v4/cpp_regex_traits.hpp (original)
+++ trunk/boost/regex/v4/cpp_regex_traits.hpp 2011-04-14 03:53:28 EDT (Thu, 14 Apr 2011)
@@ -1,7 +1,7 @@
 /*
  *
- * Copyright (c) 2004
- * John Maddock
+ * Copyright (c) 2004 John Maddock
+ * Copyright 2011 Garmin Ltd. or its subsidiaries
  *
  * Use, modification and distribution are subject to the
  * Boost Software License, Version 1.0. (See accompanying file
@@ -511,7 +511,9 @@
    // however at least one std lib will always throw
    // std::bad_alloc for certain arguments...
    //
+#ifndef BOOST_NO_EXCEPTIONS
    try{
+#endif
       //
       // What we do here depends upon the format of the sort key returned by
       // sort key returned by this->transform:
@@ -546,7 +548,9 @@
             result.erase(i);
             break;
       }
+#ifndef BOOST_NO_EXCEPTIONS
    }catch(...){}
+#endif
    while(result.size() && (charT(0) == *result.rbegin()))
       result.erase(result.size() - 1);
    if(result.empty())
@@ -576,7 +580,9 @@
    // std::bad_alloc for certain arguments...
    //
    string_type result;
+#ifndef BOOST_NO_EXCEPTIONS
    try{
+#endif
       result = this->m_pcollate->transform(p1, p2);
       //
       // Borland's STLPort version returns a NULL-terminated
@@ -593,10 +599,12 @@
          result.erase(result.size() - 1);
 #endif
       BOOST_ASSERT(std::find(result.begin(), result.end(), charT(0)) == result.end());
+#ifndef BOOST_NO_EXCEPTIONS
    }
    catch(...)
    {
    }
+#endif
    return result;
 }
 

Modified: trunk/libs/regex/test/Jamfile.v2
==============================================================================
--- trunk/libs/regex/test/Jamfile.v2 (original)
+++ trunk/libs/regex/test/Jamfile.v2 2011-04-14 03:53:28 EDT (Thu, 14 Apr 2011)
@@ -174,6 +174,18 @@
   : # requirements
     <define>BOOST_REGEX_RECURSIVE=1
   : regex_regress_recursive ]
+
+[ run regress/$(R_SOURCE) ./noeh_test//boost_regex_noeh
+ ../build//icu_options
+ : # command line
+ : # input files
+ : # requirements
+ <define>BOOST_NO_EXCEPTIONS=1
+ <exception-handling>off
+ <link>static
+ <runtime-link>shared
+ : regex_regress_noeh ]
+
 ;
 
 build-project ../example ;

Added: trunk/libs/regex/test/noeh_test/Jamfile.v2
==============================================================================
--- (empty file)
+++ trunk/libs/regex/test/noeh_test/Jamfile.v2 2011-04-14 03:53:28 EDT (Thu, 14 Apr 2011)
@@ -0,0 +1,50 @@
+# copyright John Maddock 2011
+# Distributed under the Boost Software License, Version 1.0.
+# (See accompanying file LICENSE_1_0.txt or copy at
+# http://www.boost.org/LICENSE_1_0.txt.
+
+project
+ : requirements
+ <threading>multi
+ <link>shared:<define>BOOST_REGEX_DYN_LINK=1
+ <toolset>msvc-7.1:<define>TEST_MFC=1
+ <toolset>msvc-7.0:<define>TEST_MFC=1
+ <toolset>msvc:<asynch-exceptions>on
+ # There are unidentified linker problems on these platforms:
+ <toolset>mipspro-7.4:<link>static
+ <toolset>sun-5.9:<link>static
+ <warnings>all
+ <toolset>gcc:<cxxflags>-Wextra
+ <toolset>gcc:<cxxflags>-Wshadow
+ <define>U_USING_ICU_NAMESPACE=0
+ #<toolset>gcc-mw:<link>static
+ #<toolset>gcc-mingw:<link>static
+ <toolset>gcc-cygwin:<link>static
+ ;
+
+
+lib boost_regex_noeh :
+ ../../src/c_regex_traits.cpp
+ ../../src/cpp_regex_traits.cpp
+ ../../src/cregex.cpp
+ ../../src/fileiter.cpp
+ ../../src/icu.cpp
+ ../../src/instances.cpp
+ ../../src/posix_api.cpp
+ ../../src/regex.cpp
+ ../../src/regex_debug.cpp
+ ../../src/regex_raw_buffer.cpp
+ ../../src/regex_traits_defaults.cpp
+ ../../src/static_mutex.cpp
+ ../../src/w32_regex_traits.cpp
+ ../../src/wc_regex_traits.cpp
+ ../../src/wide_posix_api.cpp
+ ../../src/winstances.cpp
+ ../../src/usinstances.cpp
+ ../../build//icu_options
+ :
+ <link>static
+ <define>BOOST_NO_EXCEPTIONS=1
+ <exception-handling>off
+ :
+ ;
\ No newline at end of file

Modified: trunk/libs/regex/test/regress/main.cpp
==============================================================================
--- trunk/libs/regex/test/regress/main.cpp (original)
+++ trunk/libs/regex/test/regress/main.cpp 2011-04-14 03:53:28 EDT (Thu, 14 Apr 2011)
@@ -208,4 +208,16 @@
 }
 #endif
 
+#ifdef BOOST_NO_EXCETIONS
+namespace boost{
+
+void throw_exception( std::exception const & e )
+{
+ std::cerr << e.what() << std::endl;
+ std::exit(1);
+}
+
+}
+#endif
+
 #include <boost/test/included/prg_exec_monitor.hpp>


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