[Boost-bugs] [Boost C++ Libraries] #4261: bug? with boost::find_format_all, boost::regex_finder and custom regex formatter. I'm not sure.

Subject: [Boost-bugs] [Boost C++ Libraries] #4261: bug? with boost::find_format_all, boost::regex_finder and custom regex formatter. I'm not sure.
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2010-05-26 17:03:51


#4261: bug? with boost::find_format_all, boost::regex_finder and custom regex
formatter. I'm not sure.
------------------------------------------------------+---------------------
 Reporter: nic.bertrand@… | Owner:
     Type: Bugs | Status: new
Milestone: Boost 1.43.0 | Component: None
  Version: Boost 1.42.0 | Severity: Problem
 Keywords: regex, string, boost-regex, boost-string |
------------------------------------------------------+---------------------
 I have a code that has been working for almost 4 years (since boost 1.33)
 and today I went from boost 1.36 to boost 1.42 and now I have a problem.

 I'm calling a custom formatter on a string to format parts of the string
 that match a REGEX.

 For instance, a string like: "abc;def:" will be changed to "abc\2Cdef\3B"
 if the REGEX contains "([;:])"

 boost::find_format_all( mystring, boost::regex_finder( REGEX ),
 custom_formatter() );

 The custom formatter looks like this:

 struct custom_formatter()
 {

   template< typename T >
   std::string operator()( const T & s ) const
   {
       std::string matchStr = s.match_results().str(1);

       // perform substitutions

       return matchStr;
   }

 }

 This worked fine but with boost 1.42 I now have "non initialized"
 s.match_results() which yield to
 boost::exception_detail::clone_implINS0_::error_info_injectorISt11logic_errorEEEE
 - Attempt to access an uninitialzed boost::match_results<> class.

 This means that sometimes I am in the functor to format a string but there
 is no match. It seems I have a new empty match at the end of each string
 to parse.

 Am I doing something wrong? Or is it normal to enter the functor when
 there is no match and I should check against something?

 I can avoid this testing s.begin() == s.end() at the begining of the
 functor, but is it really necessary or is it a bug

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/4261>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:03 UTC