/[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 496 by ph10, Tue Mar 2 19:11:17 2010 UTC
# Line 4430  we set the flag only if there is a liter Line 4430  we set the flag only if there is a liter
4430          case OP_NOTQUERY: *tempcode = OP_NOTPOSQUERY; break;          case OP_NOTQUERY: *tempcode = OP_NOTPOSQUERY; break;
4431          case OP_NOTUPTO:  *tempcode = OP_NOTPOSUPTO; break;          case OP_NOTUPTO:  *tempcode = OP_NOTPOSUPTO; break;
4432    
4433            /* Because we are moving code along, we must ensure that any
4434            pending recursive references are updated. */
4435    
4436          default:          default:
4437            *code = OP_END;
4438            adjust_recurse(tempcode, 1 + LINK_SIZE, utf8, cd, save_hwm);
4439          memmove(tempcode + 1+LINK_SIZE, tempcode, len);          memmove(tempcode + 1+LINK_SIZE, tempcode, len);
4440          code += 1 + LINK_SIZE;          code += 1 + LINK_SIZE;
4441          len += 1 + LINK_SIZE;          len += 1 + LINK_SIZE;
# Line 5149  we set the flag only if there is a liter Line 5154  we set the flag only if there is a liter
5154                  *errorcodeptr = ERR15;                  *errorcodeptr = ERR15;
5155                  goto FAILED;                  goto FAILED;
5156                  }                  }
5157    
5158                  /* Fudge the value of "called" so that when it is inserted as an
5159                  offset below, what it actually inserted is the reference number
5160                  of the group. */
5161    
5162                called = cd->start_code + recno;                called = cd->start_code + recno;
5163                PUTINC(cd->hwm, 0, code + 2 + LINK_SIZE - cd->start_code);                PUTINC(cd->hwm, 0, code + 2 + LINK_SIZE - cd->start_code);
5164                }                }
# Line 5590  we set the flag only if there is a liter Line 5600  we set the flag only if there is a liter
5600    
5601        if (-c >= ESC_REF)        if (-c >= ESC_REF)
5602          {          {
5603            open_capitem *oc;
5604          recno = -c - ESC_REF;          recno = -c - ESC_REF;
5605    
5606          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 5610  we set the flag only if there is a liter
5610          PUT2INC(code, 0, recno);          PUT2INC(code, 0, recno);
5611          cd->backref_map |= (recno < 32)? (1 << recno) : 1;          cd->backref_map |= (recno < 32)? (1 << recno) : 1;
5612          if (recno > cd->top_backref) cd->top_backref = recno;          if (recno > cd->top_backref) cd->top_backref = recno;
5613    
5614            /* Check to see if this back reference is recursive, that it, it
5615            is inside the group that it references. A flag is set so that the
5616            group can be made atomic. */
5617    
5618            for (oc = cd->open_caps; oc != NULL; oc = oc->next)
5619              {
5620              if (oc->number == recno)
5621                {
5622                oc->flag = TRUE;
5623                break;
5624                }
5625              }
5626          }          }
5627    
5628        /* 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 5835  them global. It tests the value of lengt
5835  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. */
5836    
5837  /* 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
5838  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
5839    detect groups that contain recursive back references to themselves. */
5840    
5841  if (*code == OP_CBRA)  if (*code == OP_CBRA)
5842    {    {
5843    capnumber = GET2(code, 1 + LINK_SIZE);    capnumber = GET2(code, 1 + LINK_SIZE);
5844    capitem.number = capnumber;    capitem.number = capnumber;
5845    capitem.next = cd->open_caps;    capitem.next = cd->open_caps;
5846      capitem.flag = FALSE;
5847    cd->open_caps = &capitem;    cd->open_caps = &capitem;
5848    }    }
5849    
# Line 5974  for (;;) Line 6000  for (;;)
6000        while (branch_length > 0);        while (branch_length > 0);
6001        }        }
6002    
     /* If it was a capturing subpattern, remove it from the chain. */  
   
     if (capnumber > 0) cd->open_caps = cd->open_caps->next;  
   
6003      /* Fill in the ket */      /* Fill in the ket */
6004    
6005      *code = OP_KET;      *code = OP_KET;
6006      PUT(code, 1, code - start_bracket);      PUT(code, 1, code - start_bracket);
6007      code += 1 + LINK_SIZE;      code += 1 + LINK_SIZE;
6008    
6009        /* If it was a capturing subpattern, check to see if it contained any
6010        recursive back references. If so, we must wrap it in atomic brackets.
6011        In any event, remove the block from the chain. */
6012    
6013        if (capnumber > 0)
6014          {
6015          if (cd->open_caps->flag)
6016            {
6017            memmove(start_bracket + 1 + LINK_SIZE, start_bracket,
6018              code - start_bracket);
6019            *start_bracket = OP_ONCE;
6020            code += 1 + LINK_SIZE;
6021            PUT(start_bracket, 1, code - start_bracket);
6022            *code = OP_KET;
6023            PUT(code, 1, code - start_bracket);
6024            code += 1 + LINK_SIZE;
6025            length += 2 + 2*LINK_SIZE;
6026            }
6027          cd->open_caps = cd->open_caps->next;
6028          }
6029    
6030      /* Reset options if needed. */      /* Reset options if needed. */
6031    
6032      if ((options & PCRE_IMS) != oldims && *ptr == CHAR_RIGHT_PARENTHESIS)      if ((options & PCRE_IMS) != oldims && *ptr == CHAR_RIGHT_PARENTHESIS)
# Line 6771  if (reqbyte >= 0 && Line 6814  if (reqbyte >= 0 &&
6814  case when building a production library. */  case when building a production library. */
6815    
6816  #ifdef PCRE_DEBUG  #ifdef PCRE_DEBUG
   
6817  printf("Length = %d top_bracket = %d top_backref = %d\n",  printf("Length = %d top_bracket = %d top_backref = %d\n",
6818    length, re->top_bracket, re->top_backref);    length, re->top_bracket, re->top_backref);
6819    

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

  ViewVC Help
Powered by ViewVC 1.1.5