/[pcre]/code/trunk/pcre_compile.c
ViewVC logotype

Diff of /code/trunk/pcre_compile.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 487 by ph10, Wed Jan 6 10:26:55 2010 UTC revision 488 by ph10, Mon Jan 11 15:29:42 2010 UTC
# Line 5590  we set the flag only if there is a liter Line 5590  we set the flag only if there is a liter
5590    
5591        if (-c >= ESC_REF)        if (-c >= ESC_REF)
5592          {          {
5593            open_capitem *oc;
5594          recno = -c - ESC_REF;          recno = -c - ESC_REF;
5595    
5596          HANDLE_REFERENCE:    /* Come here from named backref handling */          HANDLE_REFERENCE:    /* Come here from named backref handling */
# Line 5599  we set the flag only if there is a liter Line 5600  we set the flag only if there is a liter
5600          PUT2INC(code, 0, recno);          PUT2INC(code, 0, recno);
5601          cd->backref_map |= (recno < 32)? (1 << recno) : 1;          cd->backref_map |= (recno < 32)? (1 << recno) : 1;
5602          if (recno > cd->top_backref) cd->top_backref = recno;          if (recno > cd->top_backref) cd->top_backref = recno;
5603    
5604            /* Check to see if this back reference is recursive, that it, it
5605            is inside the group that it references. A flag is set so that the
5606            group can be made atomic. */
5607    
5608            for (oc = cd->open_caps; oc != NULL; oc = oc->next)
5609              {
5610              if (oc->number == recno)
5611                {
5612                oc->flag = TRUE;
5613                break;
5614                }
5615              }
5616          }          }
5617    
5618        /* So are Unicode property matches, if supported. */        /* So are Unicode property matches, if supported. */
# Line 5811  them global. It tests the value of lengt Line 5825  them global. It tests the value of lengt
5825  pre-compile phase to find out whether anything has yet been compiled or not. */  pre-compile phase to find out whether anything has yet been compiled or not. */
5826    
5827  /* If this is a capturing subpattern, add to the chain of open capturing items  /* If this is a capturing subpattern, add to the chain of open capturing items
5828  so that we can detect them if (*ACCEPT) is encountered. */  so that we can detect them if (*ACCEPT) is encountered. This is also used to
5829    detect groups that contain recursive back references to themselves. */
5830    
5831  if (*code == OP_CBRA)  if (*code == OP_CBRA)
5832    {    {
5833    capnumber = GET2(code, 1 + LINK_SIZE);    capnumber = GET2(code, 1 + LINK_SIZE);
5834    capitem.number = capnumber;    capitem.number = capnumber;
5835    capitem.next = cd->open_caps;    capitem.next = cd->open_caps;
5836      capitem.flag = FALSE;
5837    cd->open_caps = &capitem;    cd->open_caps = &capitem;
5838    }    }
5839    
# Line 5974  for (;;) Line 5990  for (;;)
5990        while (branch_length > 0);        while (branch_length > 0);
5991        }        }
5992    
     /* If it was a capturing subpattern, remove it from the chain. */  
   
     if (capnumber > 0) cd->open_caps = cd->open_caps->next;  
   
5993      /* Fill in the ket */      /* Fill in the ket */
5994    
5995      *code = OP_KET;      *code = OP_KET;
5996      PUT(code, 1, code - start_bracket);      PUT(code, 1, code - start_bracket);
5997      code += 1 + LINK_SIZE;      code += 1 + LINK_SIZE;
5998    
5999        /* If it was a capturing subpattern, check to see if it contained any
6000        recursive back references. If so, we must wrap it in atomic brackets.
6001        In any event, remove the block from the chain. */
6002    
6003        if (capnumber > 0)
6004          {
6005          if (cd->open_caps->flag)
6006            {
6007            memmove(start_bracket + 1 + LINK_SIZE, start_bracket,
6008              code - start_bracket);
6009            *start_bracket = OP_ONCE;
6010            code += 1 + LINK_SIZE;
6011            PUT(start_bracket, 1, code - start_bracket);
6012            *code = OP_KET;
6013            PUT(code, 1, code - start_bracket);
6014            code += 1 + LINK_SIZE;
6015            length += 2 + 2*LINK_SIZE;
6016            }
6017          cd->open_caps = cd->open_caps->next;
6018          }
6019    
6020      /* Reset options if needed. */      /* Reset options if needed. */
6021    
6022      if ((options & PCRE_IMS) != oldims && *ptr == CHAR_RIGHT_PARENTHESIS)      if ((options & PCRE_IMS) != oldims && *ptr == CHAR_RIGHT_PARENTHESIS)

Legend:
Removed from v.487  
changed lines
  Added in v.488

  ViewVC Help
Powered by ViewVC 1.1.5