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

Diff of /code/trunk/pcre_study.c

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

revision 1032 by ph10, Sat Sep 8 16:05:38 2012 UTC revision 1364 by ph10, Sat Oct 5 15:45:11 2013 UTC
# Line 66  string of that length that matches. In U Line 66  string of that length that matches. In U
66  rather than bytes.  rather than bytes.
67    
68  Arguments:  Arguments:
69      re              compiled pattern block
70    code            pointer to start of group (the bracket)    code            pointer to start of group (the bracket)
71    startcode       pointer to start of the whole pattern    startcode       pointer to start of the whole pattern's code
72    options         the compiling options    options         the compiling options
73    int             RECURSE depth    int             RECURSE depth
74    
# Line 78  Returns:   the minimum length Line 79  Returns:   the minimum length
79  */  */
80    
81  static int  static int
82  find_minlength(const pcre_uchar *code, const pcre_uchar *startcode, int options,  find_minlength(const REAL_PCRE *re, const pcre_uchar *code,
83    int recurse_depth)    const pcre_uchar *startcode, int options, int recurse_depth)
84  {  {
85  int length = -1;  int length = -1;
86  /* PCRE_UTF16 has the same value as PCRE_UTF8. */  /* PCRE_UTF16 has the same value as PCRE_UTF8. */
# Line 98  for (;;) Line 99  for (;;)
99    {    {
100    int d, min;    int d, min;
101    pcre_uchar *cs, *ce;    pcre_uchar *cs, *ce;
102    register int op = *cc;    register pcre_uchar op = *cc;
103    
104    switch (op)    switch (op)
105      {      {
# Line 129  for (;;) Line 130  for (;;)
130      case OP_SBRAPOS:      case OP_SBRAPOS:
131      case OP_ONCE:      case OP_ONCE:
132      case OP_ONCE_NC:      case OP_ONCE_NC:
133      d = find_minlength(cc, startcode, options, recurse_depth);      d = find_minlength(re, cc, startcode, options, recurse_depth);
134      if (d < 0) return d;      if (d < 0) return d;
135      branchlength += d;      branchlength += d;
136      do cc += GET(cc, 1); while (*cc == OP_ALT);      do cc += GET(cc, 1); while (*cc == OP_ALT);
# Line 323  for (;;) Line 324  for (;;)
324    
325      /* Check a class for variable quantification */      /* Check a class for variable quantification */
326    
 #if defined SUPPORT_UTF || !defined COMPILE_PCRE8  
     case OP_XCLASS:  
     cc += GET(cc, 1) - PRIV(OP_lengths)[OP_CLASS];  
     /* Fall through */  
 #endif  
   
327      case OP_CLASS:      case OP_CLASS:
328      case OP_NCLASS:      case OP_NCLASS:
329    #if defined SUPPORT_UTF || defined COMPILE_PCRE16 || defined COMPILE_PCRE32
330        case OP_XCLASS:
331        /* The original code caused an unsigned overflow in 64 bit systems,
332        so now we use a conditional statement. */
333        if (op == OP_XCLASS)
334          cc += GET(cc, 1);
335        else
336          cc += PRIV(OP_lengths)[OP_CLASS];
337    #else
338      cc += PRIV(OP_lengths)[OP_CLASS];      cc += PRIV(OP_lengths)[OP_CLASS];
339    #endif
340    
341      switch (*cc)      switch (*cc)
342        {        {
# Line 370  for (;;) Line 375  for (;;)
375      If PCRE_JAVASCRIPT_COMPAT is set, a backreference to an unset bracket      If PCRE_JAVASCRIPT_COMPAT is set, a backreference to an unset bracket
376      matches an empty string (by default it causes a matching failure), so in      matches an empty string (by default it causes a matching failure), so in
377      that case we must set the minimum length to zero. */      that case we must set the minimum length to zero. */
378    
379        case OP_DNREF:     /* Duplicate named pattern back reference */
380        case OP_DNREFI:
381        if ((options & PCRE_JAVASCRIPT_COMPAT) == 0)
382          {
383          int count = GET2(cc, 1+IMM2_SIZE);
384          pcre_uchar *slot = (pcre_uchar *)re +
385            re->name_table_offset + GET2(cc, 1) * re->name_entry_size;
386          d = INT_MAX;
387          while (count-- > 0)
388            {
389            ce = cs = (pcre_uchar *)PRIV(find_bracket)(startcode, utf, GET2(slot, 0));
390            if (cs == NULL) return -2;
391            do ce += GET(ce, 1); while (*ce == OP_ALT);
392            if (cc > cs && cc < ce)
393              {
394              d = 0;
395              had_recurse = TRUE;
396              break;
397              }
398            else
399              {
400              int dd = find_minlength(re, cs, startcode, options, recurse_depth);
401              if (dd < d) d = dd;
402              }
403            slot += re->name_entry_size;
404            }
405          }
406        else d = 0;
407        cc += 1 + 2*IMM2_SIZE;
408        goto REPEAT_BACK_REFERENCE;
409    
410      case OP_REF:      case OP_REF:      /* Single back reference */
411      case OP_REFI:      case OP_REFI:
412      if ((options & PCRE_JAVASCRIPT_COMPAT) == 0)      if ((options & PCRE_JAVASCRIPT_COMPAT) == 0)
413        {        {
# Line 385  for (;;) Line 421  for (;;)
421          }          }
422        else        else
423          {          {
424          d = find_minlength(cs, startcode, options, recurse_depth);          d = find_minlength(re, cs, startcode, options, recurse_depth);
425          }          }
426        }        }
427      else d = 0;      else d = 0;
# Line 393  for (;;) Line 429  for (;;)
429    
430      /* Handle repeated back references */      /* Handle repeated back references */
431    
432        REPEAT_BACK_REFERENCE:
433      switch (*cc)      switch (*cc)
434        {        {
435        case OP_CRSTAR:        case OP_CRSTAR:
# Line 433  for (;;) Line 470  for (;;)
470        had_recurse = TRUE;        had_recurse = TRUE;
471      else      else
472        {        {
473        branchlength += find_minlength(cs, startcode, options, recurse_depth + 1);        branchlength += find_minlength(re, cs, startcode, options,
474            recurse_depth + 1);
475        }        }
476      cc += 1 + LINK_SIZE;      cc += 1 + LINK_SIZE;
477      break;      break;
# Line 538  Arguments: Line 576  Arguments:
576    p             points to the character    p             points to the character
577    caseless      the caseless flag    caseless      the caseless flag
578    cd            the block with char table pointers    cd            the block with char table pointers
579    utf           TRUE for UTF-8 / UTF-16 mode    utf           TRUE for UTF-8 / UTF-16 / UTF-32 mode
580    
581  Returns:        pointer after the character  Returns:        pointer after the character
582  */  */
# Line 547  static const pcre_uchar * Line 585  static const pcre_uchar *
585  set_table_bit(pcre_uint8 *start_bits, const pcre_uchar *p, BOOL caseless,  set_table_bit(pcre_uint8 *start_bits, const pcre_uchar *p, BOOL caseless,
586    compile_data *cd, BOOL utf)    compile_data *cd, BOOL utf)
587  {  {
588  unsigned int c = *p;  pcre_uint32 c = *p;
589    
590  #ifdef COMPILE_PCRE8  #ifdef COMPILE_PCRE8
591  SET_BIT(c);  SET_BIT(c);
# Line 567  if (utf && c > 127) Line 605  if (utf && c > 127)
605  #endif  /* Not SUPPORT_UCP */  #endif  /* Not SUPPORT_UCP */
606    return p;    return p;
607    }    }
608  #else  /* Not SUPPORT_UTF */  #else   /* Not SUPPORT_UTF */
609  (void)(utf);   /* Stops warning for unused parameter */  (void)(utf);   /* Stops warning for unused parameter */
610  #endif  #endif  /* SUPPORT_UTF */
611    
612  /* Not UTF-8 mode, or character is less than 127. */  /* Not UTF-8 mode, or character is less than 127. */
613    
614  if (caseless && (cd->ctypes[c] & ctype_letter) != 0) SET_BIT(cd->fcc[c]);  if (caseless && (cd->ctypes[c] & ctype_letter) != 0) SET_BIT(cd->fcc[c]);
615  return p + 1;  return p + 1;
616  #endif  #endif  /* COMPILE_PCRE8 */
617    
618  #ifdef COMPILE_PCRE16  #if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
619  if (c > 0xff)  if (c > 0xff)
620    {    {
621    c = 0xff;    c = 0xff;
# Line 597  if (utf && c > 127) Line 635  if (utf && c > 127)
635        c = 0xff;        c = 0xff;
636      SET_BIT(c);      SET_BIT(c);
637      }      }
638  #endif  #endif  /* SUPPORT_UCP */
639    return p;    return p;
640    }    }
641  #endif  #else   /* Not SUPPORT_UTF */
642    (void)(utf);   /* Stops warning for unused parameter */
643    #endif  /* SUPPORT_UTF */
644    
645  if (caseless && (cd->ctypes[c] & ctype_letter) != 0) SET_BIT(cd->fcc[c]);  if (caseless && (cd->ctypes[c] & ctype_letter) != 0) SET_BIT(cd->fcc[c]);
646  return p + 1;  return p + 1;
# Line 630  Returns:         nothing Line 670  Returns:         nothing
670  */  */
671    
672  static void  static void
673  set_type_bits(pcre_uint8 *start_bits, int cbit_type, int table_limit,  set_type_bits(pcre_uint8 *start_bits, int cbit_type, unsigned int table_limit,
674    compile_data *cd)    compile_data *cd)
675  {  {
676  register int c;  register pcre_uint32 c;
677  for (c = 0; c < table_limit; c++) start_bits[c] |= cd->cbits[c+cbit_type];  for (c = 0; c < table_limit; c++) start_bits[c] |= cd->cbits[c+cbit_type];
678  #if defined SUPPORT_UTF && defined COMPILE_PCRE8  #if defined SUPPORT_UTF && defined COMPILE_PCRE8
679  if (table_limit == 32) return;  if (table_limit == 32) return;
# Line 672  Returns:         nothing Line 712  Returns:         nothing
712  */  */
713    
714  static void  static void
715  set_nottype_bits(pcre_uint8 *start_bits, int cbit_type, int table_limit,  set_nottype_bits(pcre_uint8 *start_bits, int cbit_type, unsigned int table_limit,
716    compile_data *cd)    compile_data *cd)
717  {  {
718  register int c;  register pcre_uint32 c;
719  for (c = 0; c < table_limit; c++) start_bits[c] |= ~cd->cbits[c+cbit_type];  for (c = 0; c < table_limit; c++) start_bits[c] |= ~cd->cbits[c+cbit_type];
720  #if defined SUPPORT_UTF && defined COMPILE_PCRE8  #if defined SUPPORT_UTF && defined COMPILE_PCRE8
721  if (table_limit != 32) for (c = 24; c < 32; c++) start_bits[c] = 0xff;  if (table_limit != 32) for (c = 24; c < 32; c++) start_bits[c] = 0xff;
# Line 699  function fails unless the result is SSB_ Line 739  function fails unless the result is SSB_
739  Arguments:  Arguments:
740    code         points to an expression    code         points to an expression
741    start_bits   points to a 32-byte table, initialized to 0    start_bits   points to a 32-byte table, initialized to 0
742    utf          TRUE if in UTF-8 / UTF-16 mode    utf          TRUE if in UTF-8 / UTF-16 / UTF-32 mode
743    cd           the block with char table pointers    cd           the block with char table pointers
744    
745  Returns:       SSB_FAIL     => Failed to find any starting bytes  Returns:       SSB_FAIL     => Failed to find any starting bytes
# Line 712  static int Line 752  static int
752  set_start_bits(const pcre_uchar *code, pcre_uint8 *start_bits, BOOL utf,  set_start_bits(const pcre_uchar *code, pcre_uint8 *start_bits, BOOL utf,
753    compile_data *cd)    compile_data *cd)
754  {  {
755  register int c;  register pcre_uint32 c;
756  int yield = SSB_DONE;  int yield = SSB_DONE;
757  #if defined SUPPORT_UTF && defined COMPILE_PCRE8  #if defined SUPPORT_UTF && defined COMPILE_PCRE8
758  int table_limit = utf? 16:32;  int table_limit = utf? 16:32;
# Line 819  do Line 859  do
859        case OP_RECURSE:        case OP_RECURSE:
860        case OP_REF:        case OP_REF:
861        case OP_REFI:        case OP_REFI:
862          case OP_DNREF:
863          case OP_DNREFI:
864        case OP_REVERSE:        case OP_REVERSE:
865        case OP_RREF:        case OP_RREF:
866        case OP_SCOND:        case OP_SCOND:
# Line 988  do Line 1030  do
1030        identical. */        identical. */
1031    
1032        case OP_HSPACE:        case OP_HSPACE:
1033        SET_BIT(0x09);        SET_BIT(CHAR_HT);
1034        SET_BIT(0x20);        SET_BIT(CHAR_SPACE);
1035  #ifdef SUPPORT_UTF  #ifdef SUPPORT_UTF
1036        if (utf)        if (utf)
1037          {          {
# Line 998  do Line 1040  do
1040          SET_BIT(0xE1);  /* For U+1680, U+180E */          SET_BIT(0xE1);  /* For U+1680, U+180E */
1041          SET_BIT(0xE2);  /* For U+2000 - U+200A, U+202F, U+205F */          SET_BIT(0xE2);  /* For U+2000 - U+200A, U+202F, U+205F */
1042          SET_BIT(0xE3);  /* For U+3000 */          SET_BIT(0xE3);  /* For U+3000 */
1043  #endif  #elif defined COMPILE_PCRE16 || defined COMPILE_PCRE32
 #ifdef COMPILE_PCRE16  
1044          SET_BIT(0xA0);          SET_BIT(0xA0);
1045          SET_BIT(0xFF);  /* For characters > 255 */          SET_BIT(0xFF);  /* For characters > 255 */
1046  #endif  #endif  /* COMPILE_PCRE[8|16|32] */
1047          }          }
1048        else        else
1049  #endif /* SUPPORT_UTF */  #endif /* SUPPORT_UTF */
1050          {          {
1051    #ifndef EBCDIC
1052          SET_BIT(0xA0);          SET_BIT(0xA0);
1053  #ifdef COMPILE_PCRE16  #endif  /* Not EBCDIC */
1054    #if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
1055          SET_BIT(0xFF);  /* For characters > 255 */          SET_BIT(0xFF);  /* For characters > 255 */
1056  #endif  #endif  /* COMPILE_PCRE[16|32] */
1057          }          }
1058        try_next = FALSE;        try_next = FALSE;
1059        break;        break;
1060    
1061        case OP_ANYNL:        case OP_ANYNL:
1062        case OP_VSPACE:        case OP_VSPACE:
1063        SET_BIT(0x0A);        SET_BIT(CHAR_LF);
1064        SET_BIT(0x0B);        SET_BIT(CHAR_VT);
1065        SET_BIT(0x0C);        SET_BIT(CHAR_FF);
1066        SET_BIT(0x0D);        SET_BIT(CHAR_CR);
1067  #ifdef SUPPORT_UTF  #ifdef SUPPORT_UTF
1068        if (utf)        if (utf)
1069          {          {
1070  #ifdef COMPILE_PCRE8  #ifdef COMPILE_PCRE8
1071          SET_BIT(0xC2);  /* For U+0085 */          SET_BIT(0xC2);  /* For U+0085 */
1072          SET_BIT(0xE2);  /* For U+2028, U+2029 */          SET_BIT(0xE2);  /* For U+2028, U+2029 */
1073  #endif  #elif defined COMPILE_PCRE16 || defined COMPILE_PCRE32
1074  #ifdef COMPILE_PCRE16          SET_BIT(CHAR_NEL);
         SET_BIT(0x85);  
1075          SET_BIT(0xFF);  /* For characters > 255 */          SET_BIT(0xFF);  /* For characters > 255 */
1076  #endif  #endif  /* COMPILE_PCRE[8|16|32] */
1077          }          }
1078        else        else
1079  #endif /* SUPPORT_UTF */  #endif /* SUPPORT_UTF */
1080          {          {
1081          SET_BIT(0x85);          SET_BIT(CHAR_NEL);
1082  #ifdef COMPILE_PCRE16  #if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
1083          SET_BIT(0xFF);  /* For characters > 255 */          SET_BIT(0xFF);  /* For characters > 255 */
1084  #endif  #endif
1085          }          }
# Line 1060  do Line 1102  do
1102        break;        break;
1103    
1104        /* The cbit_space table has vertical tab as whitespace; we have to        /* The cbit_space table has vertical tab as whitespace; we have to
1105        ensure it is set as not whitespace. */        ensure it is set as not whitespace. Luckily, the code value is the same
1106          (0x0b) in ASCII and EBCDIC, so we can just adjust the appropriate bit. */
1107    
1108        case OP_NOT_WHITESPACE:        case OP_NOT_WHITESPACE:
1109        set_nottype_bits(start_bits, cbit_space, table_limit, cd);        set_nottype_bits(start_bits, cbit_space, table_limit, cd);
# Line 1068  do Line 1111  do
1111        try_next = FALSE;        try_next = FALSE;
1112        break;        break;
1113    
1114        /* The cbit_space table has vertical tab as whitespace; we have to        /* The cbit_space table has vertical tab as whitespace; we have to not
1115        not set it from the table. */        set it from the table. Luckily, the code value is the same (0x0b) in
1116          ASCII and EBCDIC, so we can just adjust the appropriate bit. */
1117    
1118        case OP_WHITESPACE:        case OP_WHITESPACE:
1119        c = start_bits[1];    /* Save in case it was already set */        c = start_bits[1];    /* Save in case it was already set */
# Line 1123  do Line 1167  do
1167          return SSB_FAIL;          return SSB_FAIL;
1168    
1169          case OP_HSPACE:          case OP_HSPACE:
1170          SET_BIT(0x09);          SET_BIT(CHAR_HT);
1171          SET_BIT(0x20);          SET_BIT(CHAR_SPACE);
1172  #ifdef SUPPORT_UTF  #ifdef SUPPORT_UTF
1173          if (utf)          if (utf)
1174            {            {
# Line 1133  do Line 1177  do
1177            SET_BIT(0xE1);  /* For U+1680, U+180E */            SET_BIT(0xE1);  /* For U+1680, U+180E */
1178            SET_BIT(0xE2);  /* For U+2000 - U+200A, U+202F, U+205F */            SET_BIT(0xE2);  /* For U+2000 - U+200A, U+202F, U+205F */
1179            SET_BIT(0xE3);  /* For U+3000 */            SET_BIT(0xE3);  /* For U+3000 */
1180  #endif  #elif defined COMPILE_PCRE16 || defined COMPILE_PCRE32
 #ifdef COMPILE_PCRE16  
1181            SET_BIT(0xA0);            SET_BIT(0xA0);
1182            SET_BIT(0xFF);  /* For characters > 255 */            SET_BIT(0xFF);  /* For characters > 255 */
1183  #endif  #endif  /* COMPILE_PCRE[8|16|32] */
1184            }            }
1185          else          else
1186  #endif /* SUPPORT_UTF */  #endif /* SUPPORT_UTF */
1187    #ifndef EBCDIC
1188            SET_BIT(0xA0);            SET_BIT(0xA0);
1189    #endif  /* Not EBCDIC */
1190          break;          break;
1191    
1192          case OP_ANYNL:          case OP_ANYNL:
1193          case OP_VSPACE:          case OP_VSPACE:
1194          SET_BIT(0x0A);          SET_BIT(CHAR_LF);
1195          SET_BIT(0x0B);          SET_BIT(CHAR_VT);
1196          SET_BIT(0x0C);          SET_BIT(CHAR_FF);
1197          SET_BIT(0x0D);          SET_BIT(CHAR_CR);
1198  #ifdef SUPPORT_UTF  #ifdef SUPPORT_UTF
1199          if (utf)          if (utf)
1200            {            {
1201  #ifdef COMPILE_PCRE8  #ifdef COMPILE_PCRE8
1202            SET_BIT(0xC2);  /* For U+0085 */            SET_BIT(0xC2);  /* For U+0085 */
1203            SET_BIT(0xE2);  /* For U+2028, U+2029 */            SET_BIT(0xE2);  /* For U+2028, U+2029 */
1204  #endif  #elif defined COMPILE_PCRE16 || defined COMPILE_PCRE32
1205  #ifdef COMPILE_PCRE16            SET_BIT(CHAR_NEL);
           SET_BIT(0x85);  
1206            SET_BIT(0xFF);  /* For characters > 255 */            SET_BIT(0xFF);  /* For characters > 255 */
1207  #endif  #endif  /* COMPILE_PCRE16 */
1208            }            }
1209          else          else
1210  #endif /* SUPPORT_UTF */  #endif /* SUPPORT_UTF */
1211            SET_BIT(0x85);            SET_BIT(CHAR_NEL);
1212          break;          break;
1213    
1214          case OP_NOT_DIGIT:          case OP_NOT_DIGIT:
# Line 1175  do Line 1219  do
1219          set_type_bits(start_bits, cbit_digit, table_limit, cd);          set_type_bits(start_bits, cbit_digit, table_limit, cd);
1220          break;          break;
1221    
1222          /* The cbit_space table has vertical tab as whitespace; we have to          /* The cbit_space table has vertical tab as whitespace; we no longer
1223          ensure it gets set as not whitespace. */          have to play fancy tricks because Perl added VT to its whitespace at
1224            release 5.18. PCRE added it at release 8.34. */
1225    
1226          case OP_NOT_WHITESPACE:          case OP_NOT_WHITESPACE:
1227          set_nottype_bits(start_bits, cbit_space, table_limit, cd);          set_nottype_bits(start_bits, cbit_space, table_limit, cd);
         start_bits[1] |= 0x08;  
1228          break;          break;
1229    
         /* The cbit_space table has vertical tab as whitespace; we have to  
         avoid setting it. */  
   
1230          case OP_WHITESPACE:          case OP_WHITESPACE:
         c = start_bits[1];    /* Save in case it was already set */  
1231          set_type_bits(start_bits, cbit_space, table_limit, cd);          set_type_bits(start_bits, cbit_space, table_limit, cd);
         start_bits[1] = (start_bits[1] & ~0x08) | c;  
1232          break;          break;
1233    
1234          case OP_NOT_WORDCHAR:          case OP_NOT_WORDCHAR:
# Line 1218  do Line 1257  do
1257          memset(start_bits+25, 0xff, 7);      /* Bits for 0xc9 - 0xff */          memset(start_bits+25, 0xff, 7);      /* Bits for 0xc9 - 0xff */
1258          }          }
1259  #endif  #endif
1260  #ifdef COMPILE_PCRE16  #if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
1261        SET_BIT(0xFF);                         /* For characters > 255 */        SET_BIT(0xFF);                         /* For characters > 255 */
1262  #endif  #endif
1263        /* Fall through */        /* Fall through */
# Line 1314  Returns:    pointer to a pcre[16]_extra Line 1353  Returns:    pointer to a pcre[16]_extra
1353              NULL on error or if no optimization possible              NULL on error or if no optimization possible
1354  */  */
1355    
1356  #ifdef COMPILE_PCRE8  #if defined COMPILE_PCRE8
1357  PCRE_EXP_DEFN pcre_extra * PCRE_CALL_CONVENTION  PCRE_EXP_DEFN pcre_extra * PCRE_CALL_CONVENTION
1358  pcre_study(const pcre *external_re, int options, const char **errorptr)  pcre_study(const pcre *external_re, int options, const char **errorptr)
1359  #else  #elif defined COMPILE_PCRE16
1360  PCRE_EXP_DEFN pcre16_extra * PCRE_CALL_CONVENTION  PCRE_EXP_DEFN pcre16_extra * PCRE_CALL_CONVENTION
1361  pcre16_study(const pcre16 *external_re, int options, const char **errorptr)  pcre16_study(const pcre16 *external_re, int options, const char **errorptr)
1362    #elif defined COMPILE_PCRE32
1363    PCRE_EXP_DEFN pcre32_extra * PCRE_CALL_CONVENTION
1364    pcre32_study(const pcre32 *external_re, int options, const char **errorptr)
1365  #endif  #endif
1366  {  {
1367  int min;  int min;
# Line 1332  pcre_uchar *code; Line 1374  pcre_uchar *code;
1374  compile_data compile_block;  compile_data compile_block;
1375  const REAL_PCRE *re = (const REAL_PCRE *)external_re;  const REAL_PCRE *re = (const REAL_PCRE *)external_re;
1376    
1377    
1378  *errorptr = NULL;  *errorptr = NULL;
1379    
1380  if (re == NULL || re->magic_number != MAGIC_NUMBER)  if (re == NULL || re->magic_number != MAGIC_NUMBER)
# Line 1342  if (re == NULL || re->magic_number != MA Line 1385  if (re == NULL || re->magic_number != MA
1385    
1386  if ((re->flags & PCRE_MODE) == 0)  if ((re->flags & PCRE_MODE) == 0)
1387    {    {
1388  #ifdef COMPILE_PCRE8  #if defined COMPILE_PCRE8
1389    *errorptr = "argument is compiled in 16 bit mode";    *errorptr = "argument not compiled in 8 bit mode";
1390  #else  #elif defined COMPILE_PCRE16
1391    *errorptr = "argument is compiled in 8 bit mode";    *errorptr = "argument not compiled in 16 bit mode";
1392    #elif defined COMPILE_PCRE32
1393      *errorptr = "argument not compiled in 32 bit mode";
1394  #endif  #endif
1395    return NULL;    return NULL;
1396    }    }
# Line 1372  if ((re->options & PCRE_ANCHORED) == 0 & Line 1417  if ((re->options & PCRE_ANCHORED) == 0 &
1417    
1418    tables = re->tables;    tables = re->tables;
1419    
1420  #ifdef COMPILE_PCRE8  #if defined COMPILE_PCRE8
1421    if (tables == NULL)    if (tables == NULL)
1422      (void)pcre_fullinfo(external_re, NULL, PCRE_INFO_DEFAULT_TABLES,      (void)pcre_fullinfo(external_re, NULL, PCRE_INFO_DEFAULT_TABLES,
1423      (void *)(&tables));      (void *)(&tables));
1424  #else  #elif defined COMPILE_PCRE16
1425    if (tables == NULL)    if (tables == NULL)
1426      (void)pcre16_fullinfo(external_re, NULL, PCRE_INFO_DEFAULT_TABLES,      (void)pcre16_fullinfo(external_re, NULL, PCRE_INFO_DEFAULT_TABLES,
1427      (void *)(&tables));      (void *)(&tables));
1428    #elif defined COMPILE_PCRE32
1429      if (tables == NULL)
1430        (void)pcre32_fullinfo(external_re, NULL, PCRE_INFO_DEFAULT_TABLES,
1431        (void *)(&tables));
1432  #endif  #endif
1433    
1434    compile_block.lcc = tables + lcc_offset;    compile_block.lcc = tables + lcc_offset;
# Line 1402  if ((re->options & PCRE_ANCHORED) == 0 & Line 1451  if ((re->options & PCRE_ANCHORED) == 0 &
1451    
1452  /* Find the minimum length of subject string. */  /* Find the minimum length of subject string. */
1453    
1454  switch(min = find_minlength(code, code, re->options, 0))  switch(min = find_minlength(re, code, code, re->options, 0))
1455    {    {
1456    case -2: *errorptr = "internal error: missing capturing bracket"; return NULL;    case -2: *errorptr = "internal error: missing capturing bracket"; return NULL;
1457    case -3: *errorptr = "internal error: opcode not recognized"; return NULL;    case -3: *errorptr = "internal error: opcode not recognized"; return NULL;
# Line 1410  switch(min = find_minlength(code, code, Line 1459  switch(min = find_minlength(code, code,
1459    }    }
1460    
1461  /* If a set of starting bytes has been identified, or if the minimum length is  /* If a set of starting bytes has been identified, or if the minimum length is
1462  greater than zero, or if JIT optimization has been requested, or if  greater than zero, or if JIT optimization has been requested, or if
1463  PCRE_STUDY_EXTRA_NEEDED is set, get a pcre[16]_extra block and a  PCRE_STUDY_EXTRA_NEEDED is set, get a pcre[16]_extra block and a
1464  pcre_study_data block. The study data is put in the latter, which is pointed to  pcre_study_data block. The study data is put in the latter, which is pointed to
1465  by the former, which may also get additional data set later by the calling  by the former, which may also get additional data set later by the calling
# Line 1421  becomes variable in the future, we don't Line 1470  becomes variable in the future, we don't
1470  if (bits_set || min > 0 || (options & (  if (bits_set || min > 0 || (options & (
1471  #ifdef SUPPORT_JIT  #ifdef SUPPORT_JIT
1472      PCRE_STUDY_JIT_COMPILE | PCRE_STUDY_JIT_PARTIAL_SOFT_COMPILE |      PCRE_STUDY_JIT_COMPILE | PCRE_STUDY_JIT_PARTIAL_SOFT_COMPILE |
1473      PCRE_STUDY_JIT_PARTIAL_HARD_COMPILE |      PCRE_STUDY_JIT_PARTIAL_HARD_COMPILE |
1474  #endif  #endif
1475      PCRE_STUDY_EXTRA_NEEDED)) != 0)      PCRE_STUDY_EXTRA_NEEDED)) != 0)
1476    {    {
# Line 1477  if (bits_set || min > 0 || (options & ( Line 1526  if (bits_set || min > 0 || (options & (
1526    
1527    /* If JIT support was compiled and requested, attempt the JIT compilation.    /* If JIT support was compiled and requested, attempt the JIT compilation.
1528    If no starting bytes were found, and the minimum length is zero, and JIT    If no starting bytes were found, and the minimum length is zero, and JIT
1529    compilation fails, abandon the extra block and return NULL, unless    compilation fails, abandon the extra block and return NULL, unless
1530    PCRE_STUDY_EXTRA_NEEDED is set. */    PCRE_STUDY_EXTRA_NEEDED is set. */
1531    
1532  #ifdef SUPPORT_JIT  #ifdef SUPPORT_JIT
# Line 1492  if (bits_set || min > 0 || (options & ( Line 1541  if (bits_set || min > 0 || (options & (
1541    if (study->flags == 0 && (extra->flags & PCRE_EXTRA_EXECUTABLE_JIT) == 0 &&    if (study->flags == 0 && (extra->flags & PCRE_EXTRA_EXECUTABLE_JIT) == 0 &&
1542        (options & PCRE_STUDY_EXTRA_NEEDED) == 0)        (options & PCRE_STUDY_EXTRA_NEEDED) == 0)
1543      {      {
1544  #ifdef COMPILE_PCRE8  #if defined COMPILE_PCRE8
1545      pcre_free_study(extra);      pcre_free_study(extra);
1546  #endif  #elif defined COMPILE_PCRE16
 #ifdef COMPILE_PCRE16  
1547      pcre16_free_study(extra);      pcre16_free_study(extra);
1548    #elif defined COMPILE_PCRE32
1549        pcre32_free_study(extra);
1550  #endif  #endif
1551      extra = NULL;      extra = NULL;
1552      }      }
# Line 1517  Argument:   a pointer to the pcre[16]_ex Line 1567  Argument:   a pointer to the pcre[16]_ex
1567  Returns:    nothing  Returns:    nothing
1568  */  */
1569    
1570  #ifdef COMPILE_PCRE8  #if defined COMPILE_PCRE8
1571  PCRE_EXP_DEFN void  PCRE_EXP_DEFN void
1572  pcre_free_study(pcre_extra *extra)  pcre_free_study(pcre_extra *extra)
1573  #else  #elif defined COMPILE_PCRE16
1574  PCRE_EXP_DEFN void  PCRE_EXP_DEFN void
1575  pcre16_free_study(pcre16_extra *extra)  pcre16_free_study(pcre16_extra *extra)
1576    #elif defined COMPILE_PCRE32
1577    PCRE_EXP_DEFN void
1578    pcre32_free_study(pcre32_extra *extra)
1579  #endif  #endif
1580  {  {
1581  if (extra == NULL)  if (extra == NULL)

Legend:
Removed from v.1032  
changed lines
  Added in v.1364

  ViewVC Help
Powered by ViewVC 1.1.5