Ticket #2269: regex.2.patch
File regex.2.patch, 4.2 KB (added by , 14 years ago) |
---|
-
basic_regex.hpp
148 148 { 149 149 return this->m_mark_count; 150 150 } 151 std::pair<const_iterator, const_iterator> BOOST_REGEX_CALL get_mark(size_type index)const 152 { 153 std::pair<const_iterator, const_iterator> mark(0,0) ; 154 155 if(!mark_count() && index < mark_count()) 156 return mark ; 157 158 mark.first = mark.second = this->m_expression ; 159 160 if(index == 0) 161 { 162 std::advance(mark.second, this->m_expression_len) ; 163 return mark ; 164 } 165 166 ::boost::re_detail::re_syntax_base const * state = get_first_state() ; 167 ::boost::re_detail::re_brace const * state_brace = 0 ; 168 169 do 170 { 171 if(state->type != ::boost::re_detail::syntax_element_startmark 172 && state->type != ::boost::re_detail::syntax_element_endmark) 173 continue ; 174 175 state_brace = static_cast<re_brace const *>(state) ; 176 if(state_brace->index != (int) index) 177 continue ; 178 179 if(state_brace->type == ::boost::re_detail::syntax_element_startmark) 180 std::advance(mark.first, state_brace->position) ; 181 else if(state_brace->type == ::boost::re_detail::syntax_element_endmark) 182 { 183 std::advance(mark.second, state_brace->position+1) ; 184 state = 0 ; 185 break ; 186 } 187 188 } while((state = state->next.p)) ; 189 190 return mark ; 191 } 192 151 193 const re_detail::re_syntax_base* get_first_state()const 152 194 { 153 195 return this->m_first_state; … … 405 447 return (m_pimpl.get() ? m_pimpl->mark_count() : 0); 406 448 } 407 449 450 std::pair<const_iterator, const_iterator> BOOST_REGEX_CALL get_mark(size_type index)const 451 { 452 return (m_pimpl.get() ? m_pimpl->get_mark(index) : std::pair<const_iterator, const_iterator>(0,0)); 453 } 454 408 455 int status()const 409 456 { 410 457 return (m_pimpl.get() ? m_pimpl->status() : regex_constants::error_empty); -
basic_regex_parser.hpp
371 371 markid = ++m_mark_count; 372 372 re_brace* pb = static_cast<re_brace*>(this->append_state(syntax_element_startmark, sizeof(re_brace))); 373 373 pb->index = markid; 374 pb->position = ::boost::re_detail::distance(m_base, m_position - 1) ; 374 375 std::ptrdiff_t last_paren_start = this->getoffset(pb); 375 376 // back up insertion point for alternations, and set new point: 376 377 std::ptrdiff_t last_alt_point = m_alt_insert_point; … … 421 422 // 422 423 pb = static_cast<re_brace*>(this->append_state(syntax_element_endmark, sizeof(re_brace))); 423 424 pb->index = markid; 425 pb->position = ::boost::re_detail::distance(m_base, m_position-1) ; 424 426 this->m_paren_start = last_paren_start; 425 427 // 426 428 // restore the alternate insertion point: … … 1549 1551 m_position = pc; 1550 1552 re_brace* pb = static_cast<re_brace*>(this->append_state(syntax_element_backref, sizeof(re_brace))); 1551 1553 pb->index = i; 1554 pb->position = ::boost::re_detail::distance(m_base, m_position) ; 1552 1555 } 1553 1556 else 1554 1557 { … … 1786 1789 // make a note of whether we have a case change: 1787 1790 m_has_case_change = ((opts & regbase::icase) != (this->flags() & regbase::icase)); 1788 1791 pb->index = markid = 0; 1792 pb->position = ::boost::re_detail::distance(m_base, m_position) ; 1789 1793 if(this->m_traits.syntax_type(*m_position) == regex_constants::syntax_close_mark) 1790 1794 { 1791 1795 // update flags and carry on as normal: … … 1896 1900 // 1897 1901 pb = static_cast<re_brace*>(this->append_state(syntax_element_endmark, sizeof(re_brace))); 1898 1902 pb->index = markid; 1903 pb->position = ::boost::re_detail::distance(m_base, m_position) ; 1899 1904 this->m_paren_start = last_paren_start; 1900 1905 // 1901 1906 // restore the alternate insertion point: -
states.hpp
156 156 // The index to match, can be zero (don't mark the sub-expression) 157 157 // or negative (for perl style (?...) extentions): 158 158 int index; 159 std::ptrdiff_t position ; 159 160 }; 160 161 161 162 /*** struct re_dot **************************************************