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

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

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

revision 755 by ph10, Mon Nov 21 10:41:54 2011 UTC revision 756 by ph10, Mon Nov 21 10:48:42 2011 UTC
# Line 78  Returns: the minimum length Line 78  Returns: the minimum length
78  */  */
79    
80  static int  static int
81  find_minlength(const uschar *code, const uschar *startcode, int options,  find_minlength(const pcre_uchar *code, const pcre_uchar *startcode, int options,
82    int recurse_depth)    int recurse_depth)
83  {  {
84  int length = -1;  int length = -1;
85  BOOL utf8 = (options & PCRE_UTF8) != 0;  BOOL utf8 = (options & PCRE_UTF8) != 0;
86  BOOL had_recurse = FALSE;  BOOL had_recurse = FALSE;
87  register int branchlength = 0;  register int branchlength = 0;
88  register uschar *cc = (uschar *)code + 1 + LINK_SIZE;  register pcre_uchar *cc = (pcre_uchar *)code + 1 + LINK_SIZE;
89    
90  if (*code == OP_CBRA || *code == OP_SCBRA ||  if (*code == OP_CBRA || *code == OP_SCBRA ||
91      *code == OP_CBRAPOS || *code == OP_SCBRAPOS) cc += 2;      *code == OP_CBRAPOS || *code == OP_SCBRAPOS) cc += 2;
# Line 96  branch, check the length against that of Line 96  branch, check the length against that of
96  for (;;)  for (;;)
97    {    {
98    int d, min;    int d, min;
99    uschar *cs, *ce;    pcre_uchar *cs, *ce;
100    register int op = *cc;    register int op = *cc;
101    
102    switch (op)    switch (op)
# Line 372  for (;;) Line 372  for (;;)
372      case OP_REFI:      case OP_REFI:
373      if ((options & PCRE_JAVASCRIPT_COMPAT) == 0)      if ((options & PCRE_JAVASCRIPT_COMPAT) == 0)
374        {        {
375        ce = cs = (uschar *)_pcre_find_bracket(startcode, utf8, GET2(cc, 1));        ce = cs = (pcre_uchar *)_pcre_find_bracket(startcode, utf8, GET2(cc, 1));
376        if (cs == NULL) return -2;        if (cs == NULL) return -2;
377        do ce += GET(ce, 1); while (*ce == OP_ALT);        do ce += GET(ce, 1); while (*ce == OP_ALT);
378        if (cc > cs && cc < ce)        if (cc > cs && cc < ce)
# Line 424  for (;;) Line 424  for (;;)
424      caught by a recursion depth count. */      caught by a recursion depth count. */
425    
426      case OP_RECURSE:      case OP_RECURSE:
427      cs = ce = (uschar *)startcode + GET(cc, 1);      cs = ce = (pcre_uchar *)startcode + GET(cc, 1);
428      do ce += GET(ce, 1); while (*ce == OP_ALT);      do ce += GET(ce, 1); while (*ce == OP_ALT);
429      if ((cc > cs && cc < ce) || recurse_depth > 10)      if ((cc > cs && cc < ce) || recurse_depth > 10)
430        had_recurse = TRUE;        had_recurse = TRUE;
# Line 540  Arguments: Line 540  Arguments:
540  Returns:        pointer after the character  Returns:        pointer after the character
541  */  */
542    
543  static const uschar *  static const pcre_uchar *
544  set_table_bit(uschar *start_bits, const uschar *p, BOOL caseless,  set_table_bit(pcre_uint8 *start_bits, const pcre_uchar *p, BOOL caseless,
545    compile_data *cd, BOOL utf8)    compile_data *cd, BOOL utf8)
546  {  {
547  unsigned int c = *p;  unsigned int c = *p;
# Line 555  if (utf8 && c > 127) Line 555  if (utf8 && c > 127)
555  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
556    if (caseless)    if (caseless)
557      {      {
558      uschar buff[8];      pcre_uint8 buff[8];
559      c = UCD_OTHERCASE(c);      c = UCD_OTHERCASE(c);
560      (void)_pcre_ord2utf8(c, buff);      (void)_pcre_ord2utf8(c, buff);
561      SET_BIT(buff[0]);      SET_BIT(buff[0]);
# Line 594  Returns: nothing Line 594  Returns: nothing
594  */  */
595    
596  static void  static void
597  set_type_bits(uschar *start_bits, int cbit_type, int table_limit,  set_type_bits(pcre_uint8 *start_bits, int cbit_type, int table_limit,
598    compile_data *cd)    compile_data *cd)
599  {  {
600  register int c;  register int c;
# Line 604  for (c = 128; c < 256; c++) Line 604  for (c = 128; c < 256; c++)
604    {    {
605    if ((cd->cbits[c/8] & (1 << (c&7))) != 0)    if ((cd->cbits[c/8] & (1 << (c&7))) != 0)
606      {      {
607      uschar buff[8];      pcre_uint8 buff[8];
608      (void)_pcre_ord2utf8(c, buff);      (void)_pcre_ord2utf8(c, buff);
609      SET_BIT(buff[0]);      SET_BIT(buff[0]);
610      }      }
# Line 634  Returns: nothing Line 634  Returns: nothing
634  */  */
635    
636  static void  static void
637  set_nottype_bits(uschar *start_bits, int cbit_type, int table_limit,  set_nottype_bits(pcre_uint8 *start_bits, int cbit_type, int table_limit,
638    compile_data *cd)    compile_data *cd)
639  {  {
640  register int c;  register int c;
# Line 669  Returns: SSB_FAIL => Failed to Line 669  Returns: SSB_FAIL => Failed to
669  */  */
670    
671  static int  static int
672  set_start_bits(const uschar *code, uschar *start_bits, BOOL utf8,  set_start_bits(const pcre_uchar *code, pcre_uint8 *start_bits, BOOL utf8,
673    compile_data *cd)    compile_data *cd)
674  {  {
675  register int c;  register int c;
# Line 696  volatile int dummy; Line 696  volatile int dummy;
696  do  do
697    {    {
698    BOOL try_next = TRUE;    BOOL try_next = TRUE;
699    const uschar *tcode = code + 1 + LINK_SIZE;    const pcre_uchar *tcode = code + 1 + LINK_SIZE;
700    
701    if (*code == OP_CBRA || *code == OP_SCBRA ||    if (*code == OP_CBRA || *code == OP_SCBRA ||
702        *code == OP_CBRAPOS || *code == OP_SCBRAPOS) tcode += 2;        *code == OP_CBRAPOS || *code == OP_SCBRAPOS) tcode += 2;
# Line 1224  pcre_study(const pcre *external_re, int Line 1224  pcre_study(const pcre *external_re, int
1224  {  {
1225  int min;  int min;
1226  BOOL bits_set = FALSE;  BOOL bits_set = FALSE;
1227  uschar start_bits[32];  pcre_uint8 start_bits[32];
1228  pcre_extra *extra = NULL;  pcre_extra *extra = NULL;
1229  pcre_study_data *study;  pcre_study_data *study;
1230  const uschar *tables;  const pcre_uint8 *tables;
1231  uschar *code;  pcre_uchar *code;
1232  compile_data compile_block;  compile_data compile_block;
1233  const real_pcre *re = (const real_pcre *)external_re;  const real_pcre *re = (const real_pcre *)external_re;
1234    
# Line 1246  if ((options & ~PUBLIC_STUDY_OPTIONS) != Line 1246  if ((options & ~PUBLIC_STUDY_OPTIONS) !=
1246    return NULL;    return NULL;
1247    }    }
1248    
1249  code = (uschar *)re + re->name_table_offset +  code = (pcre_uchar *)re + re->name_table_offset +
1250    (re->name_count * re->name_entry_size);    (re->name_count * re->name_entry_size);
1251    
1252  /* For an anchored pattern, or an unanchored pattern that has a first char, or  /* For an anchored pattern, or an unanchored pattern that has a first char, or
# Line 1272  if ((re->options & PCRE_ANCHORED) == 0 & Line 1272  if ((re->options & PCRE_ANCHORED) == 0 &
1272    
1273    /* See if we can find a fixed set of initial characters for the pattern. */    /* See if we can find a fixed set of initial characters for the pattern. */
1274    
1275    memset(start_bits, 0, 32 * sizeof(uschar));    memset(start_bits, 0, 32 * sizeof(pcre_uint8));
1276    rc = set_start_bits(code, start_bits, (re->options & PCRE_UTF8) != 0,    rc = set_start_bits(code, start_bits, (re->options & PCRE_UTF8) != 0,
1277      &compile_block);      &compile_block);
1278    bits_set = rc == SSB_DONE;    bits_set = rc == SSB_DONE;

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

webmaster@exim.org
ViewVC Help
Powered by ViewVC 1.1.12