[Pcre-svn] [616] code/trunk: Add the ++ feature to pcretest.

トップ ページ
このメッセージを削除
著者: Subversion repository
日付:  
To: pcre-svn
題目: [Pcre-svn] [616] code/trunk: Add the ++ feature to pcretest.
Revision: 616
          http://vcs.pcre.org/viewvc?view=rev&revision=616
Author:   ph10
Date:     2011-07-11 16:55:25 +0100 (Mon, 11 Jul 2011)


Log Message:
-----------
Add the ++ feature to pcretest.

Modified Paths:
--------------
    code/trunk/ChangeLog
    code/trunk/doc/pcretest.1
    code/trunk/pcretest.c


Modified: code/trunk/ChangeLog
===================================================================
--- code/trunk/ChangeLog    2011-07-11 14:23:06 UTC (rev 615)
+++ code/trunk/ChangeLog    2011-07-11 15:55:25 UTC (rev 616)
@@ -122,6 +122,10 @@
     branched capturing and non-capturing groups, repeated or not, and also to 
     positive assertions (capturing in negative assertions is not well defined 
     in PCRE) and also to nested atomic groups. 
+    
+23. Add the ++ qualifier feature to pcretest, to show the remainder of the 
+    subject after a captured substring (to make it easier to tell which of a 
+    number of identical substrings has been captured).



Version 8.12 15-Jan-2011

Modified: code/trunk/doc/pcretest.1
===================================================================
--- code/trunk/doc/pcretest.1    2011-07-11 14:23:06 UTC (rev 615)
+++ code/trunk/doc/pcretest.1    2011-07-11 15:55:25 UTC (rev 616)
@@ -254,9 +254,12 @@
 operates.
 .P
 The \fB/+\fP modifier requests that as well as outputting the substring that
-matched the entire pattern, pcretest should in addition output the remainder of
-the subject string. This is useful for tests where the subject contains
-multiple copies of the same substring.
+matched the entire pattern, \fBpcretest\fP should in addition output the
+remainder of the subject string. This is useful for tests where the subject
+contains multiple copies of the same substring. If the \fB+\fP modifier appears
+twice, the same action is taken for captured substrings. In each case the 
+remainder is output on the following line with a plus character following the 
+capture number.
 .P
 The \fB/B\fP modifier is a debugging feature. It requests that \fBpcretest\fP
 output a representation of the compiled byte code after compilation. Normally
@@ -812,6 +815,6 @@
 .rs
 .sp
 .nf
-Last updated: 02 July 2011
+Last updated: 11 July 2011
 Copyright (c) 1997-2011 University of Cambridge.
 .fi


Modified: code/trunk/pcretest.c
===================================================================
--- code/trunk/pcretest.c    2011-07-11 14:23:06 UTC (rev 615)
+++ code/trunk/pcretest.c    2011-07-11 15:55:25 UTC (rev 616)
@@ -1442,6 +1442,7 @@
   int do_g = 0;
   int do_showinfo = showinfo;
   int do_showrest = 0;
+  int do_showcaprest = 0;
   int do_flip = 0;
   int erroroffset, len, delimiter, poffset;


@@ -1607,7 +1608,10 @@
       case 's': options |= PCRE_DOTALL; break;
       case 'x': options |= PCRE_EXTENDED; break;


-      case '+': do_showrest = 1; break;
+      case '+':
+      if (do_showrest) do_showcaprest = 1; else do_showrest = 1; 
+      break;
+       
       case 'A': options |= PCRE_ANCHORED; break;
       case 'B': do_debug = 1; break;
       case 'C': options |= PCRE_AUTO_CALLOUT; break;
@@ -2587,9 +2591,9 @@
             (void)pchars(dbuffer + pmatch[i].rm_so,
               pmatch[i].rm_eo - pmatch[i].rm_so, outfile);
             fprintf(outfile, "\n");
-            if (i == 0 && do_showrest)
+            if (do_showcaprest || (i == 0 && do_showrest))
               {
-              fprintf(outfile, " 0+ ");
+              fprintf(outfile, "%2d+ ", (int)i);
               (void)pchars(dbuffer + pmatch[i].rm_eo, len - pmatch[i].rm_eo,
                 outfile);
               fprintf(outfile, "\n");
@@ -2741,15 +2745,12 @@
             (void)pchars(bptr + use_offsets[i],
               use_offsets[i+1] - use_offsets[i], outfile);
             fprintf(outfile, "\n");
-            if (i == 0)
+            if (do_showcaprest || (i == 0 && do_showrest))
               {
-              if (do_showrest)
-                {
-                fprintf(outfile, " 0+ ");
-                (void)pchars(bptr + use_offsets[i+1], len - use_offsets[i+1],
-                  outfile);
-                fprintf(outfile, "\n");
-                }
+              fprintf(outfile, "%2d+ ", i/2);
+              (void)pchars(bptr + use_offsets[i+1], len - use_offsets[i+1],
+                outfile);
+              fprintf(outfile, "\n");
               }
             }
           }