diff --git a/include/boost/regex/pending/object_cache.hpp b/include/boost/regex/pending/object_cache.hpp index db60e28a..05b6bfa2 100644 --- a/include/boost/regex/pending/object_cache.hpp +++ b/include/boost/regex/pending/object_cache.hpp @@ -73,7 +73,7 @@ boost::shared_ptr object_cache::get(const Key& k, siz // 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(); #endif #else diff --git a/include/boost/regex/v4/basic_regex.hpp b/include/boost/regex/v4/basic_regex.hpp index 04c7bb37..53b7bcaa 100644 --- a/include/boost/regex/v4/basic_regex.hpp +++ b/include/boost/regex/v4/basic_regex.hpp @@ -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 @@ public: std::pair 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& pi = this->m_subs.at(n - 1); std::pair p(expression() + pi.first, expression() + pi.second); return p; @@ -487,7 +487,7 @@ public: std::pair 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 diff --git a/include/boost/regex/v4/cpp_regex_traits.hpp b/include/boost/regex/v4/cpp_regex_traits.hpp index cd22bd8e..bcae455a 100644 --- a/include/boost/regex/v4/cpp_regex_traits.hpp +++ b/include/boost/regex/v4/cpp_regex_traits.hpp @@ -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 @@ typename cpp_regex_traits_implementation::string_type // 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 @@ typename cpp_regex_traits_implementation::string_type 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 @@ typename cpp_regex_traits_implementation::string_type // 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 @@ typename cpp_regex_traits_implementation::string_type 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; } diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index ce198b56..d31366f2 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -174,6 +174,18 @@ test-suite regex : # requirements BOOST_REGEX_RECURSIVE=1 : regex_regress_recursive ] + +[ run regress/$(R_SOURCE) ./noeh_test//boost_regex_noeh + ../build//icu_options + : # command line + : # input files + : # requirements + BOOST_NO_EXCEPTIONS=1 + off + static + shared + : regex_regress_noeh ] + ; build-project ../example ; diff --git a/test/noeh_test/Jamfile.v2 b/test/noeh_test/Jamfile.v2 new file mode 100644 index 00000000..dcaa84b9 --- /dev/null +++ b/test/noeh_test/Jamfile.v2 @@ -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 + multi + shared:BOOST_REGEX_DYN_LINK=1 + msvc-7.1:TEST_MFC=1 + msvc-7.0:TEST_MFC=1 + msvc:on + # There are unidentified linker problems on these platforms: + mipspro-7.4:static + sun-5.9:static + all + gcc:-Wextra + gcc:-Wshadow + U_USING_ICU_NAMESPACE=0 + #gcc-mw:static + #gcc-mingw:static + gcc-cygwin: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 + : + static + BOOST_NO_EXCEPTIONS=1 + off + : + ; \ No newline at end of file diff --git a/test/regress/main.cpp b/test/regress/main.cpp index 50315794..85ece016 100644 --- a/test/regress/main.cpp +++ b/test/regress/main.cpp @@ -208,4 +208,16 @@ void test(const wchar_t& c, const test_invalid_regex_tag& tag) } #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