# HG changeset patch # User David Bateman # Date 1270856232 -7200 # Node ID 33940de7c082260e4d0a225116ba5f618d05c9f7 # Parent fcf6341a8cab698f72b8c49f9e6634579f83c94f Properly ignore zero-length matches in named tokens diff --git a/src/ChangeLog b/src/ChangeLog --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2010-04-09 David Bateman + + * DLD-FUNCTIONS/regexp.cc (octregexp_list): Properly ignore + zero-length matches in named tokens. + 2010-04-09 John W. Eaton * ov-ch-mat.h (octave_char_matrix::mex_get_data): New function. diff --git a/src/DLD-FUNCTIONS/regexp.cc b/src/DLD-FUNCTIONS/regexp.cc --- a/src/DLD-FUNCTIONS/regexp.cc +++ b/src/DLD-FUNCTIONS/regexp.cc @@ -462,14 +462,8 @@ string_vector named_tokens(nnames); if (namecount > 0) - for (int i = 1; i < matches; i++) - { - if (ovector[2*i] >= 0 && ovector[2*i+1] > 0) - { - named_tokens(named_idx(i-1)) = - std::string(*(listptr+nidx[i-1])); - } - } + for (int i = 0; i < pos_match; i++) + named_tokens(named_idx(i)) = std::string(*(listptr+nidx[i])); pcre_free_substring_list(listptr);