/[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

code/trunk/pcre_compile.c revision 749 by ph10, Fri Nov 18 10:36:45 2011 UTC code/branches/pcre16/pcre_compile.c revision 755 by ph10, Mon Nov 21 10:41:54 2011 UTC
# Line 1528  Arguments: Line 1528  Arguments:
1528    
1529  Returns:   the fixed length,  Returns:   the fixed length,
1530               or -1 if there is no fixed length,               or -1 if there is no fixed length,
1531               or -2 if \C was encountered               or -2 if \C was encountered (in UTF-8 mode only)
1532               or -3 if an OP_RECURSE item was encountered and atend is FALSE               or -3 if an OP_RECURSE item was encountered and atend is FALSE
1533               or -4 if an unknown opcode was encountered (internal error)               or -4 if an unknown opcode was encountered (internal error)
1534  */  */
# Line 1702  for (;;) Line 1702  for (;;)
1702      cc++;      cc++;
1703      break;      break;
1704    
1705      /* The single-byte matcher isn't allowed */      /* The single-byte matcher isn't allowed. This only happens in UTF-8 mode;
1706        otherwise \C is coded as OP_ALLANY. */
1707    
1708      case OP_ANYBYTE:      case OP_ANYBYTE:
1709      return -2;      return -2;
# Line 3352  for (;; ptr++) Line 3353  for (;; ptr++)
3353        }        }
3354    
3355      *lengthptr += (int)(code - last_code);      *lengthptr += (int)(code - last_code);
3356      DPRINTF(("length=%d added %d c=%c\n", *lengthptr, code - last_code, c));      DPRINTF(("length=%d added %d c=%c\n", *lengthptr, (int)(code - last_code),
3357          c));
3358    
3359      /* If "previous" is set and it is not at the start of the work space, move      /* If "previous" is set and it is not at the start of the work space, move
3360      it back to there, in order to avoid filling up the work space. Otherwise,      it back to there, in order to avoid filling up the work space. Otherwise,
# Line 4994  for (;; ptr++) Line 4996  for (;; ptr++)
4996        KETRPOS. (It turns out to be convenient at runtime to detect this kind of        KETRPOS. (It turns out to be convenient at runtime to detect this kind of
4997        subpattern at both the start and at the end.) The use of special opcodes        subpattern at both the start and at the end.) The use of special opcodes
4998        makes it possible to reduce greatly the stack usage in pcre_exec(). If        makes it possible to reduce greatly the stack usage in pcre_exec(). If
4999        the group is preceded by OP_BRAZERO, convert this to OP_BRAPOSZERO. Then        the group is preceded by OP_BRAZERO, convert this to OP_BRAPOSZERO.
5000        cancel the possessive flag so that the default action below, of wrapping  
5001        everything inside atomic brackets, does not happen. */        Then, if the minimum number of matches is 1 or 0, cancel the possessive
5002          flag so that the default action below, of wrapping everything inside
5003          atomic brackets, does not happen. When the minimum is greater than 1,
5004          there will be earlier copies of the group, and so we still have to wrap
5005          the whole thing. */
5006    
5007        else        else
5008          {          {
# Line 5068  for (;; ptr++) Line 5074  for (;; ptr++)
5074                }                }
5075    
5076              /* If the minimum is zero, mark it as possessive, then unset the              /* If the minimum is zero, mark it as possessive, then unset the
5077              possessive flag. */              possessive flag when the minimum is 0 or 1. */
5078    
5079              if (brazeroptr != NULL) *brazeroptr = OP_BRAPOSZERO;              if (brazeroptr != NULL) *brazeroptr = OP_BRAPOSZERO;
5080              possessive_quantifier = FALSE;              if (repeat_min < 2) possessive_quantifier = FALSE;
5081              }              }
5082    
5083            /* Non-possessive quantifier */            /* Non-possessive quantifier */
# Line 5103  for (;; ptr++) Line 5109  for (;; ptr++)
5109      notation is just syntactic sugar, taken from Sun's Java package, but the      notation is just syntactic sugar, taken from Sun's Java package, but the
5110      special opcodes can optimize it.      special opcodes can optimize it.
5111    
5112      Possessively repeated subpatterns have already been handled in the code      Some (but not all) possessively repeated subpatterns have already been
5113      just above, so possessive_quantifier is always FALSE for them at this      completely handled in the code just above. For them, possessive_quantifier
5114      stage.      is always FALSE at this stage.
5115    
5116      Note that the repeated item starts at tempcode, not at previous, which      Note that the repeated item starts at tempcode, not at previous, which
5117      might be the first part of a string whose (former) last char we repeated.      might be the first part of a string whose (former) last char we repeated.
# Line 5595  for (;; ptr++) Line 5601  for (;; ptr++)
5601    
5602          /* ------------------------------------------------------------ */          /* ------------------------------------------------------------ */
5603          case CHAR_C:                 /* Callout - may be followed by digits; */          case CHAR_C:                 /* Callout - may be followed by digits; */
5604          previous_callout = code;  /* Save for later completion */          previous_callout = code;     /* Save for later completion */
5605          after_manual_callout = 1; /* Skip one item before completing */          after_manual_callout = 1;    /* Skip one item before completing */
5606          *code++ = OP_CALLOUT;          *code++ = OP_CALLOUT;
5607            {            {
5608            int n = 0;            int n = 0;
# Line 6473  for (;; ptr++) Line 6479  for (;; ptr++)
6479            }            }
6480          else          else
6481  #endif  #endif
6482            {          /* In non-UTF-8 mode, we turn \C into OP_ALLANY instead of OP_ANYBYTE
6483            so that it works in DFA mode and in lookbehinds. */
6484    
6485              {
6486            previous = (-c > ESC_b && -c < ESC_Z)? code : NULL;            previous = (-c > ESC_b && -c < ESC_Z)? code : NULL;
6487            *code++ = -c;            *code++ = (!utf8 && c == -ESC_C)? OP_ALLANY : -c;
6488            }            }
6489          }          }
6490        continue;        continue;

Legend:
Removed from v.749  
changed lines
  Added in v.755

  ViewVC Help
Powered by ViewVC 1.1.5