changeset 10504:33940de7c082

Properly ignore zero-length matches in named tokens
author David Bateman <dbateman@free.fr>
date Sat, 10 Apr 2010 01:37:12 +0200
parents fcf6341a8cab
children 82ee24bf783c
files src/ChangeLog src/DLD-FUNCTIONS/regexp.cc
diffstat 2 files changed, 7 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Fri Apr 09 13:59:13 2010 -0400
+++ b/src/ChangeLog	Sat Apr 10 01:37:12 2010 +0200
@@ -1,3 +1,8 @@
+2010-04-09  David Bateman  <dbateman@free.fr>
+
+	* DLD-FUNCTIONS/regexp.cc (octregexp_list): Properly ignore
+	zero-length matches in named tokens.
+
 2010-04-09  John W. Eaton  <jwe@octave.org>
 
 	* ov-ch-mat.h (octave_char_matrix::mex_get_data): New function.
--- a/src/DLD-FUNCTIONS/regexp.cc	Fri Apr 09 13:59:13 2010 -0400
+++ b/src/DLD-FUNCTIONS/regexp.cc	Sat Apr 10 01:37:12 2010 +0200
@@ -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);