Ticket #5462: regex-no-exceptions.patch

File regex-no-exceptions.patch, 3.4 KB (added by carl.simonson@…, 12 years ago)
  • boost/regex/v4/basic_regex.hpp

    commit 4a4d9ab577aeff2c34259bcb82e7dd33034e2bc6
    Author: Carl Simonson <carl.simonson@garmin.com>
    Date:   Tue Apr 12 15:12:10 2011 -0500
    
        regex: Fix up code that uses exceptions
        
        Some places in the boost::regex library did not safely guard uses of
        exceptions with checks to see if exceptions were enabled.
    
    diff --git a/boost/regex/v4/basic_regex.hpp b/boost/regex/v4/basic_regex.hpp
    index 04c7bb3..cb51af7 100644
    a b  
    11/*
    22 *
    3  * Copyright (c) 1998-2004
    4  * John Maddock
     3 * Copyright (c) 1998-2004 John Maddock
     4 * Copyright 2011 Carl Simonson
    55 *
    66 * Distributed under the Boost Software License, Version 1.0.
    77 * (See accompanying file LICENSE_1_0.txt or copy at
    public:  
    234234   std::pair<const_iterator, const_iterator> BOOST_REGEX_CALL subexpression(std::size_t n)const
    235235   {
    236236      if(n == 0)
    237          throw std::out_of_range("0 is not a valid subexpression index.");
     237         boost::throw_exception(std::out_of_range("0 is not a valid subexpression index."));
    238238      const std::pair<std::size_t, std::size_t>& pi = this->m_subs.at(n - 1);
    239239      std::pair<const_iterator, const_iterator> p(expression() + pi.first, expression() + pi.second);
    240240      return p;
    public:  
    487487   std::pair<const_iterator, const_iterator> BOOST_REGEX_CALL subexpression(std::size_t n)const
    488488   {
    489489      if(!m_pimpl.get())
    490          throw std::logic_error("Can't access subexpressions in an invalid regex.");
     490         boost::throw_exception(std::logic_error("Can't access subexpressions in an invalid regex."));
    491491      return m_pimpl->subexpression(n);
    492492   }
    493493   const_iterator BOOST_REGEX_CALL begin()const
  • boost/regex/v4/cpp_regex_traits.hpp

    diff --git a/boost/regex/v4/cpp_regex_traits.hpp b/boost/regex/v4/cpp_regex_traits.hpp
    index cd22bd8..c781d74 100644
    a b  
    11/*
    22 *
    3  * Copyright (c) 2004
    4  * John Maddock
     3 * Copyright (c) 2004 John Maddock
     4 * Copyright 2011 Carl Simonson
    55 *
    66 * Use, modification and distribution are subject to the
    77 * Boost Software License, Version 1.0. (See accompanying file
    typename cpp_regex_traits_implementation<charT>::string_type  
    511511   // however at least one std lib will always throw
    512512   // std::bad_alloc for certain arguments...
    513513   //
     514#ifndef BOOST_NO_EXCEPTIONS
    514515   try{
     516#endif
    515517      //
    516518      // What we do here depends upon the format of the sort key returned by
    517519      // sort key returned by this->transform:
    typename cpp_regex_traits_implementation<charT>::string_type  
    546548            result.erase(i);
    547549            break;
    548550      }
     551#ifndef BOOST_NO_EXCEPTIONS
    549552   }catch(...){}
     553#endif
    550554   while(result.size() && (charT(0) == *result.rbegin()))
    551555      result.erase(result.size() - 1);
    552556   if(result.empty())
    typename cpp_regex_traits_implementation<charT>::string_type  
    576580   // std::bad_alloc for certain arguments...
    577581   //
    578582   string_type result;
     583#ifndef BOOST_NO_EXCEPTIONS
    579584   try{
     585#endif
    580586      result = this->m_pcollate->transform(p1, p2);
    581587      //
    582588      // Borland's STLPort version returns a NULL-terminated
    typename cpp_regex_traits_implementation<charT>::string_type  
    593599         result.erase(result.size() - 1);
    594600#endif
    595601      BOOST_ASSERT(std::find(result.begin(), result.end(), charT(0)) == result.end());
     602#ifndef BOOST_NO_EXCEPTIONS
    596603   }
    597604   catch(...)
    598605   {
    599606   }
     607#endif
    600608   return result;
    601609}
    602610