diff options
author | ph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15> | 2009-09-15 10:49:50 +0000 |
---|---|---|
committer | ph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15> | 2009-09-15 10:49:50 +0000 |
commit | efd42072fc347bc5f9e2af584f79286553c3efb2 (patch) | |
tree | b7b50f8b8350519bb563e954284be1205720d2c6 | |
parent | 6b65540312611f321988db8246f6c28d181be76f (diff) | |
download | pcre-efd42072fc347bc5f9e2af584f79286553c3efb2.tar.gz |
Correct returned capture count after recursion has matched more than outer.
git-svn-id: svn://vcs.exim.org/pcre/code/trunk@446 2f5784b3-3f2a-0410-8824-cb99058d5e15
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | pcre_exec.c | 7 | ||||
-rw-r--r-- | pcre_internal.h | 1 |
3 files changed, 11 insertions, 2 deletions
@@ -118,6 +118,11 @@ Version 8.00 ??-???-?? to have an empty string match not at the start, even when the pattern is anchored. Updated pcretest and pcredemo to use this option. +21. If the maximum number of capturing subpatterns in a recursion was greater + than the maximum at the outer level, the higher number was returned, but + with unset values at the outer level. The correct (outer level) value is + now given. + Version 7.9 11-Apr-09 --------------------- diff --git a/pcre_exec.c b/pcre_exec.c index 5fbe373..7107426 100644 --- a/pcre_exec.c +++ b/pcre_exec.c @@ -924,6 +924,7 @@ for (;;) md->recursive = rec->prevrec; memmove(md->offset_vector, rec->offset_save, rec->saved_max * sizeof(int)); + offset_top = rec->offset_top; mstart = rec->save_start; ims = original_ims; ecode = rec->after_call; @@ -1115,6 +1116,7 @@ for (;;) memcpy(new_recursive.offset_save, md->offset_vector, new_recursive.saved_max * sizeof(int)); new_recursive.save_start = mstart; + new_recursive.offset_top = offset_top; mstart = eptr; /* OK, now we can do the recursion. For each top-level alternative we @@ -1313,7 +1315,7 @@ for (;;) { number = GET2(prev, 1+LINK_SIZE); offset = number << 1; - + #ifdef DEBUG printf("end bracket %d", number); printf("\n"); @@ -1339,6 +1341,7 @@ for (;;) mstart = rec->save_start; memcpy(md->offset_vector, rec->offset_save, rec->saved_max * sizeof(int)); + offset_top = rec->offset_top; ecode = rec->after_call; ims = original_ims; break; @@ -5408,7 +5411,7 @@ if (rc == MATCH_MATCH) too many to fit into the vector. */ rc = md->offset_overflow? 0 : md->end_offset_top/2; - + /* If there is space, set up the whole thing as substring 0. The value of md->start_match_ptr might be modified if \K was encountered on the success matching path. */ diff --git a/pcre_internal.h b/pcre_internal.h index ba3c018..c6a1870 100644 --- a/pcre_internal.h +++ b/pcre_internal.h @@ -1568,6 +1568,7 @@ typedef struct recursion_info { USPTR save_start; /* Old value of mstart */ int *offset_save; /* Pointer to start of saved offsets */ int saved_max; /* Number of saved offsets */ + int offset_top; /* Current value of offset_top */ } recursion_info; /* Structure for building a chain of data for holding the values of the subject |