/[pcre]/code/branches/pcre16/pcre_compile.c
ViewVC logotype

Diff of /code/branches/pcre16/pcre_compile.c

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

revision 604 by ph10, Thu Jun 2 19:04:54 2011 UTC revision 605 by ph10, Fri Jun 3 18:18:30 2011 UTC
# Line 4510  for (;; ptr++) Line 4510  for (;; ptr++)
4510        int len = (int)(code - previous);        int len = (int)(code - previous);
4511        uschar *bralink = NULL;        uschar *bralink = NULL;
4512        uschar *brazeroptr = NULL;        uschar *brazeroptr = NULL;
4513    
4514        /* Repeating a DEFINE group is pointless */        /* Repeating a DEFINE group is pointless */
4515    
4516        if (*previous == OP_COND && previous[LINK_SIZE+1] == OP_DEF)        if (*previous == OP_COND && previous[LINK_SIZE+1] == OP_DEF)
# Line 4731  for (;; ptr++) Line 4731  for (;; ptr++)
4731        Otherwise, if the quantifier was possessive, we convert the BRA code to        Otherwise, if the quantifier was possessive, we convert the BRA code to
4732        the POS form, and the KET code to KETRPOS. (It turns out to be convenient        the POS form, and the KET code to KETRPOS. (It turns out to be convenient
4733        at runtime to detect this kind of subpattern at both the start and at the        at runtime to detect this kind of subpattern at both the start and at the
4734        end.) If the group is preceded by OP_BRAZERO, convert this to        end.) The use of special opcodes makes it possible to reduce greatly the
4735        OP_BRAPOSZERO. Then cancel the possessive flag so that the default action        stack usage in pcre_exec(). If the group is preceded by OP_BRAZERO,
4736        below, of wrapping everything inside atomic brackets, does not happen.        convert this to OP_BRAPOSZERO. Then cancel the possessive flag so that
4737          the default action below, of wrapping everything inside atomic brackets,
4738          does not happen.
4739    
4740        Then, when we are doing the actual compile phase, check to see whether        Then, when we are doing the actual compile phase, check to see whether
4741        this group is one that could match an empty string. If so, convert the        this group is one that could match an empty string. If so, convert the
# Line 4793  for (;; ptr++) Line 4795  for (;; ptr++)
4795        }        }
4796    
4797      /* If the character following a repeat is '+', or if certain optimization      /* If the character following a repeat is '+', or if certain optimization
4798      tests above succeeded, possessive_quantifier is TRUE. For some of the      tests above succeeded, possessive_quantifier is TRUE. For some opcodes,
4799      simpler opcodes, there is an special alternative opcode for this. For      there are special alternative opcodes for this case. For anything else, we
4800      anything else, we wrap the entire repeated item inside OP_ONCE brackets.      wrap the entire repeated item inside OP_ONCE brackets. Logically, the '+'
4801      The '+' notation is just syntactic sugar, taken from Sun's Java package,      notation is just syntactic sugar, taken from Sun's Java package, but the
4802      but the special opcodes can optimize it a bit. The repeated item starts at      special opcodes can optimize it.
4803      tempcode, not at previous, which might be the first part of a string whose  
4804      (former) last char we repeated.      Possessively repeated subpatterns have already been handled in the code
4805        just above, so possessive_quantifier is always FALSE for them at this
4806        stage.
4807    
4808        Note that the repeated item starts at tempcode, not at previous, which
4809        might be the first part of a string whose (former) last char we repeated.
4810    
4811      Possessifying an 'exact' quantifier has no effect, so we can ignore it. But      Possessifying an 'exact' quantifier has no effect, so we can ignore it. But
4812      an 'upto' may follow. We skip over an 'exact' item, and then test the      an 'upto' may follow. We skip over an 'exact' item, and then test the
# Line 5894  for (;; ptr++) Line 5901  for (;; ptr++)
5901          goto FAILED;          goto FAILED;
5902          }          }
5903        *lengthptr += length_prevgroup - 2 - 2*LINK_SIZE;        *lengthptr += length_prevgroup - 2 - 2*LINK_SIZE;
5904        *code++ = OP_BRA;        code++;   /* This already contains bravalue */
5905        PUTINC(code, 0, 1 + LINK_SIZE);        PUTINC(code, 0, 1 + LINK_SIZE);
5906        *code++ = OP_KET;        *code++ = OP_KET;
5907        PUTINC(code, 0, 1 + LINK_SIZE);        PUTINC(code, 0, 1 + LINK_SIZE);

Legend:
Removed from v.604  
changed lines
  Added in v.605

  ViewVC Help
Powered by ViewVC 1.1.5