summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15>2010-03-07 11:49:54 +0000
committerph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15>2010-03-07 11:49:54 +0000
commit86c2bb189a273c60fd06a118b2a8c9413996c357 (patch)
treed98e9a22b564ed8d3dc3ae5affa6d03c0dc816ae
parent2878ed98d792c02f7c9f7b4832016f55ad1db1ee (diff)
downloadpcre-86c2bb189a273c60fd06a118b2a8c9413996c357.tar.gz
Preparation code for future (*MARK) support.
git-svn-id: svn://vcs.exim.org/pcre/code/trunk@501 2f5784b3-3f2a-0410-8824-cb99058d5e15
-rw-r--r--ChangeLog6
-rw-r--r--pcre_exec.c28
2 files changed, 23 insertions, 11 deletions
diff --git a/ChangeLog b/ChangeLog
index f14172c..20ee4dc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -45,6 +45,12 @@ Version 8.02 01-Mar-2010
was called as a "subroutine", or in an assertion. Perl 5.11 documents that
\K is "not well defined" if used in an assertion. PCRE now accepts it if
the assertion is positive, but not if it is negative.
+
+12. Change 11 fortuitously reduced the size of the stack frame used in the
+ "match()" function of pcre_exec.c by one pointer. Forthcoming
+ implementation of support for (*MARK) will need an extra pointer on the
+ stack; I have reserved it now, so that the stack frame size does not
+ decrease.
Version 8.01 19-Jan-2010
diff --git a/pcre_exec.c b/pcre_exec.c
index 2734723..0f3176a 100644
--- a/pcre_exec.c
+++ b/pcre_exec.c
@@ -249,7 +249,7 @@ enum { RM1=1, RM2, RM3, RM4, RM5, RM6, RM7, RM8, RM9, RM10,
/* These versions of the macros use the stack, as normal. There are debugging
versions and production versions. Note that the "rw" argument of RMATCH isn't
-actuall used in this definition. */
+actually used in this definition. */
#ifndef NO_RECURSE
#define REGISTER register
@@ -258,7 +258,7 @@ actuall used in this definition. */
#define RMATCH(ra,rb,rc,rd,re,rf,rg,rw) \
{ \
printf("match() called in line %d\n", __LINE__); \
- rrc = match(ra,rb,mstart,rc,rd,re,rf,rg,rdepth+1); \
+ rrc = match(ra,rb,mstart,markptr,rc,rd,re,rf,rg,rdepth+1); \
printf("to line %d\n", __LINE__); \
}
#define RRETURN(ra) \
@@ -268,7 +268,7 @@ actuall used in this definition. */
}
#else
#define RMATCH(ra,rb,rc,rd,re,rf,rg,rw) \
- rrc = match(ra,rb,mstart,rc,rd,re,rf,rg,rdepth+1)
+ rrc = match(ra,rb,mstart,markptr,rc,rd,re,rf,rg,rdepth+1)
#define RRETURN(ra) return ra
#endif
@@ -288,6 +288,7 @@ argument of match(), which never changes. */
newframe->Xeptr = ra;\
newframe->Xecode = rb;\
newframe->Xmstart = mstart;\
+ newframe->Xmarkptr = markptr;\
newframe->Xoffset_top = rc;\
newframe->Xims = re;\
newframe->Xeptrb = rf;\
@@ -325,6 +326,7 @@ typedef struct heapframe {
USPTR Xeptr;
const uschar *Xecode;
USPTR Xmstart;
+ USPTR Xmarkptr;
int Xoffset_top;
long int Xims;
eptrblock *Xeptrb;
@@ -432,6 +434,7 @@ Arguments:
ecode pointer to current position in compiled code
mstart pointer to the current match start position (can be modified
by encountering \K)
+ markptr pointer to the most recent MARK name, or NULL
offset_top current top pointer
md pointer to "static" info for the match
ims current /i, /m, and /s options
@@ -450,9 +453,9 @@ Returns: MATCH_MATCH if matched ) these values are >= 0
*/
static int
-match(REGISTER USPTR eptr, REGISTER const uschar *ecode, USPTR mstart,
- int offset_top, match_data *md, unsigned long int ims, eptrblock *eptrb,
- int flags, unsigned int rdepth)
+match(REGISTER USPTR eptr, REGISTER const uschar *ecode, USPTR mstart, USPTR
+ markptr, int offset_top, match_data *md, unsigned long int ims,
+ eptrblock *eptrb, int flags, unsigned int rdepth)
{
/* These variables do not need to be preserved over recursion in this function,
so they can be ordinary variables in all cases. Mark some of them with
@@ -480,6 +483,7 @@ frame->Xprevframe = NULL; /* Marks the top level */
frame->Xeptr = eptr;
frame->Xecode = ecode;
frame->Xmstart = mstart;
+frame->Xmarkptr = markptr;
frame->Xoffset_top = offset_top;
frame->Xims = ims;
frame->Xeptrb = eptrb;
@@ -495,6 +499,7 @@ HEAP_RECURSE:
#define eptr frame->Xeptr
#define ecode frame->Xecode
#define mstart frame->Xmstart
+#define markptr frame->Xmarkptr
#define offset_top frame->Xoffset_top
#define ims frame->Xims
#define eptrb frame->Xeptrb
@@ -1113,11 +1118,11 @@ for (;;)
{
RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, NULL, 0,
RM4);
- if (rrc == MATCH_MATCH)
+ if (rrc == MATCH_MATCH)
{
mstart = md->start_match_ptr; /* In case \K reset it */
break;
- }
+ }
if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc);
ecode += GET(ecode, 1);
}
@@ -1327,11 +1332,11 @@ for (;;)
do
{
RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, eptrb, 0, RM7);
- if (rrc == MATCH_MATCH)
+ if (rrc == MATCH_MATCH)
{
mstart = md->start_match_ptr;
break;
- }
+ }
if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc);
ecode += GET(ecode,1);
}
@@ -5658,7 +5663,8 @@ for(;;)
md->start_match_ptr = start_match;
md->start_used_ptr = start_match;
md->match_call_count = 0;
- rc = match(start_match, md->start_code, start_match, 2, md, ims, NULL, 0, 0);
+ rc = match(start_match, md->start_code, start_match, NULL, 2, md, ims, NULL,
+ 0, 0);
if (md->hitend && start_partial == NULL) start_partial = md->start_used_ptr;
switch(rc)