/[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 545 by ph10, Wed Jun 16 10:51:15 2010 UTC revision 551 by ph10, Sun Oct 10 17:33:07 2010 UTC
# Line 710  for (;;) Line 710  for (;;)
710      case OP_FAIL:      case OP_FAIL:
711      MRRETURN(MATCH_NOMATCH);      MRRETURN(MATCH_NOMATCH);
712    
713        /* COMMIT overrides PRUNE, SKIP, and THEN */
714    
715      case OP_COMMIT:      case OP_COMMIT:
716      RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md,      RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md,
717        ims, eptrb, flags, RM52);        ims, eptrb, flags, RM52);
718      if (rrc != MATCH_NOMATCH) RRETURN(rrc);      if (rrc != MATCH_NOMATCH && rrc != MATCH_PRUNE &&
719            rrc != MATCH_SKIP && rrc != MATCH_SKIP_ARG &&
720            rrc != MATCH_THEN)
721          RRETURN(rrc);
722      MRRETURN(MATCH_COMMIT);      MRRETURN(MATCH_COMMIT);
723    
724        /* PRUNE overrides THEN */
725    
726      case OP_PRUNE:      case OP_PRUNE:
727      RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md,      RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md,
728        ims, eptrb, flags, RM51);        ims, eptrb, flags, RM51);
729      if (rrc != MATCH_NOMATCH) RRETURN(rrc);      if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc);
730      MRRETURN(MATCH_PRUNE);      MRRETURN(MATCH_PRUNE);
731    
732      case OP_PRUNE_ARG:      case OP_PRUNE_ARG:
733      RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode] + ecode[1], offset_top, md,      RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode] + ecode[1], offset_top, md,
734        ims, eptrb, flags, RM56);        ims, eptrb, flags, RM56);
735      if (rrc != MATCH_NOMATCH) RRETURN(rrc);      if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc);
736      md->mark = ecode + 2;      md->mark = ecode + 2;
737      RRETURN(MATCH_PRUNE);      RRETURN(MATCH_PRUNE);
738    
739        /* SKIP overrides PRUNE and THEN */
740    
741      case OP_SKIP:      case OP_SKIP:
742      RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md,      RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md,
743        ims, eptrb, flags, RM53);        ims, eptrb, flags, RM53);
744      if (rrc != MATCH_NOMATCH) RRETURN(rrc);      if (rrc != MATCH_NOMATCH && rrc != MATCH_PRUNE && rrc != MATCH_THEN)
745          RRETURN(rrc);
746      md->start_match_ptr = eptr;   /* Pass back current position */      md->start_match_ptr = eptr;   /* Pass back current position */
747      MRRETURN(MATCH_SKIP);      MRRETURN(MATCH_SKIP);
748    
749      case OP_SKIP_ARG:      case OP_SKIP_ARG:
750      RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode] + ecode[1], offset_top, md,      RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode] + ecode[1], offset_top, md,
751        ims, eptrb, flags, RM57);        ims, eptrb, flags, RM57);
752      if (rrc != MATCH_NOMATCH) RRETURN(rrc);      if (rrc != MATCH_NOMATCH && rrc != MATCH_PRUNE && rrc != MATCH_THEN)
753          RRETURN(rrc);
754    
755      /* Pass back the current skip name by overloading md->start_match_ptr and      /* Pass back the current skip name by overloading md->start_match_ptr and
756      returning the special MATCH_SKIP_ARG return code. This will either be      returning the special MATCH_SKIP_ARG return code. This will either be
# Line 748  for (;;) Line 759  for (;;)
759    
760      md->start_match_ptr = ecode + 2;      md->start_match_ptr = ecode + 2;
761      RRETURN(MATCH_SKIP_ARG);      RRETURN(MATCH_SKIP_ARG);
762    
763        /* For THEN (and THEN_ARG) we pass back the address of the bracket or
764        the alt that is at the start of the current branch. This makes it possible
765        to skip back past alternatives that precede the THEN within the current
766        branch. */
767    
768      case OP_THEN:      case OP_THEN:
769      RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md,      RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md,
770        ims, eptrb, flags, RM54);        ims, eptrb, flags, RM54);
771      if (rrc != MATCH_NOMATCH) RRETURN(rrc);      if (rrc != MATCH_NOMATCH) RRETURN(rrc);
772        md->start_match_ptr = ecode - GET(ecode, 1);
773      MRRETURN(MATCH_THEN);      MRRETURN(MATCH_THEN);
774    
775      case OP_THEN_ARG:      case OP_THEN_ARG:
776      RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode] + ecode[1], offset_top, md,      RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode] + ecode[1+LINK_SIZE],
777        ims, eptrb, flags, RM58);        offset_top, md, ims, eptrb, flags, RM58);
778      if (rrc != MATCH_NOMATCH) RRETURN(rrc);      if (rrc != MATCH_NOMATCH) RRETURN(rrc);
779      md->mark = ecode + 2;      md->start_match_ptr = ecode - GET(ecode, 1);
780        md->mark = ecode + LINK_SIZE + 2;
781      RRETURN(MATCH_THEN);      RRETURN(MATCH_THEN);
782    
783      /* 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 822  for (;;)
822          {          {
823          RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md,          RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md,
824            ims, eptrb, flags, RM1);            ims, eptrb, flags, RM1);
825          if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc);          if (rrc != MATCH_NOMATCH &&
826                (rrc != MATCH_THEN || md->start_match_ptr != ecode))
827              RRETURN(rrc);
828          md->capture_last = save_capture_last;          md->capture_last = save_capture_last;
829          ecode += GET(ecode, 1);          ecode += GET(ecode, 1);
830          }          }
# Line 865  for (;;) Line 885  for (;;)
885    
886        RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, ims,        RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, ims,
887          eptrb, flags, RM2);          eptrb, flags, RM2);
888        if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc);        if (rrc != MATCH_NOMATCH &&
889              (rrc != MATCH_THEN || md->start_match_ptr != ecode))
890            RRETURN(rrc);
891        ecode += GET(ecode, 1);        ecode += GET(ecode, 1);
892        }        }
893      /* Control never reaches here. */      /* Control never reaches here. */
# Line 1066  for (;;) Line 1088  for (;;)
1088          ecode += 1 + LINK_SIZE + GET(ecode, LINK_SIZE + 2);          ecode += 1 + LINK_SIZE + GET(ecode, LINK_SIZE + 2);
1089          while (*ecode == OP_ALT) ecode += GET(ecode, 1);          while (*ecode == OP_ALT) ecode += GET(ecode, 1);
1090          }          }
1091        else if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN)        else if (rrc != MATCH_NOMATCH &&
1092                  (rrc != MATCH_THEN || md->start_match_ptr != ecode))
1093          {          {
1094          RRETURN(rrc);         /* Need braces because of following else */          RRETURN(rrc);         /* Need braces because of following else */
1095          }          }
# Line 1194  for (;;) Line 1217  for (;;)
1217          mstart = md->start_match_ptr;   /* In case \K reset it */          mstart = md->start_match_ptr;   /* In case \K reset it */
1218          break;          break;
1219          }          }
1220        if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc);        if (rrc != MATCH_NOMATCH &&
1221              (rrc != MATCH_THEN || md->start_match_ptr != ecode))
1222            RRETURN(rrc);
1223        ecode += GET(ecode, 1);        ecode += GET(ecode, 1);
1224        }        }
1225      while (*ecode == OP_ALT);      while (*ecode == OP_ALT);
# Line 1228  for (;;) Line 1253  for (;;)
1253          do ecode += GET(ecode,1); while (*ecode == OP_ALT);          do ecode += GET(ecode,1); while (*ecode == OP_ALT);
1254          break;          break;
1255          }          }
1256        if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc);        if (rrc != MATCH_NOMATCH &&
1257              (rrc != MATCH_THEN || md->start_match_ptr != ecode))
1258            RRETURN(rrc);
1259        ecode += GET(ecode,1);        ecode += GET(ecode,1);
1260        }        }
1261      while (*ecode == OP_ALT);      while (*ecode == OP_ALT);
# Line 1365  for (;;) Line 1392  for (;;)
1392              (pcre_free)(new_recursive.offset_save);              (pcre_free)(new_recursive.offset_save);
1393            MRRETURN(MATCH_MATCH);            MRRETURN(MATCH_MATCH);
1394            }            }
1395          else if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN)          else if (rrc != MATCH_NOMATCH &&
1396                    (rrc != MATCH_THEN || md->start_match_ptr != ecode))
1397            {            {
1398            DPRINTF(("Recursion gave error %d\n", rrc));            DPRINTF(("Recursion gave error %d\n", rrc));
1399            if (new_recursive.offset_save != stacksave)            if (new_recursive.offset_save != stacksave)
# Line 1408  for (;;) Line 1436  for (;;)
1436          mstart = md->start_match_ptr;          mstart = md->start_match_ptr;
1437          break;          break;
1438          }          }
1439        if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN) RRETURN(rrc);        if (rrc != MATCH_NOMATCH &&
1440              (rrc != MATCH_THEN || md->start_match_ptr != ecode))
1441            RRETURN(rrc);
1442        ecode += GET(ecode,1);        ecode += GET(ecode,1);
1443        }        }
1444      while (*ecode == OP_ALT);      while (*ecode == OP_ALT);

Legend:
Removed from v.545  
changed lines
  Added in v.551

  ViewVC Help
Powered by ViewVC 1.1.5