/[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 531 by ph10, Tue Jun 1 13:53:26 2010 UTC revision 550 by ph10, Sun Oct 10 16:24:11 2010 UTC
# Line 295  argument of match(), which never changes Line 295  argument of match(), which never changes
295  #define RMATCH(ra,rb,rc,rd,re,rf,rg,rw)\  #define RMATCH(ra,rb,rc,rd,re,rf,rg,rw)\
296    {\    {\
297    heapframe *newframe = (pcre_stack_malloc)(sizeof(heapframe));\    heapframe *newframe = (pcre_stack_malloc)(sizeof(heapframe));\
298    if (heapframe == NULL) RRETURN(PCRE_ERROR_NOMEMORY);\    if (newframe == NULL) RRETURN(PCRE_ERROR_NOMEMORY);\
299    frame->Xwhere = rw; \    frame->Xwhere = rw; \
300    newframe->Xeptr = ra;\    newframe->Xeptr = ra;\
301    newframe->Xecode = rb;\    newframe->Xecode = rb;\
# Line 748  for (;;) Line 748  for (;;)
748    
749      md->start_match_ptr = ecode + 2;      md->start_match_ptr = ecode + 2;
750      RRETURN(MATCH_SKIP_ARG);      RRETURN(MATCH_SKIP_ARG);
751    
752        /* For THEN (and THEN_ARG) we pass back the address of the bracket or
753        the alt that is at the start of the current branch. This makes it possible
754        to skip back past alternatives that precede the THEN within the current
755        branch. */
756    
757      case OP_THEN:      case OP_THEN:
758      RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md,      RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md,
759        ims, eptrb, flags, RM54);        ims, eptrb, flags, RM54);
760      if (rrc != MATCH_NOMATCH) RRETURN(rrc);      if (rrc != MATCH_NOMATCH) RRETURN(rrc);
761        md->start_match_ptr = ecode - GET(ecode, 1);
762      MRRETURN(MATCH_THEN);      MRRETURN(MATCH_THEN);
763    
764      case OP_THEN_ARG:      case OP_THEN_ARG:
765      RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode] + ecode[1], offset_top, md,      RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode] + ecode[1+LINK_SIZE],
766        ims, eptrb, flags, RM58);        offset_top, md, ims, eptrb, flags, RM58);
767      if (rrc != MATCH_NOMATCH) RRETURN(rrc);      if (rrc != MATCH_NOMATCH) RRETURN(rrc);
768      md->mark = ecode + 2;      md->start_match_ptr = ecode - GET(ecode, 1);
769        md->mark = ecode + LINK_SIZE + 2;
770      RRETURN(MATCH_THEN);      RRETURN(MATCH_THEN);
771    
772      /* Handle a capturing bracket. If there is space in the offset vector, save      /* Handle a capturing bracket. If there is space in the offset vector, save
# Line 804  for (;;) Line 811  for (;;)
811          {          {
812          RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md,          RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md,
813            ims, eptrb, flags, RM1);            ims, eptrb, flags, RM1);
814          if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc);          if (rrc != MATCH_NOMATCH &&
815                (rrc != MATCH_THEN || md->start_match_ptr != ecode))
816              RRETURN(rrc);
817          md->capture_last = save_capture_last;          md->capture_last = save_capture_last;
818          ecode += GET(ecode, 1);          ecode += GET(ecode, 1);
819          }          }
# Line 865  for (;;) Line 874  for (;;)
874    
875        RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, ims,        RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, ims,
876          eptrb, flags, RM2);          eptrb, flags, RM2);
877        if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc);        if (rrc != MATCH_NOMATCH &&
878              (rrc != MATCH_THEN || md->start_match_ptr != ecode))
879            RRETURN(rrc);
880        ecode += GET(ecode, 1);        ecode += GET(ecode, 1);
881        }        }
882      /* Control never reaches here. */      /* Control never reaches here. */
# Line 1066  for (;;) Line 1077  for (;;)
1077          ecode += 1 + LINK_SIZE + GET(ecode, LINK_SIZE + 2);          ecode += 1 + LINK_SIZE + GET(ecode, LINK_SIZE + 2);
1078          while (*ecode == OP_ALT) ecode += GET(ecode, 1);          while (*ecode == OP_ALT) ecode += GET(ecode, 1);
1079          }          }
1080        else if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN)        else if (rrc != MATCH_NOMATCH &&
1081                  (rrc != MATCH_THEN || md->start_match_ptr != ecode))
1082          {          {
1083          RRETURN(rrc);         /* Need braces because of following else */          RRETURN(rrc);         /* Need braces because of following else */
1084          }          }
# Line 1194  for (;;) Line 1206  for (;;)
1206          mstart = md->start_match_ptr;   /* In case \K reset it */          mstart = md->start_match_ptr;   /* In case \K reset it */
1207          break;          break;
1208          }          }
1209        if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc);        if (rrc != MATCH_NOMATCH &&
1210              (rrc != MATCH_THEN || md->start_match_ptr != ecode))
1211            RRETURN(rrc);
1212        ecode += GET(ecode, 1);        ecode += GET(ecode, 1);
1213        }        }
1214      while (*ecode == OP_ALT);      while (*ecode == OP_ALT);
# Line 1228  for (;;) Line 1242  for (;;)
1242          do ecode += GET(ecode,1); while (*ecode == OP_ALT);          do ecode += GET(ecode,1); while (*ecode == OP_ALT);
1243          break;          break;
1244          }          }
1245        if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc);        if (rrc != MATCH_NOMATCH &&
1246              (rrc != MATCH_THEN || md->start_match_ptr != ecode))
1247            RRETURN(rrc);
1248        ecode += GET(ecode,1);        ecode += GET(ecode,1);
1249        }        }
1250      while (*ecode == OP_ALT);      while (*ecode == OP_ALT);
# Line 1365  for (;;) Line 1381  for (;;)
1381              (pcre_free)(new_recursive.offset_save);              (pcre_free)(new_recursive.offset_save);
1382            MRRETURN(MATCH_MATCH);            MRRETURN(MATCH_MATCH);
1383            }            }
1384          else if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN)          else if (rrc != MATCH_NOMATCH &&
1385                    (rrc != MATCH_THEN || md->start_match_ptr != ecode))
1386            {            {
1387            DPRINTF(("Recursion gave error %d\n", rrc));            DPRINTF(("Recursion gave error %d\n", rrc));
1388            if (new_recursive.offset_save != stacksave)            if (new_recursive.offset_save != stacksave)
# Line 1408  for (;;) Line 1425  for (;;)
1425          mstart = md->start_match_ptr;          mstart = md->start_match_ptr;
1426          break;          break;
1427          }          }
1428        if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc);        if (rrc != MATCH_NOMATCH &&
1429              (rrc != MATCH_THEN || md->start_match_ptr != ecode))
1430            RRETURN(rrc);
1431        ecode += GET(ecode,1);        ecode += GET(ecode,1);
1432        }        }
1433      while (*ecode == OP_ALT);      while (*ecode == OP_ALT);
# Line 5959  for(;;) Line 5978  for(;;)
5978        while (start_match < end_subject)        while (start_match < end_subject)
5979          {          {
5980          register unsigned int c = *start_match;          register unsigned int c = *start_match;
5981          if ((start_bits[c/8] & (1 << (c&7))) == 0) start_match++;          if ((start_bits[c/8] & (1 << (c&7))) == 0)
5982            else break;            {
5983              start_match++;
5984    #ifdef SUPPORT_UTF8
5985              if (utf8)
5986                while(start_match < end_subject && (*start_match & 0xc0) == 0x80)
5987                  start_match++;
5988    #endif
5989              }
5990            else break;
5991          }          }
5992        }        }
5993      }   /* Starting optimizations */      }   /* Starting optimizations */
# Line 6061  for(;;) Line 6088  for(;;)
6088    
6089    switch(rc)    switch(rc)
6090      {      {
6091      /* NOMATCH and PRUNE advance by one character. If MATCH_SKIP_ARG reaches      /* SKIP passes back the next starting point explicitly, but if it is the
6092      this level it means that a MARK that matched the SKIP's arg was not found.      same as the match we have just done, treat it as NOMATCH. */
6093      We treat this as NOMATCH. THEN at this level acts exactly like PRUNE. */  
6094        case MATCH_SKIP:
6095        if (md->start_match_ptr != start_match)
6096          {
6097          new_start_match = md->start_match_ptr;
6098          break;
6099          }
6100        /* Fall through */
6101    
6102        /* If MATCH_SKIP_ARG reaches this level it means that a MARK that matched
6103        the SKIP's arg was not found. We also treat this as NOMATCH. */
6104    
6105        case MATCH_SKIP_ARG:
6106        /* Fall through */
6107    
6108        /* NOMATCH and PRUNE advance by one character. THEN at this level acts
6109        exactly like PRUNE. */
6110    
6111      case MATCH_NOMATCH:      case MATCH_NOMATCH:
6112      case MATCH_PRUNE:      case MATCH_PRUNE:
     case MATCH_SKIP_ARG:  
6113      case MATCH_THEN:      case MATCH_THEN:
6114      new_start_match = start_match + 1;      new_start_match = start_match + 1;
6115  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
# Line 6077  for(;;) Line 6119  for(;;)
6119  #endif  #endif
6120      break;      break;
6121    
     /* SKIP passes back the next starting point explicitly. */  
   
     case MATCH_SKIP:  
     new_start_match = md->start_match_ptr;  
     break;  
   
6122      /* COMMIT disables the bumpalong, but otherwise behaves as NOMATCH. */      /* COMMIT disables the bumpalong, but otherwise behaves as NOMATCH. */
6123    
6124      case MATCH_COMMIT:      case MATCH_COMMIT:

Legend:
Removed from v.531  
changed lines
  Added in v.550

  ViewVC Help
Powered by ViewVC 1.1.5