/[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 835 by ph10, Wed Dec 28 16:10:09 2011 UTC revision 1084 by chpe, Tue Oct 16 15:55:28 2012 UTC
# Line 6  Line 6 
6  and semantics are as close as possible to those of the Perl 5 language.  and semantics are as close as possible to those of the Perl 5 language.
7    
8                         Written by Philip Hazel                         Written by Philip Hazel
9             Copyright (c) 1997-2010 University of Cambridge             Copyright (c) 1997-2012 University of Cambridge
10    
11  -----------------------------------------------------------------------------  -----------------------------------------------------------------------------
12  Redistribution and use in source and binary forms, with or without  Redistribution and use in source and binary forms, with or without
# 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;  /* PCRE_UTF16 has the same value as PCRE_UTF8. */
86    BOOL utf = (options & PCRE_UTF8) != 0;
87  BOOL had_recurse = FALSE;  BOOL had_recurse = FALSE;
88  register int branchlength = 0;  register int branchlength = 0;
89  register uschar *cc = (uschar *)code + 1 + LINK_SIZE;  register pcre_uchar *cc = (pcre_uchar *)code + 1 + LINK_SIZE;
90    
91  if (*code == OP_CBRA || *code == OP_SCBRA ||  if (*code == OP_CBRA || *code == OP_SCBRA ||
92      *code == OP_CBRAPOS || *code == OP_SCBRAPOS) cc += 2;      *code == OP_CBRAPOS || *code == OP_SCBRAPOS) cc += IMM2_SIZE;
93    
94  /* Scan along the opcodes for this branch. If we get to the end of the  /* Scan along the opcodes for this branch. If we get to the end of the
95  branch, check the length against that of the other branches. */  branch, check the length against that of the other branches. */
# Line 96  branch, check the length against that of Line 97  branch, check the length against that of
97  for (;;)  for (;;)
98    {    {
99    int d, min;    int d, min;
100    uschar *cs, *ce;    pcre_uchar *cs, *ce;
101    register int op = *cc;    register pcre_uchar op = *cc;
102    
103    switch (op)    switch (op)
104      {      {
# Line 189  for (;;) Line 190  for (;;)
190      case OP_DOLLM:      case OP_DOLLM:
191      case OP_NOT_WORD_BOUNDARY:      case OP_NOT_WORD_BOUNDARY:
192      case OP_WORD_BOUNDARY:      case OP_WORD_BOUNDARY:
193      cc += _pcre_OP_lengths[*cc];      cc += PRIV(OP_lengths)[*cc];
194      break;      break;
195    
196      /* Skip over a subpattern that has a {0} or {0,x} quantifier */      /* Skip over a subpattern that has a {0} or {0,x} quantifier */
# Line 198  for (;;) Line 199  for (;;)
199      case OP_BRAMINZERO:      case OP_BRAMINZERO:
200      case OP_BRAPOSZERO:      case OP_BRAPOSZERO:
201      case OP_SKIPZERO:      case OP_SKIPZERO:
202      cc += _pcre_OP_lengths[*cc];      cc += PRIV(OP_lengths)[*cc];
203      do cc += GET(cc, 1); while (*cc == OP_ALT);      do cc += GET(cc, 1); while (*cc == OP_ALT);
204      cc += 1 + LINK_SIZE;      cc += 1 + LINK_SIZE;
205      break;      break;
# Line 223  for (;;) Line 224  for (;;)
224      case OP_NOTPOSPLUSI:      case OP_NOTPOSPLUSI:
225      branchlength++;      branchlength++;
226      cc += 2;      cc += 2;
227  #ifdef SUPPORT_UTF8  #if defined SUPPORT_UTF && !defined COMPILE_PCRE32
228      if (utf8 && cc[-1] >= 0xc0) cc += _pcre_utf8_table4[cc[-1] & 0x3f];      if (utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);
229  #endif  #endif
230      break;      break;
231    
# Line 243  for (;;) Line 244  for (;;)
244      case OP_NOTEXACT:      case OP_NOTEXACT:
245      case OP_NOTEXACTI:      case OP_NOTEXACTI:
246      branchlength += GET2(cc,1);      branchlength += GET2(cc,1);
247      cc += 4;      cc += 2 + IMM2_SIZE;
248  #ifdef SUPPORT_UTF8  #if defined SUPPORT_UTF && !defined COMPILE_PCRE32
249      if (utf8 && cc[-1] >= 0xc0) cc += _pcre_utf8_table4[cc[-1] & 0x3f];      if (utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);
250  #endif  #endif
251      break;      break;
252    
253      case OP_TYPEEXACT:      case OP_TYPEEXACT:
254      branchlength += GET2(cc,1);      branchlength += GET2(cc,1);
255      cc += (cc[3] == OP_PROP || cc[3] == OP_NOTPROP)? 6 : 4;      cc += 2 + IMM2_SIZE + ((cc[1 + IMM2_SIZE] == OP_PROP
256          || cc[1 + IMM2_SIZE] == OP_NOTPROP)? 2 : 0);
257      break;      break;
258    
259      /* Handle single-char non-literal matchers */      /* Handle single-char non-literal matchers */
# Line 286  for (;;) Line 288  for (;;)
288      cc++;      cc++;
289      break;      break;
290    
291      /* The single-byte matcher means we can't proceed in UTF-8 mode. (In      /* The single-byte matcher means we can't proceed in UTF-8 mode. (In
292      non-UTF-8 mode \C will actually be turned into OP_ALLANY, so won't ever      non-UTF-8 mode \C will actually be turned into OP_ALLANY, so won't ever
293      appear, but leave the code, just in case.) */      appear, but leave the code, just in case.) */
294    
295      case OP_ANYBYTE:      case OP_ANYBYTE:
296  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF
297      if (utf8) return -1;      if (utf) return -1;
298  #endif  #endif
299      branchlength++;      branchlength++;
300      cc++;      cc++;
# Line 308  for (;;) Line 310  for (;;)
310      case OP_TYPEPOSSTAR:      case OP_TYPEPOSSTAR:
311      case OP_TYPEPOSQUERY:      case OP_TYPEPOSQUERY:
312      if (cc[1] == OP_PROP || cc[1] == OP_NOTPROP) cc += 2;      if (cc[1] == OP_PROP || cc[1] == OP_NOTPROP) cc += 2;
313      cc += _pcre_OP_lengths[op];      cc += PRIV(OP_lengths)[op];
314      break;      break;
315    
316      case OP_TYPEUPTO:      case OP_TYPEUPTO:
317      case OP_TYPEMINUPTO:      case OP_TYPEMINUPTO:
318      case OP_TYPEPOSUPTO:      case OP_TYPEPOSUPTO:
319      if (cc[3] == OP_PROP || cc[3] == OP_NOTPROP) cc += 2;      if (cc[1 + IMM2_SIZE] == OP_PROP
320      cc += _pcre_OP_lengths[op];        || cc[1 + IMM2_SIZE] == OP_NOTPROP) cc += 2;
321        cc += PRIV(OP_lengths)[op];
322      break;      break;
323    
324      /* Check a class for variable quantification */      /* Check a class for variable quantification */
325    
326  #ifdef SUPPORT_UTF8  #if defined SUPPORT_UTF || !defined COMPILE_PCRE8
327      case OP_XCLASS:      case OP_XCLASS:
328      cc += GET(cc, 1) - 33;      cc += GET(cc, 1) - PRIV(OP_lengths)[OP_CLASS];
329      /* Fall through */      /* Fall through */
330  #endif  #endif
331    
332      case OP_CLASS:      case OP_CLASS:
333      case OP_NCLASS:      case OP_NCLASS:
334      cc += 33;      cc += PRIV(OP_lengths)[OP_CLASS];
335    
336      switch (*cc)      switch (*cc)
337        {        {
# Line 347  for (;;) Line 350  for (;;)
350        case OP_CRRANGE:        case OP_CRRANGE:
351        case OP_CRMINRANGE:        case OP_CRMINRANGE:
352        branchlength += GET2(cc,1);        branchlength += GET2(cc,1);
353        cc += 5;        cc += 1 + 2 * IMM2_SIZE;
354        break;        break;
355    
356        default:        default:
# Line 372  for (;;) Line 375  for (;;)
375      case OP_REFI:      case OP_REFI:
376      if ((options & PCRE_JAVASCRIPT_COMPAT) == 0)      if ((options & PCRE_JAVASCRIPT_COMPAT) == 0)
377        {        {
378        ce = cs = (uschar *)_pcre_find_bracket(startcode, utf8, GET2(cc, 1));        ce = cs = (pcre_uchar *)PRIV(find_bracket)(startcode, utf, GET2(cc, 1));
379        if (cs == NULL) return -2;        if (cs == NULL) return -2;
380        do ce += GET(ce, 1); while (*ce == OP_ALT);        do ce += GET(ce, 1); while (*ce == OP_ALT);
381        if (cc > cs && cc < ce)        if (cc > cs && cc < ce)
# Line 386  for (;;) Line 389  for (;;)
389          }          }
390        }        }
391      else d = 0;      else d = 0;
392      cc += 3;      cc += 1 + IMM2_SIZE;
393    
394      /* Handle repeated back references */      /* Handle repeated back references */
395    
# Line 409  for (;;) Line 412  for (;;)
412        case OP_CRRANGE:        case OP_CRRANGE:
413        case OP_CRMINRANGE:        case OP_CRMINRANGE:
414        min = GET2(cc, 1);        min = GET2(cc, 1);
415        cc += 5;        cc += 1 + 2 * IMM2_SIZE;
416        break;        break;
417    
418        default:        default:
# Line 424  for (;;) Line 427  for (;;)
427      caught by a recursion depth count. */      caught by a recursion depth count. */
428    
429      case OP_RECURSE:      case OP_RECURSE:
430      cs = ce = (uschar *)startcode + GET(cc, 1);      cs = ce = (pcre_uchar *)startcode + GET(cc, 1);
431      do ce += GET(ce, 1); while (*ce == OP_ALT);      do ce += GET(ce, 1); while (*ce == OP_ALT);
432      if ((cc > cs && cc < ce) || recurse_depth > 10)      if ((cc > cs && cc < ce) || recurse_depth > 10)
433        had_recurse = TRUE;        had_recurse = TRUE;
# Line 482  for (;;) Line 485  for (;;)
485      case OP_NOTPOSQUERY:      case OP_NOTPOSQUERY:
486      case OP_NOTPOSQUERYI:      case OP_NOTPOSQUERYI:
487    
488      cc += _pcre_OP_lengths[op];      cc += PRIV(OP_lengths)[op];
489  #ifdef SUPPORT_UTF8  #if defined SUPPORT_UTF && !defined COMPILE_PCRE32
490      if (utf8 && cc[-1] >= 0xc0) cc += _pcre_utf8_table4[cc[-1] & 0x3f];      if (utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);
491  #endif  #endif
492      break;      break;
493    
# Line 494  for (;;) Line 497  for (;;)
497      case OP_PRUNE_ARG:      case OP_PRUNE_ARG:
498      case OP_SKIP_ARG:      case OP_SKIP_ARG:
499      case OP_THEN_ARG:      case OP_THEN_ARG:
500      cc += _pcre_OP_lengths[op] + cc[1];      cc += PRIV(OP_lengths)[op] + cc[1];
501      break;      break;
502    
503      /* The remaining opcodes are just skipped over. */      /* The remaining opcodes are just skipped over. */
# Line 506  for (;;) Line 509  for (;;)
509      case OP_SET_SOM:      case OP_SET_SOM:
510      case OP_SKIP:      case OP_SKIP:
511      case OP_THEN:      case OP_THEN:
512      cc += _pcre_OP_lengths[op];      cc += PRIV(OP_lengths)[op];
513      break;      break;
514    
515      /* This should not occur: we list all opcodes explicitly so that when      /* This should not occur: we list all opcodes explicitly so that when
# Line 535  Arguments: Line 538  Arguments:
538    p             points to the character    p             points to the character
539    caseless      the caseless flag    caseless      the caseless flag
540    cd            the block with char table pointers    cd            the block with char table pointers
541    utf8          TRUE for UTF-8 mode    utf           TRUE for UTF-8 / UTF-16 / UTF-32 mode
542    
543  Returns:        pointer after the character  Returns:        pointer after the character
544  */  */
545    
546  static const uschar *  static const pcre_uchar *
547  set_table_bit(uschar *start_bits, const uschar *p, BOOL caseless,  set_table_bit(pcre_uint8 *start_bits, const pcre_uchar *p, BOOL caseless,
548    compile_data *cd, BOOL utf8)    compile_data *cd, BOOL utf)
549  {  {
550  unsigned int c = *p;  unsigned int c = *p;
551    
552    #ifdef COMPILE_PCRE8
553  SET_BIT(c);  SET_BIT(c);
554    
555  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF
556  if (utf8 && c > 127)  if (utf && c > 127)
557    {    {
558    GETCHARINC(c, p);    GETCHARINC(c, p);
559  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
560    if (caseless)    if (caseless)
561      {      {
562      uschar buff[8];      pcre_uchar buff[6];
563      c = UCD_OTHERCASE(c);      c = UCD_OTHERCASE(c);
564      (void)_pcre_ord2utf8(c, buff);      (void)PRIV(ord2utf)(c, buff);
565      SET_BIT(buff[0]);      SET_BIT(buff[0]);
566      }      }
567  #endif  #endif  /* Not SUPPORT_UCP */
568    return p;    return p;
569    }    }
570  #endif  #else   /* Not SUPPORT_UTF */
571    (void)(utf);   /* Stops warning for unused parameter */
572    #endif  /* SUPPORT_UTF */
573    
574  /* Not UTF-8 mode, or character is less than 127. */  /* Not UTF-8 mode, or character is less than 127. */
575    
576  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]);
577  return p + 1;  return p + 1;
578    #endif  /* COMPILE_PCRE8 */
579    
580    #if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
581    if (c > 0xff)
582      {
583      c = 0xff;
584      caseless = FALSE;
585      }
586    SET_BIT(c);
587    
588    #ifdef SUPPORT_UTF
589    if (utf && c > 127)
590      {
591      GETCHARINC(c, p);
592    #ifdef SUPPORT_UCP
593      if (caseless)
594        {
595        c = UCD_OTHERCASE(c);
596        if (c > 0xff)
597          c = 0xff;
598        SET_BIT(c);
599        }
600    #endif  /* SUPPORT_UCP */
601      return p;
602      }
603    #else   /* Not SUPPORT_UTF */
604    (void)(utf);   /* Stops warning for unused parameter */
605    #endif  /* SUPPORT_UTF */
606    
607    if (caseless && (cd->ctypes[c] & ctype_letter) != 0) SET_BIT(cd->fcc[c]);
608    return p + 1;
609    #endif
610  }  }
611    
612    
# Line 594  Returns:         nothing Line 632  Returns:         nothing
632  */  */
633    
634  static void  static void
635  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,
636    compile_data *cd)    compile_data *cd)
637  {  {
638  register int c;  register int c;
639  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];
640    #if defined SUPPORT_UTF && defined COMPILE_PCRE8
641  if (table_limit == 32) return;  if (table_limit == 32) return;
642  for (c = 128; c < 256; c++)  for (c = 128; c < 256; c++)
643    {    {
644    if ((cd->cbits[c/8] & (1 << (c&7))) != 0)    if ((cd->cbits[c/8] & (1 << (c&7))) != 0)
645      {      {
646      uschar buff[8];      pcre_uchar buff[6];
647      (void)_pcre_ord2utf8(c, buff);      (void)PRIV(ord2utf)(c, buff);
648      SET_BIT(buff[0]);      SET_BIT(buff[0]);
649      }      }
650    }    }
651    #endif
652  }  }
653    
654    
# Line 634  Returns:         nothing Line 674  Returns:         nothing
674  */  */
675    
676  static void  static void
677  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,
678    compile_data *cd)    compile_data *cd)
679  {  {
680  register int c;  register int c;
681  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];
682    #if defined SUPPORT_UTF && defined COMPILE_PCRE8
683  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;
684    #endif
685  }  }
686    
687    
# Line 659  function fails unless the result is SSB_ Line 701  function fails unless the result is SSB_
701  Arguments:  Arguments:
702    code         points to an expression    code         points to an expression
703    start_bits   points to a 32-byte table, initialized to 0    start_bits   points to a 32-byte table, initialized to 0
704    utf8         TRUE if in UTF-8 mode    utf          TRUE if in UTF-8 / UTF-16 / UTF-32 mode
705    cd           the block with char table pointers    cd           the block with char table pointers
706    
707  Returns:       SSB_FAIL     => Failed to find any starting bytes  Returns:       SSB_FAIL     => Failed to find any starting bytes
# Line 669  Returns:       SSB_FAIL     => Failed to Line 711  Returns:       SSB_FAIL     => Failed to
711  */  */
712    
713  static int  static int
714  set_start_bits(const uschar *code, uschar *start_bits, BOOL utf8,  set_start_bits(const pcre_uchar *code, pcre_uint8 *start_bits, BOOL utf,
715    compile_data *cd)    compile_data *cd)
716  {  {
717  register int c;  register int c;
718  int yield = SSB_DONE;  int yield = SSB_DONE;
719  int table_limit = utf8? 16:32;  #if defined SUPPORT_UTF && defined COMPILE_PCRE8
720    int table_limit = utf? 16:32;
721    #else
722    int table_limit = 32;
723    #endif
724    
725  #if 0  #if 0
726  /* ========================================================================= */  /* ========================================================================= */
# Line 696  volatile int dummy; Line 742  volatile int dummy;
742  do  do
743    {    {
744    BOOL try_next = TRUE;    BOOL try_next = TRUE;
745    const uschar *tcode = code + 1 + LINK_SIZE;    const pcre_uchar *tcode = code + 1 + LINK_SIZE;
746    
747    if (*code == OP_CBRA || *code == OP_SCBRA ||    if (*code == OP_CBRA || *code == OP_SCBRA ||
748        *code == OP_CBRAPOS || *code == OP_SCBRAPOS) tcode += 2;        *code == OP_CBRAPOS || *code == OP_SCBRAPOS) tcode += IMM2_SIZE;
749    
750    while (try_next)    /* Loop for items in this branch */    while (try_next)    /* Loop for items in this branch */
751      {      {
# Line 785  do Line 831  do
831        case OP_SOM:        case OP_SOM:
832        case OP_THEN:        case OP_THEN:
833        case OP_THEN_ARG:        case OP_THEN_ARG:
834    #if defined SUPPORT_UTF || !defined COMPILE_PCRE8
835        case OP_XCLASS:        case OP_XCLASS:
836    #endif
837        return SSB_FAIL;        return SSB_FAIL;
838    
839        /* We can ignore word boundary tests. */        /* We can ignore word boundary tests. */
# Line 811  do Line 859  do
859        case OP_ONCE:        case OP_ONCE:
860        case OP_ONCE_NC:        case OP_ONCE_NC:
861        case OP_ASSERT:        case OP_ASSERT:
862        rc = set_start_bits(tcode, start_bits, utf8, cd);        rc = set_start_bits(tcode, start_bits, utf, cd);
863        if (rc == SSB_FAIL || rc == SSB_UNKNOWN) return rc;        if (rc == SSB_FAIL || rc == SSB_UNKNOWN) return rc;
864        if (rc == SSB_DONE) try_next = FALSE; else        if (rc == SSB_DONE) try_next = FALSE; else
865          {          {
# Line 858  do Line 906  do
906        case OP_BRAZERO:        case OP_BRAZERO:
907        case OP_BRAMINZERO:        case OP_BRAMINZERO:
908        case OP_BRAPOSZERO:        case OP_BRAPOSZERO:
909        rc = set_start_bits(++tcode, start_bits, utf8, cd);        rc = set_start_bits(++tcode, start_bits, utf, cd);
910        if (rc == SSB_FAIL || rc == SSB_UNKNOWN) return rc;        if (rc == SSB_FAIL || rc == SSB_UNKNOWN) return rc;
911  /* =========================================================================  /* =========================================================================
912        See the comment at the head of this function concerning the next line,        See the comment at the head of this function concerning the next line,
# Line 885  do Line 933  do
933        case OP_QUERY:        case OP_QUERY:
934        case OP_MINQUERY:        case OP_MINQUERY:
935        case OP_POSQUERY:        case OP_POSQUERY:
936        tcode = set_table_bit(start_bits, tcode + 1, FALSE, cd, utf8);        tcode = set_table_bit(start_bits, tcode + 1, FALSE, cd, utf);
937        break;        break;
938    
939        case OP_STARI:        case OP_STARI:
# Line 894  do Line 942  do
942        case OP_QUERYI:        case OP_QUERYI:
943        case OP_MINQUERYI:        case OP_MINQUERYI:
944        case OP_POSQUERYI:        case OP_POSQUERYI:
945        tcode = set_table_bit(start_bits, tcode + 1, TRUE, cd, utf8);        tcode = set_table_bit(start_bits, tcode + 1, TRUE, cd, utf);
946        break;        break;
947    
948        /* Single-char upto sets the bit and tries the next */        /* Single-char upto sets the bit and tries the next */
# Line 902  do Line 950  do
950        case OP_UPTO:        case OP_UPTO:
951        case OP_MINUPTO:        case OP_MINUPTO:
952        case OP_POSUPTO:        case OP_POSUPTO:
953        tcode = set_table_bit(start_bits, tcode + 3, FALSE, cd, utf8);        tcode = set_table_bit(start_bits, tcode + 1 + IMM2_SIZE, FALSE, cd, utf);
954        break;        break;
955    
956        case OP_UPTOI:        case OP_UPTOI:
957        case OP_MINUPTOI:        case OP_MINUPTOI:
958        case OP_POSUPTOI:        case OP_POSUPTOI:
959        tcode = set_table_bit(start_bits, tcode + 3, TRUE, cd, utf8);        tcode = set_table_bit(start_bits, tcode + 1 + IMM2_SIZE, TRUE, cd, utf);
960        break;        break;
961    
962        /* At least one single char sets the bit and stops */        /* At least one single char sets the bit and stops */
963    
964        case OP_EXACT:        case OP_EXACT:
965        tcode += 2;        tcode += IMM2_SIZE;
966        /* Fall through */        /* Fall through */
967        case OP_CHAR:        case OP_CHAR:
968        case OP_PLUS:        case OP_PLUS:
969        case OP_MINPLUS:        case OP_MINPLUS:
970        case OP_POSPLUS:        case OP_POSPLUS:
971        (void)set_table_bit(start_bits, tcode + 1, FALSE, cd, utf8);        (void)set_table_bit(start_bits, tcode + 1, FALSE, cd, utf);
972        try_next = FALSE;        try_next = FALSE;
973        break;        break;
974    
975        case OP_EXACTI:        case OP_EXACTI:
976        tcode += 2;        tcode += IMM2_SIZE;
977        /* Fall through */        /* Fall through */
978        case OP_CHARI:        case OP_CHARI:
979        case OP_PLUSI:        case OP_PLUSI:
980        case OP_MINPLUSI:        case OP_MINPLUSI:
981        case OP_POSPLUSI:        case OP_POSPLUSI:
982        (void)set_table_bit(start_bits, tcode + 1, TRUE, cd, utf8);        (void)set_table_bit(start_bits, tcode + 1, TRUE, cd, utf);
983        try_next = FALSE;        try_next = FALSE;
984        break;        break;
985    
# Line 942  do Line 990  do
990        identical. */        identical. */
991    
992        case OP_HSPACE:        case OP_HSPACE:
993        SET_BIT(0x09);        SET_BIT(CHAR_HT);
994        SET_BIT(0x20);        SET_BIT(CHAR_SPACE);
995        if (utf8)  #ifdef SUPPORT_UTF
996          if (utf)
997          {          {
998    #ifdef COMPILE_PCRE8
999          SET_BIT(0xC2);  /* For U+00A0 */          SET_BIT(0xC2);  /* For U+00A0 */
1000          SET_BIT(0xE1);  /* For U+1680, U+180E */          SET_BIT(0xE1);  /* For U+1680, U+180E */
1001          SET_BIT(0xE2);  /* For U+2000 - U+200A, U+202F, U+205F */          SET_BIT(0xE2);  /* For U+2000 - U+200A, U+202F, U+205F */
1002          SET_BIT(0xE3);  /* For U+3000 */          SET_BIT(0xE3);  /* For U+3000 */
1003    #elif defined COMPILE_PCRE16 || defined COMPILE_PCRE32
1004            SET_BIT(0xA0);
1005            SET_BIT(0xFF);  /* For characters > 255 */
1006    #endif  /* COMPILE_PCRE[8|16|32] */
1007            }
1008          else
1009    #endif /* SUPPORT_UTF */
1010            {
1011    #ifndef EBCDIC
1012            SET_BIT(0xA0);
1013    #endif  /* Not EBCDIC */
1014    #if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
1015            SET_BIT(0xFF);  /* For characters > 255 */
1016    #endif  /* COMPILE_PCRE[16|32] */
1017          }          }
       else SET_BIT(0xA0);  
1018        try_next = FALSE;        try_next = FALSE;
1019        break;        break;
1020    
1021        case OP_ANYNL:        case OP_ANYNL:
1022        case OP_VSPACE:        case OP_VSPACE:
1023        SET_BIT(0x0A);        SET_BIT(CHAR_LF);
1024        SET_BIT(0x0B);        SET_BIT(CHAR_VT);
1025        SET_BIT(0x0C);        SET_BIT(CHAR_FF);
1026        SET_BIT(0x0D);        SET_BIT(CHAR_CR);
1027        if (utf8)  #ifdef SUPPORT_UTF
1028          if (utf)
1029          {          {
1030    #ifdef COMPILE_PCRE8
1031          SET_BIT(0xC2);  /* For U+0085 */          SET_BIT(0xC2);  /* For U+0085 */
1032          SET_BIT(0xE2);  /* For U+2028, U+2029 */          SET_BIT(0xE2);  /* For U+2028, U+2029 */
1033    #elif defined COMPILE_PCRE16 || defined COMPILE_PCRE32
1034            SET_BIT(CHAR_NEL);
1035            SET_BIT(0xFF);  /* For characters > 255 */
1036    #endif  /* COMPILE_PCRE[8|16|32] */
1037            }
1038          else
1039    #endif /* SUPPORT_UTF */
1040            {
1041            SET_BIT(CHAR_NEL);
1042    #if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
1043            SET_BIT(0xFF);  /* For characters > 255 */
1044    #endif
1045          }          }
       else SET_BIT(0x85);  
1046        try_next = FALSE;        try_next = FALSE;
1047        break;        break;
1048    
# Line 986  do Line 1062  do
1062        break;        break;
1063    
1064        /* The cbit_space table has vertical tab as whitespace; we have to        /* The cbit_space table has vertical tab as whitespace; we have to
1065        ensure it is set as not whitespace. */        ensure it is set as not whitespace. Luckily, the code value is the same
1066          (0x0b) in ASCII and EBCDIC, so we can just adjust the appropriate bit. */
1067    
1068        case OP_NOT_WHITESPACE:        case OP_NOT_WHITESPACE:
1069        set_nottype_bits(start_bits, cbit_space, table_limit, cd);        set_nottype_bits(start_bits, cbit_space, table_limit, cd);
# Line 994  do Line 1071  do
1071        try_next = FALSE;        try_next = FALSE;
1072        break;        break;
1073    
1074        /* 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
1075        not set it from the table. */        set it from the table. Luckily, the code value is the same (0x0b) in
1076          ASCII and EBCDIC, so we can just adjust the appropriate bit. */
1077    
1078        case OP_WHITESPACE:        case OP_WHITESPACE:
1079        c = start_bits[1];    /* Save in case it was already set */        c = start_bits[1];    /* Save in case it was already set */
# Line 1024  do Line 1102  do
1102        break;        break;
1103    
1104        case OP_TYPEEXACT:        case OP_TYPEEXACT:
1105        tcode += 3;        tcode += 1 + IMM2_SIZE;
1106        break;        break;
1107    
1108        /* Zero or more repeats of character types set the bits and then        /* Zero or more repeats of character types set the bits and then
# Line 1033  do Line 1111  do
1111        case OP_TYPEUPTO:        case OP_TYPEUPTO:
1112        case OP_TYPEMINUPTO:        case OP_TYPEMINUPTO:
1113        case OP_TYPEPOSUPTO:        case OP_TYPEPOSUPTO:
1114        tcode += 2;               /* Fall through */        tcode += IMM2_SIZE;  /* Fall through */
1115    
1116        case OP_TYPESTAR:        case OP_TYPESTAR:
1117        case OP_TYPEMINSTAR:        case OP_TYPEMINSTAR:
# Line 1049  do Line 1127  do
1127          return SSB_FAIL;          return SSB_FAIL;
1128    
1129          case OP_HSPACE:          case OP_HSPACE:
1130          SET_BIT(0x09);          SET_BIT(CHAR_HT);
1131          SET_BIT(0x20);          SET_BIT(CHAR_SPACE);
1132          if (utf8)  #ifdef SUPPORT_UTF
1133            if (utf)
1134            {            {
1135    #ifdef COMPILE_PCRE8
1136            SET_BIT(0xC2);  /* For U+00A0 */            SET_BIT(0xC2);  /* For U+00A0 */
1137            SET_BIT(0xE1);  /* For U+1680, U+180E */            SET_BIT(0xE1);  /* For U+1680, U+180E */
1138            SET_BIT(0xE2);  /* For U+2000 - U+200A, U+202F, U+205F */            SET_BIT(0xE2);  /* For U+2000 - U+200A, U+202F, U+205F */
1139            SET_BIT(0xE3);  /* For U+3000 */            SET_BIT(0xE3);  /* For U+3000 */
1140    #elif defined COMPILE_PCRE16 || defined COMPILE_PCRE32
1141              SET_BIT(0xA0);
1142              SET_BIT(0xFF);  /* For characters > 255 */
1143    #endif  /* COMPILE_PCRE[8|16|32] */
1144            }            }
1145          else SET_BIT(0xA0);          else
1146    #endif /* SUPPORT_UTF */
1147    #ifndef EBCDIC
1148              SET_BIT(0xA0);
1149    #endif  /* Not EBCDIC */
1150          break;          break;
1151    
1152          case OP_ANYNL:          case OP_ANYNL:
1153          case OP_VSPACE:          case OP_VSPACE:
1154          SET_BIT(0x0A);          SET_BIT(CHAR_LF);
1155          SET_BIT(0x0B);          SET_BIT(CHAR_VT);
1156          SET_BIT(0x0C);          SET_BIT(CHAR_FF);
1157          SET_BIT(0x0D);          SET_BIT(CHAR_CR);
1158          if (utf8)  #ifdef SUPPORT_UTF
1159            if (utf)
1160            {            {
1161    #ifdef COMPILE_PCRE8
1162            SET_BIT(0xC2);  /* For U+0085 */            SET_BIT(0xC2);  /* For U+0085 */
1163            SET_BIT(0xE2);  /* For U+2028, U+2029 */            SET_BIT(0xE2);  /* For U+2028, U+2029 */
1164    #elif defined COMPILE_PCRE16 || defined COMPILE_PCRE32
1165              SET_BIT(CHAR_NEL);
1166              SET_BIT(0xFF);  /* For characters > 255 */
1167    #endif  /* COMPILE_PCRE16 */
1168            }            }
1169          else SET_BIT(0x85);          else
1170    #endif /* SUPPORT_UTF */
1171              SET_BIT(CHAR_NEL);
1172          break;          break;
1173    
1174          case OP_NOT_DIGIT:          case OP_NOT_DIGIT:
# Line 1084  do Line 1180  do
1180          break;          break;
1181    
1182          /* The cbit_space table has vertical tab as whitespace; we have to          /* The cbit_space table has vertical tab as whitespace; we have to
1183          ensure it gets set as not whitespace. */          ensure it gets set as not whitespace. Luckily, the code value is the
1184            same (0x0b) in ASCII and EBCDIC, so we can just adjust the appropriate
1185            bit. */
1186    
1187          case OP_NOT_WHITESPACE:          case OP_NOT_WHITESPACE:
1188          set_nottype_bits(start_bits, cbit_space, table_limit, cd);          set_nottype_bits(start_bits, cbit_space, table_limit, cd);
# Line 1092  do Line 1190  do
1190          break;          break;
1191    
1192          /* The cbit_space table has vertical tab as whitespace; we have to          /* The cbit_space table has vertical tab as whitespace; we have to
1193          avoid setting it. */          avoid setting it. Luckily, the code value is the same (0x0b) in ASCII
1194            and EBCDIC, so we can just adjust the appropriate bit. */
1195    
1196          case OP_WHITESPACE:          case OP_WHITESPACE:
1197          c = start_bits[1];    /* Save in case it was already set */          c = start_bits[1];    /* Save in case it was already set */
# Line 1119  do Line 1218  do
1218        character with a value > 255. */        character with a value > 255. */
1219    
1220        case OP_NCLASS:        case OP_NCLASS:
1221  #ifdef SUPPORT_UTF8  #if defined SUPPORT_UTF && defined COMPILE_PCRE8
1222        if (utf8)        if (utf)
1223          {          {
1224          start_bits[24] |= 0xf0;              /* Bits for 0xc4 - 0xc8 */          start_bits[24] |= 0xf0;              /* Bits for 0xc4 - 0xc8 */
1225          memset(start_bits+25, 0xff, 7);      /* Bits for 0xc9 - 0xff */          memset(start_bits+25, 0xff, 7);      /* Bits for 0xc9 - 0xff */
1226          }          }
1227  #endif  #endif
1228    #if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
1229          SET_BIT(0xFF);                         /* For characters > 255 */
1230    #endif
1231        /* Fall through */        /* Fall through */
1232    
1233        case OP_CLASS:        case OP_CLASS:
1234          {          {
1235            pcre_uint8 *map;
1236          tcode++;          tcode++;
1237            map = (pcre_uint8 *)tcode;
1238    
1239          /* In UTF-8 mode, the bits in a bit map correspond to character          /* In UTF-8 mode, the bits in a bit map correspond to character
1240          values, not to byte values. However, the bit map we are constructing is          values, not to byte values. However, the bit map we are constructing is
# Line 1138  do Line 1242  do
1242          value is > 127. In fact, there are only two possible starting bytes for          value is > 127. In fact, there are only two possible starting bytes for
1243          characters in the range 128 - 255. */          characters in the range 128 - 255. */
1244    
1245  #ifdef SUPPORT_UTF8  #if defined SUPPORT_UTF && defined COMPILE_PCRE8
1246          if (utf8)          if (utf)
1247            {            {
1248            for (c = 0; c < 16; c++) start_bits[c] |= tcode[c];            for (c = 0; c < 16; c++) start_bits[c] |= map[c];
1249            for (c = 128; c < 256; c++)            for (c = 128; c < 256; c++)
1250              {              {
1251              if ((tcode[c/8] && (1 << (c&7))) != 0)              if ((map[c/8] && (1 << (c&7))) != 0)
1252                {                {
1253                int d = (c >> 6) | 0xc0;            /* Set bit for this starter */                int d = (c >> 6) | 0xc0;            /* Set bit for this starter */
1254                start_bits[d/8] |= (1 << (d&7));    /* and then skip on to the */                start_bits[d/8] |= (1 << (d&7));    /* and then skip on to the */
# Line 1152  do Line 1256  do
1256                }                }
1257              }              }
1258            }            }
   
         /* In non-UTF-8 mode, the two bit maps are completely compatible. */  
   
1259          else          else
1260  #endif  #endif
1261            {            {
1262            for (c = 0; c < 32; c++) start_bits[c] |= tcode[c];            /* In non-UTF-8 mode, the two bit maps are completely compatible. */
1263              for (c = 0; c < 32; c++) start_bits[c] |= map[c];
1264            }            }
1265    
1266          /* Advance past the bit map, and act on what follows. For a zero          /* Advance past the bit map, and act on what follows. For a zero
1267          minimum repeat, continue; otherwise stop processing. */          minimum repeat, continue; otherwise stop processing. */
1268    
1269          tcode += 32;          tcode += 32 / sizeof(pcre_uchar);
1270          switch (*tcode)          switch (*tcode)
1271            {            {
1272            case OP_CRSTAR:            case OP_CRSTAR:
# Line 1176  do Line 1278  do
1278    
1279            case OP_CRRANGE:            case OP_CRRANGE:
1280            case OP_CRMINRANGE:            case OP_CRMINRANGE:
1281            if (((tcode[1] << 8) + tcode[2]) == 0) tcode += 5;            if (GET2(tcode, 1) == 0) tcode += 1 + 2 * IMM2_SIZE;
1282              else try_next = FALSE;              else try_next = FALSE;
1283            break;            break;
1284    
# Line 1205  return yield; Line 1307  return yield;
1307  *************************************************/  *************************************************/
1308    
1309  /* This function is handed a compiled expression that it must study to produce  /* This function is handed a compiled expression that it must study to produce
1310  information that will speed up the matching. It returns a pcre_extra block  information that will speed up the matching. It returns a pcre[16]_extra block
1311  which then gets handed back to pcre_exec().  which then gets handed back to pcre_exec().
1312    
1313  Arguments:  Arguments:
# Line 1214  Arguments: Line 1316  Arguments:
1316    errorptr  points to where to place error messages;    errorptr  points to where to place error messages;
1317              set NULL unless error              set NULL unless error
1318    
1319  Returns:    pointer to a pcre_extra block, with study_data filled in and the  Returns:    pointer to a pcre[16]_extra block, with study_data filled in and
1320                appropriate flags set;                the appropriate flags set;
1321              NULL on error or if no optimization possible              NULL on error or if no optimization possible
1322  */  */
1323    
1324    #if defined COMPILE_PCRE8
1325  PCRE_EXP_DEFN pcre_extra * PCRE_CALL_CONVENTION  PCRE_EXP_DEFN pcre_extra * PCRE_CALL_CONVENTION
1326  pcre_study(const pcre *external_re, int options, const char **errorptr)  pcre_study(const pcre *external_re, int options, const char **errorptr)
1327    #elif defined COMPILE_PCRE16
1328    PCRE_EXP_DEFN pcre16_extra * PCRE_CALL_CONVENTION
1329    pcre16_study(const pcre16 *external_re, int options, const char **errorptr)
1330    #elif defined COMPILE_PCRE32
1331    PCRE_EXP_DEFN pcre32_extra * PCRE_CALL_CONVENTION
1332    pcre32_study(const pcre32 *external_re, int options, const char **errorptr)
1333    #endif
1334  {  {
1335  int min;  int min;
1336  BOOL bits_set = FALSE;  BOOL bits_set = FALSE;
1337  uschar start_bits[32];  pcre_uint8 start_bits[32];
1338  pcre_extra *extra = NULL;  PUBL(extra) *extra = NULL;
1339  pcre_study_data *study;  pcre_study_data *study;
1340  const uschar *tables;  const pcre_uint8 *tables;
1341  uschar *code;  pcre_uchar *code;
1342  compile_data compile_block;  compile_data compile_block;
1343  const real_pcre *re = (const real_pcre *)external_re;  const REAL_PCRE *re = (const REAL_PCRE *)external_re;
1344    
1345  *errorptr = NULL;  *errorptr = NULL;
1346    
# Line 1240  if (re == NULL || re->magic_number != MA Line 1350  if (re == NULL || re->magic_number != MA
1350    return NULL;    return NULL;
1351    }    }
1352    
1353    if ((re->flags & PCRE_MODE) == 0)
1354      {
1355    #if defined COMPILE_PCRE8
1356      *errorptr = "argument not compiled in 8 bit mode";
1357    #elif defined COMPILE_PCRE16
1358      *errorptr = "argument not compiled in 16 bit mode";
1359    #elif defined COMPILE_PCRE32
1360      *errorptr = "argument not compiled in 32 bit mode";
1361    #endif
1362      return NULL;
1363      }
1364    
1365  if ((options & ~PUBLIC_STUDY_OPTIONS) != 0)  if ((options & ~PUBLIC_STUDY_OPTIONS) != 0)
1366    {    {
1367    *errorptr = "unknown or incorrect option bit(s) set";    *errorptr = "unknown or incorrect option bit(s) set";
1368    return NULL;    return NULL;
1369    }    }
1370    
1371  code = (uschar *)re + re->name_table_offset +  code = (pcre_uchar *)re + re->name_table_offset +
1372    (re->name_count * re->name_entry_size);    (re->name_count * re->name_entry_size);
1373    
1374  /* 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 1261  if ((re->options & PCRE_ANCHORED) == 0 & Line 1383  if ((re->options & PCRE_ANCHORED) == 0 &
1383    /* Set the character tables in the block that is passed around */    /* Set the character tables in the block that is passed around */
1384    
1385    tables = re->tables;    tables = re->tables;
1386    
1387    #if defined COMPILE_PCRE8
1388    if (tables == NULL)    if (tables == NULL)
1389      (void)pcre_fullinfo(external_re, NULL, PCRE_INFO_DEFAULT_TABLES,      (void)pcre_fullinfo(external_re, NULL, PCRE_INFO_DEFAULT_TABLES,
1390      (void *)(&tables));      (void *)(&tables));
1391    #elif defined COMPILE_PCRE16
1392      if (tables == NULL)
1393        (void)pcre16_fullinfo(external_re, NULL, PCRE_INFO_DEFAULT_TABLES,
1394        (void *)(&tables));
1395    #elif defined COMPILE_PCRE32
1396      if (tables == NULL)
1397        (void)pcre32_fullinfo(external_re, NULL, PCRE_INFO_DEFAULT_TABLES,
1398        (void *)(&tables));
1399    #endif
1400    
1401    compile_block.lcc = tables + lcc_offset;    compile_block.lcc = tables + lcc_offset;
1402    compile_block.fcc = tables + fcc_offset;    compile_block.fcc = tables + fcc_offset;
# Line 1272  if ((re->options & PCRE_ANCHORED) == 0 & Line 1405  if ((re->options & PCRE_ANCHORED) == 0 &
1405    
1406    /* 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. */
1407    
1408    memset(start_bits, 0, 32 * sizeof(uschar));    memset(start_bits, 0, 32 * sizeof(pcre_uint8));
1409    rc = set_start_bits(code, start_bits, (re->options & PCRE_UTF8) != 0,    rc = set_start_bits(code, start_bits, (re->options & PCRE_UTF8) != 0,
1410      &compile_block);      &compile_block);
1411    bits_set = rc == SSB_DONE;    bits_set = rc == SSB_DONE;
# Line 1293  switch(min = find_minlength(code, code, Line 1426  switch(min = find_minlength(code, code,
1426    }    }
1427    
1428  /* 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
1429  greater than zero, or if JIT optimization has been requested, get a pcre_extra  greater than zero, or if JIT optimization has been requested, or if
1430  block and a pcre_study_data block. The study data is put in the latter, which  PCRE_STUDY_EXTRA_NEEDED is set, get a pcre[16]_extra block and a
1431  is pointed to by the former, which may also get additional data set later by  pcre_study_data block. The study data is put in the latter, which is pointed to
1432  the calling program. At the moment, the size of pcre_study_data is fixed. We  by the former, which may also get additional data set later by the calling
1433  nevertheless save it in a field for returning via the pcre_fullinfo() function  program. At the moment, the size of pcre_study_data is fixed. We nevertheless
1434  so that if it becomes variable in the future, we don't have to change that  save it in a field for returning via the pcre_fullinfo() function so that if it
1435  code. */  becomes variable in the future, we don't have to change that code. */
1436    
1437  if (bits_set || min > 0  if (bits_set || min > 0 || (options & (
1438  #ifdef SUPPORT_JIT  #ifdef SUPPORT_JIT
1439      || (options & PCRE_STUDY_JIT_COMPILE) != 0      PCRE_STUDY_JIT_COMPILE | PCRE_STUDY_JIT_PARTIAL_SOFT_COMPILE |
1440        PCRE_STUDY_JIT_PARTIAL_HARD_COMPILE |
1441  #endif  #endif
1442    )      PCRE_STUDY_EXTRA_NEEDED)) != 0)
1443    {    {
1444    extra = (pcre_extra *)(pcre_malloc)    extra = (PUBL(extra) *)(PUBL(malloc))
1445      (sizeof(pcre_extra) + sizeof(pcre_study_data));      (sizeof(PUBL(extra)) + sizeof(pcre_study_data));
1446    if (extra == NULL)    if (extra == NULL)
1447      {      {
1448      *errorptr = "failed to get memory";      *errorptr = "failed to get memory";
1449      return NULL;      return NULL;
1450      }      }
1451    
1452    study = (pcre_study_data *)((char *)extra + sizeof(pcre_extra));    study = (pcre_study_data *)((char *)extra + sizeof(PUBL(extra)));
1453    extra->flags = PCRE_EXTRA_STUDY_DATA;    extra->flags = PCRE_EXTRA_STUDY_DATA;
1454    extra->study_data = study;    extra->study_data = study;
1455    
1456    study->size = sizeof(pcre_study_data);    study->size = sizeof(pcre_study_data);
1457    study->flags = 0;    study->flags = 0;
1458    
1459      /* Set the start bits always, to avoid unset memory errors if the
1460      study data is written to a file, but set the flag only if any of the bits
1461      are set, to save time looking when none are. */
1462    
1463    if (bits_set)    if (bits_set)
1464      {      {
1465      study->flags |= PCRE_STUDY_MAPPED;      study->flags |= PCRE_STUDY_MAPPED;
1466      memcpy(study->start_bits, start_bits, sizeof(start_bits));      memcpy(study->start_bits, start_bits, sizeof(start_bits));
1467      }      }
1468      else memset(study->start_bits, 0, 32 * sizeof(pcre_uint8));
1469    
1470    #ifdef PCRE_DEBUG
1471      if (bits_set)
1472        {
1473        pcre_uint8 *ptr = start_bits;
1474        int i;
1475    
1476        printf("Start bits:\n");
1477        for (i = 0; i < 32; i++)
1478          printf("%3d: %02x%s", i * 8, *ptr++, ((i + 1) & 0x7) != 0? " " : "\n");
1479        }
1480    #endif
1481    
1482    /* Always set the minlength value in the block, because the JIT compiler    /* Always set the minlength value in the block, because the JIT compiler
1483    makes use of it. However, don't set the bit unless the length is greater than    makes use of it. However, don't set the bit unless the length is greater than
# Line 1342  if (bits_set || min > 0 Line 1493  if (bits_set || min > 0
1493    
1494    /* If JIT support was compiled and requested, attempt the JIT compilation.    /* If JIT support was compiled and requested, attempt the JIT compilation.
1495    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
1496    compilation fails, abandon the extra block and return NULL. */    compilation fails, abandon the extra block and return NULL, unless
1497      PCRE_STUDY_EXTRA_NEEDED is set. */
1498    
1499  #ifdef SUPPORT_JIT  #ifdef SUPPORT_JIT
1500    extra->executable_jit = NULL;    extra->executable_jit = NULL;
1501    if ((options & PCRE_STUDY_JIT_COMPILE) != 0) _pcre_jit_compile(re, extra);    if ((options & PCRE_STUDY_JIT_COMPILE) != 0)
1502    if (study->flags == 0 && (extra->flags & PCRE_EXTRA_EXECUTABLE_JIT) == 0)      PRIV(jit_compile)(re, extra, JIT_COMPILE);
1503      if ((options & PCRE_STUDY_JIT_PARTIAL_SOFT_COMPILE) != 0)
1504        PRIV(jit_compile)(re, extra, JIT_PARTIAL_SOFT_COMPILE);
1505      if ((options & PCRE_STUDY_JIT_PARTIAL_HARD_COMPILE) != 0)
1506        PRIV(jit_compile)(re, extra, JIT_PARTIAL_HARD_COMPILE);
1507    
1508      if (study->flags == 0 && (extra->flags & PCRE_EXTRA_EXECUTABLE_JIT) == 0 &&
1509          (options & PCRE_STUDY_EXTRA_NEEDED) == 0)
1510      {      {
1511    #if defined COMPILE_PCRE8
1512      pcre_free_study(extra);      pcre_free_study(extra);
1513    #elif defined COMPILE_PCRE16
1514        pcre16_free_study(extra);
1515    #elif defined COMPILE_PCRE32
1516        pcre32_free_study(extra);
1517    #endif
1518      extra = NULL;      extra = NULL;
1519      }      }
1520  #endif  #endif
# Line 1365  return extra; Line 1530  return extra;
1530    
1531  /* This function frees the memory that was obtained by pcre_study().  /* This function frees the memory that was obtained by pcre_study().
1532    
1533  Argument:   a pointer to the pcre_extra block  Argument:   a pointer to the pcre[16]_extra block
1534  Returns:    nothing  Returns:    nothing
1535  */  */
1536    
1537    #if defined COMPILE_PCRE8
1538  PCRE_EXP_DEFN void  PCRE_EXP_DEFN void
1539  pcre_free_study(pcre_extra *extra)  pcre_free_study(pcre_extra *extra)
1540    #elif defined COMPILE_PCRE16
1541    PCRE_EXP_DEFN void
1542    pcre16_free_study(pcre16_extra *extra)
1543    #elif defined COMPILE_PCRE32
1544    PCRE_EXP_DEFN void
1545    pcre32_free_study(pcre32_extra *extra)
1546    #endif
1547  {  {
1548    if (extra == NULL)
1549      return;
1550  #ifdef SUPPORT_JIT  #ifdef SUPPORT_JIT
1551  if ((extra->flags & PCRE_EXTRA_EXECUTABLE_JIT) != 0 &&  if ((extra->flags & PCRE_EXTRA_EXECUTABLE_JIT) != 0 &&
1552       extra->executable_jit != NULL)       extra->executable_jit != NULL)
1553    _pcre_jit_free(extra->executable_jit);    PRIV(jit_free)(extra->executable_jit);
1554  #endif  #endif
1555  pcre_free(extra);  PUBL(free)(extra);
1556  }  }
1557    
1558  /* End of pcre_study.c */  /* End of pcre_study.c */

Legend:
Removed from v.835  
changed lines
  Added in v.1084

  ViewVC Help
Powered by ViewVC 1.1.5