[Pcre-svn] [496] code/trunk: Fix DEFINE bug for forward refe…

Página Inicial
Delete this message
Autor: Subversion repository
Data:  
Para: pcre-svn
Assunto: [Pcre-svn] [496] code/trunk: Fix DEFINE bug for forward reference with a possessive quantifier.
Revision: 496
          http://vcs.pcre.org/viewvc?view=rev&revision=496
Author:   ph10
Date:     2010-03-02 19:11:17 +0000 (Tue, 02 Mar 2010)


Log Message:
-----------
Fix DEFINE bug for forward reference with a possessive quantifier.

Modified Paths:
--------------
    code/trunk/ChangeLog
    code/trunk/pcre_compile.c
    code/trunk/testdata/testinput2
    code/trunk/testdata/testoutput2


Modified: code/trunk/ChangeLog
===================================================================
--- code/trunk/ChangeLog    2010-03-02 11:56:59 UTC (rev 495)
+++ code/trunk/ChangeLog    2010-03-02 19:11:17 UTC (rev 496)
@@ -14,6 +14,11 @@


 4.  On systems that do not have stdint.h (e.g. Solaris), check for and include 
     inttypes.h instead. This fixes a bug that was introduced by change 8.01/8.
+    
+5.  A pattern such as (?&t)*+(?(DEFINE)(?<t>.)) which has a possessive
+    quantifier applied to a forward-referencing subroutine call, could compile
+    incorrect code or give the error "internal error: previously-checked
+    referenced subpattern not found".



Version 8.01 19-Jan-2010

Modified: code/trunk/pcre_compile.c
===================================================================
--- code/trunk/pcre_compile.c    2010-03-02 11:56:59 UTC (rev 495)
+++ code/trunk/pcre_compile.c    2010-03-02 19:11:17 UTC (rev 496)
@@ -4430,7 +4430,12 @@
         case OP_NOTQUERY: *tempcode = OP_NOTPOSQUERY; break;
         case OP_NOTUPTO:  *tempcode = OP_NOTPOSUPTO; break;


+        /* Because we are moving code along, we must ensure that any
+        pending recursive references are updated. */
+          
         default:
+        *code = OP_END;
+        adjust_recurse(tempcode, 1 + LINK_SIZE, utf8, cd, save_hwm);
         memmove(tempcode + 1+LINK_SIZE, tempcode, len);
         code += 1 + LINK_SIZE;
         len += 1 + LINK_SIZE;
@@ -5149,6 +5154,11 @@
                 *errorcodeptr = ERR15;
                 goto FAILED;
                 }
+                 
+              /* Fudge the value of "called" so that when it is inserted as an
+              offset below, what it actually inserted is the reference number 
+              of the group. */
+                
               called = cd->start_code + recno;
               PUTINC(cd->hwm, 0, code + 2 + LINK_SIZE - cd->start_code);
               }
@@ -6804,7 +6814,6 @@
 case when building a production library. */


#ifdef PCRE_DEBUG
-
printf("Length = %d top_bracket = %d top_backref = %d\n",
length, re->top_bracket, re->top_backref);


Modified: code/trunk/testdata/testinput2
===================================================================
--- code/trunk/testdata/testinput2    2010-03-02 11:56:59 UTC (rev 495)
+++ code/trunk/testdata/testinput2    2010-03-02 19:11:17 UTC (rev 496)
@@ -3203,5 +3203,9 @@


 /^(ab(c\1)d|x){2}$/BZ
     xabcxd
+    
+/^(?&t)*+(?(DEFINE)(?<t>.))$/BZ


+/^(?&t)*(?(DEFINE)(?<t>.))$/BZ
+
/-- End of testinput2 --/

Modified: code/trunk/testdata/testoutput2
===================================================================
--- code/trunk/testdata/testoutput2    2010-03-02 11:56:59 UTC (rev 495)
+++ code/trunk/testdata/testoutput2    2010-03-02 19:11:17 UTC (rev 496)
@@ -10596,5 +10596,45 @@
  0: xabcxd
  1: abcxd
  2: cx
+    
+/^(?&t)*+(?(DEFINE)(?<t>.))$/BZ
+------------------------------------------------------------------
+        Bra
+        ^
+        Once
+        Brazero
+        Once
+        Recurse
+        KetRmax
+        Ket
+        Cond
+        Cond def
+        CBra 1
+        Any
+        Ket
+        Ket
+        $
+        Ket
+        End
+------------------------------------------------------------------


+/^(?&t)*(?(DEFINE)(?<t>.))$/BZ
+------------------------------------------------------------------
+        Bra
+        ^
+        Brazero
+        Once
+        Recurse
+        KetRmax
+        Cond
+        Cond def
+        CBra 1
+        Any
+        Ket
+        Ket
+        $
+        Ket
+        End
+------------------------------------------------------------------
+
 /-- End of testinput2 --/