/[pcre]/code/tags/pcre-2.00/pcre.c
ViewVC logotype

Diff of /code/tags/pcre-2.00/pcre.c

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

revision 13 by nigel, Sat Feb 24 21:38:21 2007 UTC revision 19 by nigel, Sat Feb 24 21:38:33 2007 UTC
# Line 9  the file Tech.Notes for some information Line 9  the file Tech.Notes for some information
9    
10  Written by: Philip Hazel <ph10@cam.ac.uk>  Written by: Philip Hazel <ph10@cam.ac.uk>
11    
12             Copyright (c) 1997 University of Cambridge             Copyright (c) 1998 University of Cambridge
13    
14  -----------------------------------------------------------------------------  -----------------------------------------------------------------------------
15  Permission is granted to anyone to use this software for any purpose on any  Permission is granted to anyone to use this software for any purpose on any
# Line 49  the external pcre header. */ Line 49  the external pcre header. */
49  #include "internal.h"  #include "internal.h"
50    
51    
52    /* Allow compilation as C++ source code, should anybody want to do that. */
53    
54    #ifdef __cplusplus
55    #define class pcre_class
56    #endif
57    
58    
59  /* Min and max values for the common repeats; for the maxima, 0 => infinity */  /* Min and max values for the common repeats; for the maxima, 0 => infinity */
60    
61  static char rep_min[] = { 0, 0, 1, 1, 0, 0 };  static const char rep_min[] = { 0, 0, 1, 1, 0, 0 };
62  static char rep_max[] = { 0, 0, 0, 0, 1, 1 };  static const char rep_max[] = { 0, 0, 0, 0, 1, 1 };
63    
64  /* Text forms of OP_ values and things, for debugging (not all used) */  /* Text forms of OP_ values and things, for debugging (not all used) */
65    
# Line 76  are simple data values; negative values Line 83  are simple data values; negative values
83  on. Zero means further processing is needed (for things like \x), or the escape  on. Zero means further processing is needed (for things like \x), or the escape
84  is invalid. */  is invalid. */
85    
86  static short int escapes[] = {  static const short int escapes[] = {
87      0,      0,      0,      0,      0,      0,      0,      0,   /* 0 - 7 */      0,      0,      0,      0,      0,      0,      0,      0,   /* 0 - 7 */
88      0,      0,    ':',    ';',    '<',    '=',    '>',    '?',   /* 8 - ? */      0,      0,    ':',    ';',    '<',    '=',    '>',    '?',   /* 8 - ? */
89    '@', -ESC_A, -ESC_B,      0, -ESC_D,      0,      0,      0,   /* @ - G */    '@', -ESC_A, -ESC_B,      0, -ESC_D,      0,      0,      0,   /* @ - G */
# Line 257  do { Line 264  do {
264        case OP_KETRMIN:        case OP_KETRMIN:
265        return TRUE;        return TRUE;
266    
267          /* Skip over entire bracket groups with zero lower bound */
268    
269          case OP_BRAZERO:
270          case OP_BRAMINZERO:
271          cc++;
272          /* Fall through */
273    
274        /* Skip over assertive subpatterns */        /* Skip over assertive subpatterns */
275    
276        case OP_ASSERT:        case OP_ASSERT:
# Line 271  do { Line 285  do {
285        case OP_EOD:        case OP_EOD:
286        case OP_CIRC:        case OP_CIRC:
287        case OP_DOLL:        case OP_DOLL:
       case OP_BRAZERO:  
       case OP_BRAMINZERO:  
288        case OP_NOT_WORD_BOUNDARY:        case OP_NOT_WORD_BOUNDARY:
289        case OP_WORD_BOUNDARY:        case OP_WORD_BOUNDARY:
290        cc++;        cc++;
# Line 611  compile_branch(int options, int *bracket Line 623  compile_branch(int options, int *bracket
623  int repeat_type, op_type;  int repeat_type, op_type;
624  int repeat_min, repeat_max;  int repeat_min, repeat_max;
625  int bravalue, length;  int bravalue, length;
626    int greedy_default, greedy_non_default;
627  register int c;  register int c;
628  register uschar *code = *codeptr;  register uschar *code = *codeptr;
629  const uschar *ptr = *ptrptr;  const uschar *ptr = *ptrptr;
# Line 618  const uschar *oldptr; Line 631  const uschar *oldptr;
631  uschar *previous = NULL;  uschar *previous = NULL;
632  uschar class[32];  uschar class[32];
633    
634    /* Set up the default and non-default settings for greediness */
635    
636    greedy_default = ((options & PCRE_UNGREEDY) != 0);
637    greedy_non_default = greedy_default ^ 1;
638    
639  /* Switch on next character until the end of the branch */  /* Switch on next character until the end of the branch */
640    
641  for (;; ptr++)  for (;; ptr++)
# Line 895  for (;; ptr++) Line 913  for (;; ptr++)
913        goto FAILED;        goto FAILED;
914        }        }
915    
916      /* If the next character is '?' this is a minimizing repeat. Advance to the      /* If the next character is '?' this is a minimizing repeat, by default,
917        but if PCRE_UNGREEDY is set, it works the other way round. Advance to the
918      next character. */      next character. */
919    
920      if (ptr[1] == '?') { repeat_type = 1; ptr++; } else repeat_type = 0;      if (ptr[1] == '?')
921          { repeat_type = greedy_non_default; ptr++; }
922        else repeat_type = greedy_default;
923    
924      /* If the maximum is zero then the minimum must also be zero; Perl allows      /* If the maximum is zero then the minimum must also be zero; Perl allows
925      this case, so we do too - by simply omitting the item altogether. */      this case, so we do too - by simply omitting the item altogether. */
# Line 1137  for (;; ptr++) Line 1158  for (;; ptr++)
1158          case 'm':          case 'm':
1159          case 's':          case 's':
1160          case 'x':          case 'x':
1161            case 'U':
1162            case 'X':
1163          ptr++;          ptr++;
1164          while (*ptr != ')') ptr++;          while (*ptr != ')') ptr++;
1165          previous = NULL;          previous = NULL;
# Line 1296  for (;; ptr++) Line 1319  for (;; ptr++)
1319      the next state. */      the next state. */
1320    
1321      previous[1] = length;      previous[1] = length;
1322      ptr--;      if (length < 255) ptr--;
1323      break;      break;
1324      }      }
1325    }                   /* end of big loop */    }                   /* end of big loop */
# Line 1740  while ((c = *(++ptr)) != 0) Line 1763  while ((c = *(++ptr)) != 0)
1763          ptr += 2;          ptr += 2;
1764          break;          break;
1765          }          }
1766        /* Else fall thourh */        /* Else fall through */
1767    
1768        /* Else loop setting valid options until ) is met. Anything else is an        /* Else loop setting valid options until ) is met. Anything else is an
1769        error. */        error. */
# Line 1770  while ((c = *(++ptr)) != 0) Line 1793  while ((c = *(++ptr)) != 0)
1793            length -= spaces;          /* Already counted spaces */            length -= spaces;          /* Already counted spaces */
1794            continue;            continue;
1795            }            }
1796            else if (c == 'X')
1797              {
1798              options |= PCRE_EXTRA;
1799              continue;
1800              }
1801            else if (c == 'U')
1802              {
1803              options |= PCRE_UNGREEDY;
1804              continue;
1805              }
1806          else if (c == ')') break;          else if (c == ')') break;
1807    
1808          *errorptr = ERR12;          *errorptr = ERR12;
# Line 1975  printf("Length = %d top_bracket = %d top Line 2008  printf("Length = %d top_bracket = %d top
2008    
2009  if (re->options != 0)  if (re->options != 0)
2010    {    {
2011    printf("%s%s%s%s%s%s%s\n",    printf("%s%s%s%s%s%s%s%s\n",
2012      ((re->options & PCRE_ANCHORED) != 0)? "anchored " : "",      ((re->options & PCRE_ANCHORED) != 0)? "anchored " : "",
2013      ((re->options & PCRE_CASELESS) != 0)? "caseless " : "",      ((re->options & PCRE_CASELESS) != 0)? "caseless " : "",
2014      ((re->options & PCRE_EXTENDED) != 0)? "extended " : "",      ((re->options & PCRE_EXTENDED) != 0)? "extended " : "",
2015      ((re->options & PCRE_MULTILINE) != 0)? "multiline " : "",      ((re->options & PCRE_MULTILINE) != 0)? "multiline " : "",
2016      ((re->options & PCRE_DOTALL) != 0)? "dotall " : "",      ((re->options & PCRE_DOTALL) != 0)? "dotall " : "",
2017      ((re->options & PCRE_DOLLAR_ENDONLY) != 0)? "endonly " : "",      ((re->options & PCRE_DOLLAR_ENDONLY) != 0)? "endonly " : "",
2018      ((re->options & PCRE_EXTRA) != 0)? "extra " : "");      ((re->options & PCRE_EXTRA) != 0)? "extra " : "",
2019        ((re->options & PCRE_UNGREEDY) != 0)? "ungreedy " : "");
2020    }    }
2021    
2022  if ((re->options & PCRE_FIRSTSET) != 0)  if ((re->options & PCRE_FIRSTSET) != 0)
# Line 3450  ocount = offsetcount & (-2); Line 3484  ocount = offsetcount & (-2);
3484  if (re->top_backref > 0 && re->top_backref >= ocount/2)  if (re->top_backref > 0 && re->top_backref >= ocount/2)
3485    {    {
3486    ocount = re->top_backref * 2 + 2;    ocount = re->top_backref * 2 + 2;
3487    match_block.offset_vector = (pcre_malloc)(ocount * sizeof(int));    match_block.offset_vector = (int *)(pcre_malloc)(ocount * sizeof(int));
3488    if (match_block.offset_vector == NULL) return PCRE_ERROR_NOMEMORY;    if (match_block.offset_vector == NULL) return PCRE_ERROR_NOMEMORY;
3489    using_temporary_offsets = TRUE;    using_temporary_offsets = TRUE;
3490    DPRINTF(("Got memory to hold back references\n"));    DPRINTF(("Got memory to hold back references\n"));

Legend:
Removed from v.13  
changed lines
  Added in v.19

  ViewVC Help
Powered by ViewVC 1.1.5