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

Diff of /code/branches/pcre16/pcre_exec.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 121  Returns:     nothing Line 121  Returns:     nothing
121  */  */
122    
123  static void  static void
124  pchars(const uschar *p, int length, BOOL is_subject, match_data *md)  pchars(const pcre_uchar *p, int length, BOOL is_subject, match_data *md)
125  {  {
126  unsigned int c;  unsigned int c;
127  if (is_subject && length > md->end_subject - p) length = md->end_subject - p;  if (is_subject && length > md->end_subject - p) length = md->end_subject - p;
# Line 152  Returns:      < 0 if not matched, otherw Line 152  Returns:      < 0 if not matched, otherw
152  */  */
153    
154  static int  static int
155  match_ref(int offset, register USPTR eptr, int length, match_data *md,  match_ref(int offset, register PCRE_PUCHAR eptr, int length, match_data *md,
156    BOOL caseless)    BOOL caseless)
157  {  {
158  USPTR eptr_start = eptr;  PCRE_PUCHAR eptr_start = eptr;
159  register USPTR p = md->start_subject + md->offset_vector[offset];  register PCRE_PUCHAR p = md->start_subject + md->offset_vector[offset];
160    
161  #ifdef PCRE_DEBUG  #ifdef PCRE_DEBUG
162  if (eptr >= md->end_subject)  if (eptr >= md->end_subject)
# Line 193  if (caseless) Line 193  if (caseless)
193      the latter. It is important, therefore, to check the length along the      the latter. It is important, therefore, to check the length along the
194      reference, not along the subject (earlier code did this wrong). */      reference, not along the subject (earlier code did this wrong). */
195    
196      USPTR endptr = p + length;      PCRE_PUCHAR endptr = p + length;
197      while (p < endptr)      while (p < endptr)
198        {        {
199        int c, d;        int c, d;
# Line 354  typedef struct heapframe { Line 354  typedef struct heapframe {
354    
355    /* Function arguments that may change */    /* Function arguments that may change */
356    
357    USPTR Xeptr;    PCRE_PUCHAR Xeptr;
358    const uschar *Xecode;    const pcre_uchar *Xecode;
359    USPTR Xmstart;    PCRE_PUCHAR Xmstart;
360    USPTR Xmarkptr;    PCRE_PUCHAR Xmarkptr;
361    int Xoffset_top;    int Xoffset_top;
362    eptrblock *Xeptrb;    eptrblock *Xeptrb;
363    unsigned int Xrdepth;    unsigned int Xrdepth;
364    
365    /* Function local variables */    /* Function local variables */
366    
367    USPTR Xcallpat;    PCRE_PUCHAR Xcallpat;
368  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
369    USPTR Xcharptr;    PCRE_PUCHAR Xcharptr;
370  #endif  #endif
371    USPTR Xdata;    PCRE_PUCHAR Xdata;
372    USPTR Xnext;    PCRE_PUCHAR Xnext;
373    USPTR Xpp;    PCRE_PUCHAR Xpp;
374    USPTR Xprev;    PCRE_PUCHAR Xprev;
375    USPTR Xsaved_eptr;    PCRE_PUCHAR Xsaved_eptr;
376    
377    recursion_info Xnew_recursive;    recursion_info Xnew_recursive;
378    
# Line 385  typedef struct heapframe { Line 385  typedef struct heapframe {
385    int Xprop_value;    int Xprop_value;
386    int Xprop_fail_result;    int Xprop_fail_result;
387    int Xoclength;    int Xoclength;
388    uschar Xocchars[8];    pcre_uint8 Xocchars[8];
389  #endif  #endif
390    
391    int Xcodelink;    int Xcodelink;
# Line 474  Returns:       MATCH_MATCH if matched Line 474  Returns:       MATCH_MATCH if matched
474  */  */
475    
476  static int  static int
477  match(REGISTER USPTR eptr, REGISTER const uschar *ecode, USPTR mstart,  match(REGISTER PCRE_PUCHAR eptr, REGISTER const pcre_uchar *ecode,
478    const uschar *markptr, int offset_top, match_data *md, eptrblock *eptrb,    PCRE_PUCHAR mstart, const pcre_uchar *markptr, int offset_top,
479    unsigned int rdepth)    match_data *md, eptrblock *eptrb, unsigned int rdepth)
480  {  {
481  /* These variables do not need to be preserved over recursion in this function,  /* These variables do not need to be preserved over recursion in this function,
482  so they can be ordinary variables in all cases. Mark some of them with  so they can be ordinary variables in all cases. Mark some of them with
# Line 586  below are for variables that do not have Line 586  below are for variables that do not have
586  to RMATCH(). */  to RMATCH(). */
587    
588  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
589  const uschar *charptr;  const pcre_uchar *charptr;
590  #endif  #endif
591  const uschar *callpat;  const pcre_uchar *callpat;
592  const uschar *data;  const pcre_uchar *data;
593  const uschar *next;  const pcre_uchar *next;
594  USPTR         pp;  PCRE_PUCHAR       pp;
595  const uschar *prev;  const pcre_uchar *prev;
596  USPTR         saved_eptr;  PCRE_PUCHAR       saved_eptr;
597    
598  recursion_info new_recursive;  recursion_info new_recursive;
599    
# Line 606  int prop_type; Line 606  int prop_type;
606  int prop_value;  int prop_value;
607  int prop_fail_result;  int prop_fail_result;
608  int oclength;  int oclength;
609  uschar occhars[8];  pcre_uint8 occhars[8];
610  #endif  #endif
611    
612  int codelink;  int codelink;
# Line 1028  for (;;) Line 1028  for (;;)
1028          {          {
1029          if (rrc == MATCH_ONCE)          if (rrc == MATCH_ONCE)
1030            {            {
1031            const uschar *scode = ecode;            const pcre_uchar *scode = ecode;
1032            if (*scode != OP_ONCE)           /* If not at start, find it */            if (*scode != OP_ONCE)           /* If not at start, find it */
1033              {              {
1034              while (*scode == OP_ALT) scode += GET(scode, 1);              while (*scode == OP_ALT) scode += GET(scode, 1);
# Line 1262  for (;;) Line 1262  for (;;)
1262    
1263          if (!condition && condcode == OP_NRREF)          if (!condition && condcode == OP_NRREF)
1264            {            {
1265            uschar *slotA = md->name_table;            pcre_uchar *slotA = md->name_table;
1266            for (i = 0; i < md->name_count; i++)            for (i = 0; i < md->name_count; i++)
1267              {              {
1268              if (GET2(slotA, 0) == recno) break;              if (GET2(slotA, 0) == recno) break;
# Line 1275  for (;;) Line 1275  for (;;)
1275    
1276            if (i < md->name_count)            if (i < md->name_count)
1277              {              {
1278              uschar *slotB = slotA;              pcre_uchar *slotB = slotA;
1279              while (slotB > md->name_table)              while (slotB > md->name_table)
1280                {                {
1281                slotB -= md->name_entry_size;                slotB -= md->name_entry_size;
# Line 1325  for (;;) Line 1325  for (;;)
1325        if (!condition && condcode == OP_NCREF)        if (!condition && condcode == OP_NCREF)
1326          {          {
1327          int refno = offset >> 1;          int refno = offset >> 1;
1328          uschar *slotA = md->name_table;          pcre_uchar *slotA = md->name_table;
1329    
1330          for (i = 0; i < md->name_count; i++)          for (i = 0; i < md->name_count; i++)
1331            {            {
# Line 1339  for (;;) Line 1339  for (;;)
1339    
1340          if (i < md->name_count)          if (i < md->name_count)
1341            {            {
1342            uschar *slotB = slotA;            pcre_uchar *slotB = slotA;
1343            while (slotB > md->name_table)            while (slotB > md->name_table)
1344              {              {
1345              slotB -= md->name_entry_size;              slotB -= md->name_entry_size;
# Line 2076  for (;;) Line 2076  for (;;)
2076    
2077          if (eptr == md->start_subject) prev_is_word = FALSE; else          if (eptr == md->start_subject) prev_is_word = FALSE; else
2078            {            {
2079            USPTR lastptr = eptr - 1;            PCRE_PUCHAR lastptr = eptr - 1;
2080            while((*lastptr & 0xc0) == 0x80) lastptr--;            while((*lastptr & 0xc0) == 0x80) lastptr--;
2081            if (lastptr < md->start_used_ptr) md->start_used_ptr = lastptr;            if (lastptr < md->start_used_ptr) md->start_used_ptr = lastptr;
2082            GETCHAR(c, lastptr);            GETCHAR(c, lastptr);
# Line 5945  BOOL req_byte_caseless = FALSE; Line 5945  BOOL req_byte_caseless = FALSE;
5945  BOOL utf8;  BOOL utf8;
5946  match_data match_block;  match_data match_block;
5947  match_data *md = &match_block;  match_data *md = &match_block;
5948  const uschar *tables;  const pcre_uint8 *tables;
5949  const uschar *start_bits = NULL;  const pcre_uint8 *start_bits = NULL;
5950  USPTR start_match = (USPTR)subject + start_offset;  PCRE_PUCHAR start_match = (PCRE_PUCHAR)subject + start_offset;
5951  USPTR end_subject;  PCRE_PUCHAR end_subject;
5952  USPTR start_partial = NULL;  PCRE_PUCHAR start_partial = NULL;
5953  USPTR req_byte_ptr = start_match - 1;  PCRE_PUCHAR req_byte_ptr = start_match - 1;
5954    
5955  pcre_study_data internal_study;  pcre_study_data internal_study;
5956  const pcre_study_data *study;  const pcre_study_data *study;
# Line 5983  code for an invalid string if a results Line 5983  code for an invalid string if a results
5983  if (utf8 && (options & PCRE_NO_UTF8_CHECK) == 0)  if (utf8 && (options & PCRE_NO_UTF8_CHECK) == 0)
5984    {    {
5985    int erroroffset;    int erroroffset;
5986    int errorcode = _pcre_valid_utf8((USPTR)subject, length, &erroroffset);    int errorcode = _pcre_valid_utf8((PCRE_PUCHAR)subject, length, &erroroffset);
5987    if (errorcode != 0)    if (errorcode != 0)
5988      {      {
5989      if (offsetcount >= 2)      if (offsetcount >= 2)
# Line 5997  if (utf8 && (options & PCRE_NO_UTF8_CHEC Line 5997  if (utf8 && (options & PCRE_NO_UTF8_CHEC
5997    
5998    /* Check that a start_offset points to the start of a UTF-8 character. */    /* Check that a start_offset points to the start of a UTF-8 character. */
5999    if (start_offset > 0 && start_offset < length &&    if (start_offset > 0 && start_offset < length &&
6000        (((USPTR)subject)[start_offset] & 0xc0) == 0x80)        (((PCRE_PUCHAR)subject)[start_offset] & 0xc0) == 0x80)
6001      return PCRE_ERROR_BADUTF8_OFFSET;      return PCRE_ERROR_BADUTF8_OFFSET;
6002    }    }
6003  #endif  #endif
# Line 6023  if (extra_data != NULL Line 6023  if (extra_data != NULL
6023  /* Carry on with non-JIT matching. This information is for finding all the  /* Carry on with non-JIT matching. This information is for finding all the
6024  numbers associated with a given name, for condition testing. */  numbers associated with a given name, for condition testing. */
6025    
6026  md->name_table = (uschar *)re + re->name_table_offset;  md->name_table = (pcre_uchar *)re + re->name_table_offset;
6027  md->name_count = re->name_count;  md->name_count = re->name_count;
6028  md->name_entry_size = re->name_entry_size;  md->name_entry_size = re->name_entry_size;
6029    
# Line 6079  firstline = (re->options & PCRE_FIRSTLIN Line 6079  firstline = (re->options & PCRE_FIRSTLIN
6079    
6080  /* The code starts after the real_pcre block and the capture name table. */  /* The code starts after the real_pcre block and the capture name table. */
6081    
6082  md->start_code = (const uschar *)external_re + re->name_table_offset +  md->start_code = (const pcre_uchar *)external_re + re->name_table_offset +
6083    re->name_count * re->name_entry_size;    re->name_count * re->name_entry_size;
6084    
6085  md->start_subject = (USPTR)subject;  md->start_subject = (PCRE_PUCHAR)subject;
6086  md->start_offset = start_offset;  md->start_offset = start_offset;
6087  md->end_subject = md->start_subject + length;  md->end_subject = md->start_subject + length;
6088  end_subject = md->end_subject;  end_subject = md->end_subject;
# Line 6259  the loop runs just once. */ Line 6259  the loop runs just once. */
6259    
6260  for(;;)  for(;;)
6261    {    {
6262    USPTR save_end_subject = end_subject;    PCRE_PUCHAR save_end_subject = end_subject;
6263    USPTR new_start_match;    PCRE_PUCHAR new_start_match;
6264    
6265    /* If firstline is TRUE, the start of the match is constrained to the first    /* If firstline is TRUE, the start of the match is constrained to the first
6266    line of a multiline string. That is, the match must be before or at the first    line of a multiline string. That is, the match must be before or at the first
# Line 6270  for(;;) Line 6270  for(;;)
6270    
6271    if (firstline)    if (firstline)
6272      {      {
6273      USPTR t = start_match;      PCRE_PUCHAR t = start_match;
6274  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
6275      if (utf8)      if (utf8)
6276        {        {
# Line 6397  for(;;) Line 6397  for(;;)
6397    
6398      if (req_byte >= 0 && end_subject - start_match < REQ_BYTE_MAX)      if (req_byte >= 0 && end_subject - start_match < REQ_BYTE_MAX)
6399        {        {
6400        register USPTR p = start_match + ((first_byte >= 0)? 1 : 0);        register PCRE_PUCHAR p = start_match + ((first_byte >= 0)? 1 : 0);
6401    
6402        /* We don't need to repeat the search if we haven't yet reached the        /* We don't need to repeat the search if we haven't yet reached the
6403        place we found it at last time. */        place we found it at last time. */
# Line 6637  if (start_partial != NULL) Line 6637  if (start_partial != NULL)
6637    md->mark = NULL;    md->mark = NULL;
6638    if (offsetcount > 1)    if (offsetcount > 1)
6639      {      {
6640      offsets[0] = (int)(start_partial - (USPTR)subject);      offsets[0] = (int)(start_partial - (PCRE_PUCHAR)subject);
6641      offsets[1] = (int)(end_subject - (USPTR)subject);      offsets[1] = (int)(end_subject - (PCRE_PUCHAR)subject);
6642      }      }
6643    rc = PCRE_ERROR_PARTIAL;    rc = PCRE_ERROR_PARTIAL;
6644    }    }

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

  ViewVC Help
Powered by ViewVC 1.1.5