[Pcre-svn] [501] code/trunk: Preparation code for future (*M…

Página Inicial
Delete this message
Autor: Subversion repository
Data:  
Para: pcre-svn
Assunto: [Pcre-svn] [501] code/trunk: Preparation code for future (*MARK) support.
Revision: 501
          http://vcs.pcre.org/viewvc?view=rev&revision=501
Author:   ph10
Date:     2010-03-07 11:49:54 +0000 (Sun, 07 Mar 2010)


Log Message:
-----------
Preparation code for future (*MARK) support.

Modified Paths:
--------------
    code/trunk/ChangeLog
    code/trunk/pcre_exec.c


Modified: code/trunk/ChangeLog
===================================================================
--- code/trunk/ChangeLog    2010-03-06 19:00:29 UTC (rev 500)
+++ code/trunk/ChangeLog    2010-03-07 11:49:54 UTC (rev 501)
@@ -45,6 +45,12 @@
     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

Modified: code/trunk/pcre_exec.c
===================================================================
--- code/trunk/pcre_exec.c    2010-03-06 19:00:29 UTC (rev 500)
+++ code/trunk/pcre_exec.c    2010-03-07 11:49:54 UTC (rev 501)
@@ -249,7 +249,7 @@


/* 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 @@
#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 @@
}
#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 @@
   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 @@
   USPTR Xeptr;
   const uschar *Xecode;
   USPTR Xmstart;
+  USPTR Xmarkptr;
   int Xoffset_top;
   long int Xims;
   eptrblock *Xeptrb;
@@ -432,6 +434,7 @@
    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 @@
 */


 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->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 @@
 #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 @@
       {
       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 @@
     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 @@
   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)