[Pcre-svn] [645] code/trunk: Pass *MARK name to callouts

トップ ページ
このメッセージを削除
著者: Subversion repository
日付:  
To: pcre-svn
題目: [Pcre-svn] [645] code/trunk: Pass *MARK name to callouts
Revision: 645
          http://vcs.pcre.org/viewvc?view=rev&revision=645
Author:   ph10
Date:     2011-07-31 18:02:18 +0100 (Sun, 31 Jul 2011)


Log Message:
-----------
Pass *MARK name to callouts

Modified Paths:
--------------
    code/trunk/ChangeLog
    code/trunk/doc/pcrecallout.3
    code/trunk/pcre.h.in
    code/trunk/pcre_dfa_exec.c
    code/trunk/pcre_exec.c
    code/trunk/pcretest.c


Modified: code/trunk/ChangeLog
===================================================================
--- code/trunk/ChangeLog    2011-07-30 17:13:00 UTC (rev 644)
+++ code/trunk/ChangeLog    2011-07-31 17:02:18 UTC (rev 645)
@@ -234,6 +234,8 @@


     (e) If a line being scanned overflows pcregrep's buffer, an error is now 
         given and the return code is set to 2.
+        
+44. Add a pointer to the latest mark to the callout data block. 



Version 8.12 15-Jan-2011

Modified: code/trunk/doc/pcrecallout.3
===================================================================
--- code/trunk/doc/pcrecallout.3    2011-07-30 17:13:00 UTC (rev 644)
+++ code/trunk/doc/pcrecallout.3    2011-07-31 17:02:18 UTC (rev 645)
@@ -75,21 +75,22 @@
 only argument to the callout function is a pointer to a \fBpcre_callout\fP
 block. This structure contains the following fields:
 .sp
-  int          \fIversion\fP;
-  int          \fIcallout_number\fP;
-  int         *\fIoffset_vector\fP;
-  const char  *\fIsubject\fP;
-  int          \fIsubject_length\fP;
-  int          \fIstart_match\fP;
-  int          \fIcurrent_position\fP;
-  int          \fIcapture_top\fP;
-  int          \fIcapture_last\fP;
-  void        *\fIcallout_data\fP;
-  int          \fIpattern_position\fP;
-  int          \fInext_item_length\fP;
+  int         \fIversion\fP;
+  int         \fIcallout_number\fP;
+  int        *\fIoffset_vector\fP;
+  const char *\fIsubject\fP;
+  int         \fIsubject_length\fP;
+  int         \fIstart_match\fP;
+  int         \fIcurrent_position\fP;
+  int         \fIcapture_top\fP;
+  int         \fIcapture_last\fP;
+  void       *\fIcallout_data\fP;
+  int         \fIpattern_position\fP;
+  int         \fInext_item_length\fP;
+  const unsigned char *\fImark\fP; 
 .sp
 The \fIversion\fP field is an integer containing the version number of the
-block format. The initial version was 0; the current version is 1. The version
+block format. The initial version was 0; the current version is 2. The version
 number will change again in future if additional fields are added, but the
 intention is never to remove any of the existing fields.
 .P
@@ -152,6 +153,12 @@
 The \fIpattern_position\fP and \fInext_item_length\fP fields are intended to
 help in distinguishing between different automatic callouts, which all have the
 same callout number. However, they are set for all callouts.
+.P
+The \fImark\fP field is present from version 2 of the \fIpcre_callout\fP 
+structure. In callouts from \fBpcre_exec()\fP it contains a pointer to the 
+zero-terminated name of the most recently passed (*MARK) item in the match, or
+NULL if there are no (*MARK)s in the current matching path. In callouts from
+\fBpcre_dfa_exec()\fP this field always contains NULL.
 .
 .
 .SH "RETURN VALUES"
@@ -184,6 +191,6 @@
 .rs
 .sp
 .nf
-Last updated: 21 November 2010
-Copyright (c) 1997-2010 University of Cambridge.
+Last updated: 31 July 2011
+Copyright (c) 1997-2011 University of Cambridge.
 .fi


Modified: code/trunk/pcre.h.in
===================================================================
--- code/trunk/pcre.h.in    2011-07-30 17:13:00 UTC (rev 644)
+++ code/trunk/pcre.h.in    2011-07-31 17:02:18 UTC (rev 645)
@@ -280,6 +280,8 @@
   /* ------------------- Added for Version 1 -------------------------- */
   int          pattern_position;  /* Offset to next item in the pattern */
   int          next_item_length;  /* Length of next item in the pattern */
+  /* ------------------- Added for Version 2 -------------------------- */
+  const unsigned char *mark;      /* Pointer to current mark or NULL    */ 
   /* ------------------------------------------------------------------ */
 } pcre_callout_block;



Modified: code/trunk/pcre_dfa_exec.c
===================================================================
--- code/trunk/pcre_dfa_exec.c    2011-07-30 17:13:00 UTC (rev 644)
+++ code/trunk/pcre_dfa_exec.c    2011-07-31 17:02:18 UTC (rev 645)
@@ -2560,6 +2560,7 @@
             cb.capture_top      = 1;
             cb.capture_last     = -1;
             cb.callout_data     = md->callout_data;
+            cb.mark             = NULL;   /* No (*MARK) support */ 
             if ((rrc = (*pcre_callout)(&cb)) < 0) return rrc;   /* Abandon */
             }
           if (rrc > 0) break;                      /* Fail this thread */
@@ -2891,6 +2892,7 @@
         cb.capture_top      = 1;
         cb.capture_last     = -1;
         cb.callout_data     = md->callout_data;
+        cb.mark             = NULL;   /* No (*MARK) support */ 
         if ((rrc = (*pcre_callout)(&cb)) < 0) return rrc;   /* Abandon */
         }
       if (rrc == 0)


Modified: code/trunk/pcre_exec.c
===================================================================
--- code/trunk/pcre_exec.c    2011-07-30 17:13:00 UTC (rev 644)
+++ code/trunk/pcre_exec.c    2011-07-31 17:02:18 UTC (rev 645)
@@ -1070,7 +1070,7 @@
       if (pcre_callout != NULL)
         {
         pcre_callout_block cb;
-        cb.version          = 1;   /* Version 1 of the callout block */
+        cb.version          = 2;   /* Version 1 of the callout block */
         cb.callout_number   = ecode[LINK_SIZE+2];
         cb.offset_vector    = md->offset_vector;
         cb.subject          = (PCRE_SPTR)md->start_subject;
@@ -1082,6 +1082,7 @@
         cb.capture_top      = offset_top/2;
         cb.capture_last     = md->capture_last;
         cb.callout_data     = md->callout_data;
+        cb.mark             = markptr; 
         if ((rrc = (*pcre_callout)(&cb)) > 0) MRRETURN(MATCH_NOMATCH);
         if (rrc < 0) RRETURN(rrc);
         }
@@ -1464,7 +1465,7 @@
     if (pcre_callout != NULL)
       {
       pcre_callout_block cb;
-      cb.version          = 1;   /* Version 1 of the callout block */
+      cb.version          = 2;   /* Version 1 of the callout block */
       cb.callout_number   = ecode[1];
       cb.offset_vector    = md->offset_vector;
       cb.subject          = (PCRE_SPTR)md->start_subject;
@@ -1476,6 +1477,7 @@
       cb.capture_top      = offset_top/2;
       cb.capture_last     = md->capture_last;
       cb.callout_data     = md->callout_data;
+      cb.mark             = markptr; 
       if ((rrc = (*pcre_callout)(&cb)) > 0) MRRETURN(MATCH_NOMATCH);
       if (rrc < 0) RRETURN(rrc);
       }


Modified: code/trunk/pcretest.c
===================================================================
--- code/trunk/pcretest.c    2011-07-30 17:13:00 UTC (rev 644)
+++ code/trunk/pcretest.c    2011-07-31 17:02:18 UTC (rev 645)
@@ -189,6 +189,7 @@
 static int show_malloc;
 static int use_utf8;
 static size_t gotten_store;
+static const unsigned char *last_callout_mark = NULL;


/* The buffers grow automatically if very long input lines are encountered. */

@@ -960,6 +961,13 @@
fprintf(outfile, "\n");
first_callout = 0;

+if (cb->mark != last_callout_mark) 
+  {
+  fprintf(outfile, "Latest Mark: %s\n", 
+    (cb->mark == NULL)? "<unset>" : (char *)(cb->mark));
+  last_callout_mark = cb->mark; 
+  } 
+
 if (cb->callout_data != NULL)
   {
   int callout_data = *((int *)(cb->callout_data));
@@ -2211,6 +2219,7 @@


     pcre_callout = callout;
     first_callout = 1;
+    last_callout_mark = NULL;    
     callout_extra = 0;
     callout_count = 0;
     callout_fail_count = 999999;