Ticket #2269: regex.patch
File regex.patch, 4.3 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 ptrdiff_t position = this->m_expression_len ; 155 156 if(!mark_count() && index < mark_count()) 157 return mark ; 158 159 mark.first = mark.second = this->m_expression ; 160 161 if(index == 0) 162 { 163 while(position--) mark.second++ ; // We seek after the last 164 return mark ; 165 } 166 167 ::boost::re_detail::re_syntax_base const * state = get_first_state() ; 168 ::boost::re_detail::re_brace const * state_brace = 0 ; 169 170 do 171 { 172 if(state->type != ::boost::re_detail::syntax_element_startmark 173 && state->type != ::boost::re_detail::syntax_element_endmark) 174 continue ; 175 176 state_brace = static_cast<re_brace const *>(state) ; 177 if(state_brace->index != (int) index) 178 continue ; 179 180 ptrdiff_t position = state_brace->position ; 181 if(state_brace->type == ::boost::re_detail::syntax_element_startmark) 182 while(--position) mark.first++ ; // We seek on '(' 183 else if(state_brace->type == ::boost::re_detail::syntax_element_endmark) 184 { 185 while(position--) mark.second++ ; // We seek after ')' 186 state = 0 ; 187 break ; 188 } 189 190 } while((state = state->next.p)) ; 191 192 return mark ; 193 } 194 151 195 const re_detail::re_syntax_base* get_first_state()const 152 196 { 153 197 return this->m_first_state; … … 405 449 return (m_pimpl.get() ? m_pimpl->mark_count() : 0); 406 450 } 407 451 452 std::pair<const_iterator, const_iterator> BOOST_REGEX_CALL get_mark(size_type index)const 453 { 454 return (m_pimpl.get() ? m_pimpl->get_mark(index) : std::pair<const_iterator, const_iterator>(0,0)); 455 } 456 408 457 int status()const 409 458 { 410 459 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) ; 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) ; 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 **************************************************