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

Diff of /code/trunk/pcre_exec.c

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

revision 473 by ph10, Sat Jan 2 12:40:07 2010 UTC revision 500 by ph10, Sat Mar 6 19:00:29 2010 UTC
# Line 89  static const char rep_max[] = { 0, 0, 0, Line 89  static const char rep_max[] = { 0, 0, 0,
89    
90    
91    
92  #ifdef DEBUG  #ifdef PCRE_DEBUG
93  /*************************************************  /*************************************************
94  *        Debugging function to print chars       *  *        Debugging function to print chars       *
95  *************************************************/  *************************************************/
# Line 141  match_ref(int offset, register USPTR ept Line 141  match_ref(int offset, register USPTR ept
141  {  {
142  USPTR p = md->start_subject + md->offset_vector[offset];  USPTR p = md->start_subject + md->offset_vector[offset];
143    
144  #ifdef DEBUG  #ifdef PCRE_DEBUG
145  if (eptr >= md->end_subject)  if (eptr >= md->end_subject)
146    printf("matching subject <null>");    printf("matching subject <null>");
147  else  else
# Line 254  actuall used in this definition. */ Line 254  actuall used in this definition. */
254  #ifndef NO_RECURSE  #ifndef NO_RECURSE
255  #define REGISTER register  #define REGISTER register
256    
257  #ifdef DEBUG  #ifdef PCRE_DEBUG
258  #define RMATCH(ra,rb,rc,rd,re,rf,rg,rw) \  #define RMATCH(ra,rb,rc,rd,re,rf,rg,rw) \
259    { \    { \
260    printf("match() called in line %d\n", __LINE__); \    printf("match() called in line %d\n", __LINE__); \
# Line 622  TAIL_RECURSE: Line 622  TAIL_RECURSE:
622  /* OK, now we can get on with the real code of the function. Recursive calls  /* OK, now we can get on with the real code of the function. Recursive calls
623  are specified by the macro RMATCH and RRETURN is used to return. When  are specified by the macro RMATCH and RRETURN is used to return. When
624  NO_RECURSE is *not* defined, these just turn into a recursive call to match()  NO_RECURSE is *not* defined, these just turn into a recursive call to match()
625  and a "return", respectively (possibly with some debugging if DEBUG is  and a "return", respectively (possibly with some debugging if PCRE_DEBUG is
626  defined). However, RMATCH isn't like a function call because it's quite a  defined). However, RMATCH isn't like a function call because it's quite a
627  complicated macro. It has to be used in one particular way. This shouldn't,  complicated macro. It has to be used in one particular way. This shouldn't,
628  however, impact performance when true recursion is being used. */  however, impact performance when true recursion is being used. */
# Line 713  for (;;) Line 713  for (;;)
713      number = GET2(ecode, 1+LINK_SIZE);      number = GET2(ecode, 1+LINK_SIZE);
714      offset = number << 1;      offset = number << 1;
715    
716  #ifdef DEBUG  #ifdef PCRE_DEBUG
717      printf("start bracket %d\n", number);      printf("start bracket %d\n", number);
718      printf("subject=");      printf("subject=");
719      pchars(eptr, 16, TRUE, md);      pchars(eptr, 16, TRUE, md);
# Line 1039  for (;;) Line 1039  for (;;)
1039      number = GET2(ecode, 1);      number = GET2(ecode, 1);
1040      offset = number << 1;      offset = number << 1;
1041    
1042  #ifdef DEBUG  #ifdef PCRE_DEBUG
1043        printf("end bracket %d at *ACCEPT", number);        printf("end bracket %d at *ACCEPT", number);
1044        printf("\n");        printf("\n");
1045  #endif  #endif
# Line 1070  for (;;) Line 1070  for (;;)
1070        memmove(md->offset_vector, rec->offset_save,        memmove(md->offset_vector, rec->offset_save,
1071          rec->saved_max * sizeof(int));          rec->saved_max * sizeof(int));
1072        offset_top = rec->save_offset_top;        offset_top = rec->save_offset_top;
       mstart = rec->save_start;  
1073        ims = original_ims;        ims = original_ims;
1074        ecode = rec->after_call;        ecode = rec->after_call;
1075        break;        break;
# Line 1114  for (;;) Line 1113  for (;;)
1113        {        {
1114        RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, NULL, 0,        RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, NULL, 0,
1115          RM4);          RM4);
1116        if (rrc == MATCH_MATCH) break;        if (rrc == MATCH_MATCH)
1117            {
1118            mstart = md->start_match_ptr;   /* In case \K reset it */
1119            break;
1120            }
1121        if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc);        if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc);
1122        ecode += GET(ecode, 1);        ecode += GET(ecode, 1);
1123        }        }
# Line 1134  for (;;) Line 1137  for (;;)
1137      continue;      continue;
1138    
1139      /* Negative assertion: all branches must fail to match. Encountering SKIP,      /* Negative assertion: all branches must fail to match. Encountering SKIP,
1140      PRUNE, or COMMIT means we must assume failure without checking subsequent      PRUNE, or COMMIT means we must assume failure without checking subsequent
1141      branches. */      branches. */
1142    
1143      case OP_ASSERT_NOT:      case OP_ASSERT_NOT:
# Line 1147  for (;;) Line 1150  for (;;)
1150        if (rrc == MATCH_SKIP || rrc == MATCH_PRUNE || rrc == MATCH_COMMIT)        if (rrc == MATCH_SKIP || rrc == MATCH_PRUNE || rrc == MATCH_COMMIT)
1151          {          {
1152          do ecode += GET(ecode,1); while (*ecode == OP_ALT);          do ecode += GET(ecode,1); while (*ecode == OP_ALT);
1153          break;          break;
1154          }          }
1155        if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc);        if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc);
1156        ecode += GET(ecode,1);        ecode += GET(ecode,1);
1157        }        }
# Line 1267  for (;;) Line 1270  for (;;)
1270    
1271        memcpy(new_recursive.offset_save, md->offset_vector,        memcpy(new_recursive.offset_save, md->offset_vector,
1272              new_recursive.saved_max * sizeof(int));              new_recursive.saved_max * sizeof(int));
       new_recursive.save_start = mstart;  
1273        new_recursive.save_offset_top = offset_top;        new_recursive.save_offset_top = offset_top;
       mstart = eptr;  
1274    
1275        /* OK, now we can do the recursion. For each top-level alternative we        /* OK, now we can do the recursion. For each top-level alternative we
1276        restore the offset and recursion data. */        restore the offset and recursion data. */
# Line 1316  for (;;) Line 1317  for (;;)
1317      a move back into the brackets. Friedl calls these "atomic" subpatterns.      a move back into the brackets. Friedl calls these "atomic" subpatterns.
1318      Check the alternative branches in turn - the matching won't pass the KET      Check the alternative branches in turn - the matching won't pass the KET
1319      for this kind of subpattern. If any one branch matches, we carry on as at      for this kind of subpattern. If any one branch matches, we carry on as at
1320      the end of a normal bracket, leaving the subject pointer. */      the end of a normal bracket, leaving the subject pointer, but resetting
1321        the start-of-match value in case it was changed by \K. */
1322    
1323      case OP_ONCE:      case OP_ONCE:
1324      prev = ecode;      prev = ecode;
# Line 1325  for (;;) Line 1327  for (;;)
1327      do      do
1328        {        {
1329        RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, eptrb, 0, RM7);        RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, eptrb, 0, RM7);
1330        if (rrc == MATCH_MATCH) break;        if (rrc == MATCH_MATCH)
1331            {
1332            mstart = md->start_match_ptr;
1333            break;
1334            }
1335        if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc);        if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc);
1336        ecode += GET(ecode,1);        ecode += GET(ecode,1);
1337        }        }
# Line 1444  for (;;) Line 1450  for (;;)
1450        }        }
1451      else saved_eptr = NULL;      else saved_eptr = NULL;
1452    
1453      /* If we are at the end of an assertion group, stop matching and return      /* If we are at the end of an assertion group or an atomic group, stop
1454      MATCH_MATCH, but record the current high water mark for use by positive      matching and return MATCH_MATCH, but record the current high water mark for
1455      assertions. Do this also for the "once" (atomic) groups. */      use by positive assertions. We also need to record the match start in case
1456        it was changed by \K. */
1457    
1458      if (*prev == OP_ASSERT || *prev == OP_ASSERT_NOT ||      if (*prev == OP_ASSERT || *prev == OP_ASSERT_NOT ||
1459          *prev == OP_ASSERTBACK || *prev == OP_ASSERTBACK_NOT ||          *prev == OP_ASSERTBACK || *prev == OP_ASSERTBACK_NOT ||
# Line 1454  for (;;) Line 1461  for (;;)
1461        {        {
1462        md->end_match_ptr = eptr;      /* For ONCE */        md->end_match_ptr = eptr;      /* For ONCE */
1463        md->end_offset_top = offset_top;        md->end_offset_top = offset_top;
1464          md->start_match_ptr = mstart;
1465        RRETURN(MATCH_MATCH);        RRETURN(MATCH_MATCH);
1466        }        }
1467    
# Line 1468  for (;;) Line 1476  for (;;)
1476        number = GET2(prev, 1+LINK_SIZE);        number = GET2(prev, 1+LINK_SIZE);
1477        offset = number << 1;        offset = number << 1;
1478    
1479  #ifdef DEBUG  #ifdef PCRE_DEBUG
1480        printf("end bracket %d", number);        printf("end bracket %d", number);
1481        printf("\n");        printf("\n");
1482  #endif  #endif
# Line 1490  for (;;) Line 1498  for (;;)
1498          recursion_info *rec = md->recursive;          recursion_info *rec = md->recursive;
1499          DPRINTF(("Recursion (%d) succeeded - continuing\n", number));          DPRINTF(("Recursion (%d) succeeded - continuing\n", number));
1500          md->recursive = rec->prevrec;          md->recursive = rec->prevrec;
         mstart = rec->save_start;  
1501          memcpy(md->offset_vector, rec->offset_save,          memcpy(md->offset_vector, rec->offset_save,
1502            rec->saved_max * sizeof(int));            rec->saved_max * sizeof(int));
1503          offset_top = rec->save_offset_top;          offset_top = rec->save_offset_top;
# Line 3695  for (;;) Line 3702  for (;;)
3702          case OP_NOT_WORDCHAR:          case OP_NOT_WORDCHAR:
3703          for (i = 1; i <= min; i++)          for (i = 1; i <= min; i++)
3704            {            {
3705            if (eptr >= md->end_subject ||            if (eptr >= md->end_subject)
3706               (*eptr < 128 && (md->ctypes[*eptr] & ctype_word) != 0))              {
3707                SCHECK_PARTIAL();
3708                RRETURN(MATCH_NOMATCH);
3709                }
3710              if (*eptr < 128 && (md->ctypes[*eptr] & ctype_word) != 0)
3711              RRETURN(MATCH_NOMATCH);              RRETURN(MATCH_NOMATCH);
3712            while (++eptr < md->end_subject && (*eptr & 0xc0) == 0x80);            while (++eptr < md->end_subject && (*eptr & 0xc0) == 0x80);
3713            }            }
# Line 5572  for(;;) Line 5583  for(;;)
5583      bytes to avoid spending too much time in this optimization. */      bytes to avoid spending too much time in this optimization. */
5584    
5585      if (study != NULL && (study->flags & PCRE_STUDY_MINLEN) != 0 &&      if (study != NULL && (study->flags & PCRE_STUDY_MINLEN) != 0 &&
5586          end_subject - start_match < study->minlength)          (pcre_uint32)(end_subject - start_match) < study->minlength)
5587        {        {
5588        rc = MATCH_NOMATCH;        rc = MATCH_NOMATCH;
5589        break;        break;
# Line 5635  for(;;) Line 5646  for(;;)
5646        }        }
5647      }      }
5648    
5649  #ifdef DEBUG  /* Sigh. Some compilers never learn. */  #ifdef PCRE_DEBUG  /* Sigh. Some compilers never learn. */
5650    printf(">>>> Match against: ");    printf(">>>> Match against: ");
5651    pchars(start_match, end_subject - start_match, TRUE, md);    pchars(start_match, end_subject - start_match, TRUE, md);
5652    printf("\n");    printf("\n");

Legend:
Removed from v.473  
changed lines
  Added in v.500

  ViewVC Help
Powered by ViewVC 1.1.5