/[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 510 by ph10, Sat Mar 27 17:45:29 2010 UTC revision 551 by ph10, Sun Oct 10 17:33:07 2010 UTC
# Line 71  defined PCRE_ERROR_xxx codes, which are Line 71  defined PCRE_ERROR_xxx codes, which are
71  /* Special internal returns from the match() function. Make them sufficiently  /* Special internal returns from the match() function. Make them sufficiently
72  negative to avoid the external error codes. */  negative to avoid the external error codes. */
73    
74  #define MATCH_COMMIT       (-999)  #define MATCH_ACCEPT       (-999)
75  #define MATCH_PRUNE        (-998)  #define MATCH_COMMIT       (-998)
76  #define MATCH_SKIP         (-997)  #define MATCH_PRUNE        (-997)
77  #define MATCH_SKIP_ARG     (-996)  #define MATCH_SKIP         (-996)
78  #define MATCH_THEN         (-995)  #define MATCH_SKIP_ARG     (-995)
79    #define MATCH_THEN         (-994)
80    
81  /* This is a convenience macro for code that occurs many times. */  /* This is a convenience macro for code that occurs many times. */
82    
# Line 254  enum { RM1=1, RM2,  RM3,  RM4,  RM5,  RM Line 255  enum { RM1=1, RM2,  RM3,  RM4,  RM5,  RM
255         RM21,  RM22, RM23, RM24, RM25, RM26, RM27, RM28, RM29, RM30,         RM21,  RM22, RM23, RM24, RM25, RM26, RM27, RM28, RM29, RM30,
256         RM31,  RM32, RM33, RM34, RM35, RM36, RM37, RM38, RM39, RM40,         RM31,  RM32, RM33, RM34, RM35, RM36, RM37, RM38, RM39, RM40,
257         RM41,  RM42, RM43, RM44, RM45, RM46, RM47, RM48, RM49, RM50,         RM41,  RM42, RM43, RM44, RM45, RM46, RM47, RM48, RM49, RM50,
258         RM51,  RM52, RM53, RM54 };         RM51,  RM52, RM53, RM54, RM55, RM56, RM57, RM58, RM59, RM60,
259           RM61,  RM62 };
260    
261  /* These versions of the macros use the stack, as normal. There are debugging  /* These versions of the macros use the stack, as normal. There are debugging
262  versions and production versions. Note that the "rw" argument of RMATCH isn't  versions and production versions. Note that the "rw" argument of RMATCH isn't
# Line 293  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 (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 313  argument of match(), which never changes Line 316  argument of match(), which never changes
316    
317  #define RRETURN(ra)\  #define RRETURN(ra)\
318    {\    {\
319    heapframe *newframe = frame;\    heapframe *oldframe = frame;\
320    frame = newframe->Xprevframe;\    frame = oldframe->Xprevframe;\
321    (pcre_stack_free)(newframe);\    (pcre_stack_free)(oldframe);\
322    if (frame != NULL)\    if (frame != NULL)\
323      {\      {\
324      rrc = ra;\      rrc = ra;\
# Line 486  heap whenever RMATCH() does a "recursion Line 489  heap whenever RMATCH() does a "recursion
489    
490  #ifdef NO_RECURSE  #ifdef NO_RECURSE
491  heapframe *frame = (pcre_stack_malloc)(sizeof(heapframe));  heapframe *frame = (pcre_stack_malloc)(sizeof(heapframe));
492    if (frame == NULL) RRETURN(PCRE_ERROR_NOMEMORY);
493  frame->Xprevframe = NULL;            /* Marks the top level */  frame->Xprevframe = NULL;            /* Marks the top level */
494    
495  /* Copy in the original argument variables */  /* Copy in the original argument variables */
# Line 684  for (;;) Line 688  for (;;)
688      case OP_MARK:      case OP_MARK:
689      markptr = ecode + 2;      markptr = ecode + 2;
690      RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode] + ecode[1], offset_top, md,      RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode] + ecode[1], offset_top, md,
691        ims, eptrb, flags, RM51);        ims, eptrb, flags, RM55);
692    
693      /* A return of MATCH_SKIP_ARG means that matching failed at SKIP with an      /* A return of MATCH_SKIP_ARG means that matching failed at SKIP with an
694      argument, and we must check whether that argument matches this MARK's      argument, and we must check whether that argument matches this MARK's
695      argument. It is passed back in md->start_match_ptr (an overloading of that      argument. It is passed back in md->start_match_ptr (an overloading of that
696      variable). If it does match, we reset that variable to the current subject      variable). If it does match, we reset that variable to the current subject
697      position and return MATCH_SKIP. Otherwise, pass back the return code      position and return MATCH_SKIP. Otherwise, pass back the return code
698      unaltered. */      unaltered. */
699    
700      if (rrc == MATCH_SKIP_ARG &&      if (rrc == MATCH_SKIP_ARG &&
701          strcmp((char *)markptr, (char *)(md->start_match_ptr)) == 0)          strcmp((char *)markptr, (char *)(md->start_match_ptr)) == 0)
702        {        {
703        md->start_match_ptr = eptr;        md->start_match_ptr = eptr;
704        RRETURN(MATCH_SKIP);        RRETURN(MATCH_SKIP);
705        }        }
706    
707      if (md->mark == NULL) md->mark = markptr;      if (md->mark == NULL) md->mark = markptr;
708      RRETURN(rrc);      RRETURN(rrc);
709    
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, RM51);        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, RM53);        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      /* Pass back the current skip name by overloading md->start_match_ptr and  
755      returning the special MATCH_SKIP_ARG return code. This will either be      /* Pass back the current skip name by overloading md->start_match_ptr and
756      caught by a matching MARK, or get to the top, where it is treated the same      returning the special MATCH_SKIP_ARG return code. This will either be
757        caught by a matching MARK, or get to the top, where it is treated the same
758      as PRUNE. */      as PRUNE. */
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, RM54);        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 792  for (;;) Line 814  for (;;)
814        save_capture_last = md->capture_last;        save_capture_last = md->capture_last;
815    
816        DPRINTF(("saving %d %d %d\n", save_offset1, save_offset2, save_offset3));        DPRINTF(("saving %d %d %d\n", save_offset1, save_offset2, save_offset3));
817        md->offset_vector[md->offset_end - number] = eptr - md->start_subject;        md->offset_vector[md->offset_end - number] =
818            (int)(eptr - md->start_subject);
819    
820        flags = (op == OP_SCBRA)? match_cbegroup : 0;        flags = (op == OP_SCBRA)? match_cbegroup : 0;
821        do        do
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 851  for (;;) Line 876  for (;;)
876    
877          RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, ims,          RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, ims,
878            eptrb, flags, RM48);            eptrb, flags, RM48);
879          if (rrc == MATCH_NOMATCH) md->mark = markptr;          if (rrc == MATCH_NOMATCH) md->mark = markptr;
880          RRETURN(rrc);          RRETURN(rrc);
881          }          }
882    
883        /* For non-final alternatives, continue the loop for a NOMATCH result;        /* For non-final alternatives, continue the loop for a NOMATCH result;
# Line 860  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 887  for (;;) Line 914  for (;;)
914          cb.callout_number   = ecode[LINK_SIZE+2];          cb.callout_number   = ecode[LINK_SIZE+2];
915          cb.offset_vector    = md->offset_vector;          cb.offset_vector    = md->offset_vector;
916          cb.subject          = (PCRE_SPTR)md->start_subject;          cb.subject          = (PCRE_SPTR)md->start_subject;
917          cb.subject_length   = md->end_subject - md->start_subject;          cb.subject_length   = (int)(md->end_subject - md->start_subject);
918          cb.start_match      = mstart - md->start_subject;          cb.start_match      = (int)(mstart - md->start_subject);
919          cb.current_position = eptr - md->start_subject;          cb.current_position = (int)(eptr - md->start_subject);
920          cb.pattern_position = GET(ecode, LINK_SIZE + 3);          cb.pattern_position = GET(ecode, LINK_SIZE + 3);
921          cb.next_item_length = GET(ecode, 3 + 2*LINK_SIZE);          cb.next_item_length = GET(ecode, 3 + 2*LINK_SIZE);
922          cb.capture_top      = offset_top/2;          cb.capture_top      = offset_top/2;
# Line 1061  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 1115  for (;;) Line 1143  for (;;)
1143        {        {
1144        md->offset_vector[offset] =        md->offset_vector[offset] =
1145          md->offset_vector[md->offset_end - number];          md->offset_vector[md->offset_end - number];
1146        md->offset_vector[offset+1] = eptr - md->start_subject;        md->offset_vector[offset+1] = (int)(eptr - md->start_subject);
1147        if (offset_top <= offset) offset_top = offset + 2;        if (offset_top <= offset) offset_top = offset + 2;
1148        }        }
1149      ecode += 3;      ecode += 3;
# Line 1157  for (;;) Line 1185  for (;;)
1185      md->end_match_ptr = eptr;           /* Record where we ended */      md->end_match_ptr = eptr;           /* Record where we ended */
1186      md->end_offset_top = offset_top;    /* and how many extracts were taken */      md->end_offset_top = offset_top;    /* and how many extracts were taken */
1187      md->start_match_ptr = mstart;       /* and the start (\K can modify) */      md->start_match_ptr = mstart;       /* and the start (\K can modify) */
1188      MRRETURN(MATCH_MATCH);  
1189        /* For some reason, the macros don't work properly if an expression is
1190        given as the argument to MRRETURN when the heap is in use. */
1191    
1192        rrc = (op == OP_END)? MATCH_MATCH : MATCH_ACCEPT;
1193        MRRETURN(rrc);
1194    
1195      /* Change option settings */      /* Change option settings */
1196    
# Line 1179  for (;;) Line 1212  for (;;)
1212        {        {
1213        RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, NULL, 0,        RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, NULL, 0,
1214          RM4);          RM4);
1215        if (rrc == MATCH_MATCH)        if (rrc == MATCH_MATCH || rrc == MATCH_ACCEPT)
1216          {          {
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 1212  for (;;) Line 1247  for (;;)
1247        {        {
1248        RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, NULL, 0,        RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, ims, NULL, 0,
1249          RM5);          RM5);
1250        if (rrc == MATCH_MATCH) MRRETURN(MATCH_NOMATCH);        if (rrc == MATCH_MATCH || rrc == MATCH_ACCEPT) MRRETURN(MATCH_NOMATCH);
1251        if (rrc == MATCH_SKIP || rrc == MATCH_PRUNE || rrc == MATCH_COMMIT)        if (rrc == MATCH_SKIP || rrc == MATCH_PRUNE || rrc == MATCH_COMMIT)
1252          {          {
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 1273  for (;;) Line 1310  for (;;)
1310        cb.callout_number   = ecode[1];        cb.callout_number   = ecode[1];
1311        cb.offset_vector    = md->offset_vector;        cb.offset_vector    = md->offset_vector;
1312        cb.subject          = (PCRE_SPTR)md->start_subject;        cb.subject          = (PCRE_SPTR)md->start_subject;
1313        cb.subject_length   = md->end_subject - md->start_subject;        cb.subject_length   = (int)(md->end_subject - md->start_subject);
1314        cb.start_match      = mstart - md->start_subject;        cb.start_match      = (int)(mstart - md->start_subject);
1315        cb.current_position = eptr - md->start_subject;        cb.current_position = (int)(eptr - md->start_subject);
1316        cb.pattern_position = GET(ecode, 2);        cb.pattern_position = GET(ecode, 2);
1317        cb.next_item_length = GET(ecode, 2 + LINK_SIZE);        cb.next_item_length = GET(ecode, 2 + LINK_SIZE);
1318        cb.capture_top      = offset_top/2;        cb.capture_top      = offset_top/2;
# Line 1347  for (;;) Line 1384  for (;;)
1384          {          {
1385          RMATCH(eptr, callpat + _pcre_OP_lengths[*callpat], offset_top,          RMATCH(eptr, callpat + _pcre_OP_lengths[*callpat], offset_top,
1386            md, ims, eptrb, flags, RM6);            md, ims, eptrb, flags, RM6);
1387          if (rrc == MATCH_MATCH)          if (rrc == MATCH_MATCH || rrc == MATCH_ACCEPT)
1388            {            {
1389            DPRINTF(("Recursion matched\n"));            DPRINTF(("Recursion matched\n"));
1390            md->recursive = new_recursive.prevrec;            md->recursive = new_recursive.prevrec;
# Line 1355  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 1393  for (;;) Line 1431  for (;;)
1431      do      do
1432        {        {
1433        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);
1434        if (rrc == MATCH_MATCH)        if (rrc == MATCH_MATCH)  /* Note: _not_ MATCH_ACCEPT */
1435          {          {
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);
# Line 1552  for (;;) Line 1592  for (;;)
1592          {          {
1593          md->offset_vector[offset] =          md->offset_vector[offset] =
1594            md->offset_vector[md->offset_end - number];            md->offset_vector[md->offset_end - number];
1595          md->offset_vector[offset+1] = eptr - md->start_subject;          md->offset_vector[offset+1] = (int)(eptr - md->start_subject);
1596          if (offset_top <= offset) offset_top = offset + 2;          if (offset_top <= offset) offset_top = offset + 2;
1597          }          }
1598    
# Line 1712  for (;;) Line 1752  for (;;)
1752  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
1753        if (utf8)        if (utf8)
1754          {          {
1755            /* Get status of previous character */
1756    
1757          if (eptr == md->start_subject) prev_is_word = FALSE; else          if (eptr == md->start_subject) prev_is_word = FALSE; else
1758            {            {
1759            USPTR lastptr = eptr - 1;            USPTR lastptr = eptr - 1;
1760            while((*lastptr & 0xc0) == 0x80) lastptr--;            while((*lastptr & 0xc0) == 0x80) lastptr--;
1761            if (lastptr < md->start_used_ptr) md->start_used_ptr = lastptr;            if (lastptr < md->start_used_ptr) md->start_used_ptr = lastptr;
1762            GETCHAR(c, lastptr);            GETCHAR(c, lastptr);
1763    #ifdef SUPPORT_UCP
1764              if (md->use_ucp)
1765                {
1766                if (c == '_') prev_is_word = TRUE; else
1767                  {
1768                  int cat = UCD_CATEGORY(c);
1769                  prev_is_word = (cat == ucp_L || cat == ucp_N);
1770                  }
1771                }
1772              else
1773    #endif
1774            prev_is_word = c < 256 && (md->ctypes[c] & ctype_word) != 0;            prev_is_word = c < 256 && (md->ctypes[c] & ctype_word) != 0;
1775            }            }
1776    
1777            /* Get status of next character */
1778    
1779          if (eptr >= md->end_subject)          if (eptr >= md->end_subject)
1780            {            {
1781            SCHECK_PARTIAL();            SCHECK_PARTIAL();
# Line 1728  for (;;) Line 1784  for (;;)
1784          else          else
1785            {            {
1786            GETCHAR(c, eptr);            GETCHAR(c, eptr);
1787    #ifdef SUPPORT_UCP
1788              if (md->use_ucp)
1789                {
1790                if (c == '_') cur_is_word = TRUE; else
1791                  {
1792                  int cat = UCD_CATEGORY(c);
1793                  cur_is_word = (cat == ucp_L || cat == ucp_N);
1794                  }
1795                }
1796              else
1797    #endif
1798            cur_is_word = c < 256 && (md->ctypes[c] & ctype_word) != 0;            cur_is_word = c < 256 && (md->ctypes[c] & ctype_word) != 0;
1799            }            }
1800          }          }
1801        else        else
1802  #endif  #endif
1803    
1804        /* Not in UTF-8 mode */        /* Not in UTF-8 mode, but we may still have PCRE_UCP set, and for
1805          consistency with the behaviour of \w we do use it in this case. */
1806    
1807          {          {
1808            /* Get status of previous character */
1809    
1810          if (eptr == md->start_subject) prev_is_word = FALSE; else          if (eptr == md->start_subject) prev_is_word = FALSE; else
1811            {            {
1812            if (eptr <= md->start_used_ptr) md->start_used_ptr = eptr - 1;            if (eptr <= md->start_used_ptr) md->start_used_ptr = eptr - 1;
1813    #ifdef SUPPORT_UCP
1814              if (md->use_ucp)
1815                {
1816                c = eptr[-1];
1817                if (c == '_') prev_is_word = TRUE; else
1818                  {
1819                  int cat = UCD_CATEGORY(c);
1820                  prev_is_word = (cat == ucp_L || cat == ucp_N);
1821                  }
1822                }
1823              else
1824    #endif
1825            prev_is_word = ((md->ctypes[eptr[-1]] & ctype_word) != 0);            prev_is_word = ((md->ctypes[eptr[-1]] & ctype_word) != 0);
1826            }            }
1827    
1828            /* Get status of next character */
1829    
1830          if (eptr >= md->end_subject)          if (eptr >= md->end_subject)
1831            {            {
1832            SCHECK_PARTIAL();            SCHECK_PARTIAL();
1833            cur_is_word = FALSE;            cur_is_word = FALSE;
1834            }            }
1835          else cur_is_word = ((md->ctypes[*eptr] & ctype_word) != 0);          else
1836    #ifdef SUPPORT_UCP
1837            if (md->use_ucp)
1838              {
1839              c = *eptr;
1840              if (c == '_') cur_is_word = TRUE; else
1841                {
1842                int cat = UCD_CATEGORY(c);
1843                cur_is_word = (cat == ucp_L || cat == ucp_N);
1844                }
1845              }
1846            else
1847    #endif
1848            cur_is_word = ((md->ctypes[*eptr] & ctype_word) != 0);
1849          }          }
1850    
1851        /* Now see if the situation is what we want */        /* Now see if the situation is what we want */
# Line 2054  for (;;) Line 2152  for (;;)
2152               prop->chartype == ucp_Ll ||               prop->chartype == ucp_Ll ||
2153               prop->chartype == ucp_Lt) == (op == OP_NOTPROP))               prop->chartype == ucp_Lt) == (op == OP_NOTPROP))
2154            MRRETURN(MATCH_NOMATCH);            MRRETURN(MATCH_NOMATCH);
2155           break;          break;
2156    
2157          case PT_GC:          case PT_GC:
2158          if ((ecode[2] != _pcre_ucp_gentype[prop->chartype]) == (op == OP_PROP))          if ((ecode[2] != _pcre_ucp_gentype[prop->chartype]) == (op == OP_PROP))
# Line 2071  for (;;) Line 2169  for (;;)
2169            MRRETURN(MATCH_NOMATCH);            MRRETURN(MATCH_NOMATCH);
2170          break;          break;
2171    
2172            /* These are specials */
2173    
2174            case PT_ALNUM:
2175            if ((_pcre_ucp_gentype[prop->chartype] == ucp_L ||
2176                 _pcre_ucp_gentype[prop->chartype] == ucp_N) == (op == OP_NOTPROP))
2177              MRRETURN(MATCH_NOMATCH);
2178            break;
2179    
2180            case PT_SPACE:    /* Perl space */
2181            if ((_pcre_ucp_gentype[prop->chartype] == ucp_Z ||
2182                 c == CHAR_HT || c == CHAR_NL || c == CHAR_FF || c == CHAR_CR)
2183                   == (op == OP_NOTPROP))
2184              MRRETURN(MATCH_NOMATCH);
2185            break;
2186    
2187            case PT_PXSPACE:  /* POSIX space */
2188            if ((_pcre_ucp_gentype[prop->chartype] == ucp_Z ||
2189                 c == CHAR_HT || c == CHAR_NL || c == CHAR_VT ||
2190                 c == CHAR_FF || c == CHAR_CR)
2191                   == (op == OP_NOTPROP))
2192              MRRETURN(MATCH_NOMATCH);
2193            break;
2194    
2195            case PT_WORD:
2196            if ((_pcre_ucp_gentype[prop->chartype] == ucp_L ||
2197                 _pcre_ucp_gentype[prop->chartype] == ucp_N ||
2198                 c == CHAR_UNDERSCORE) == (op == OP_NOTPROP))
2199              MRRETURN(MATCH_NOMATCH);
2200            break;
2201    
2202            /* This should never occur */
2203    
2204          default:          default:
2205          RRETURN(PCRE_ERROR_INTERNAL);          RRETURN(PCRE_ERROR_INTERNAL);
2206          }          }
# Line 2136  for (;;) Line 2266  for (;;)
2266        referenced subpattern. */        referenced subpattern. */
2267    
2268        if (offset >= offset_top || md->offset_vector[offset] < 0)        if (offset >= offset_top || md->offset_vector[offset] < 0)
2269          length = (md->jscript_compat)? 0 : md->end_subject - eptr + 1;          length = (md->jscript_compat)? 0 : (int)(md->end_subject - eptr + 1);
2270        else        else
2271          length = md->offset_vector[offset+1] - md->offset_vector[offset];          length = md->offset_vector[offset+1] - md->offset_vector[offset];
2272    
# Line 3487  for (;;) Line 3617  for (;;)
3617              }              }
3618            break;            break;
3619    
3620              case PT_ALNUM:
3621              for (i = 1; i <= min; i++)
3622                {
3623                if (eptr >= md->end_subject)
3624                  {
3625                  SCHECK_PARTIAL();
3626                  MRRETURN(MATCH_NOMATCH);
3627                  }
3628                GETCHARINCTEST(c, eptr);
3629                prop_category = UCD_CATEGORY(c);
3630                if ((prop_category == ucp_L || prop_category == ucp_N)
3631                       == prop_fail_result)
3632                  MRRETURN(MATCH_NOMATCH);
3633                }
3634              break;
3635    
3636              case PT_SPACE:    /* Perl space */
3637              for (i = 1; i <= min; i++)
3638                {
3639                if (eptr >= md->end_subject)
3640                  {
3641                  SCHECK_PARTIAL();
3642                  MRRETURN(MATCH_NOMATCH);
3643                  }
3644                GETCHARINCTEST(c, eptr);
3645                prop_category = UCD_CATEGORY(c);
3646                if ((prop_category == ucp_Z || c == CHAR_HT || c == CHAR_NL ||
3647                     c == CHAR_FF || c == CHAR_CR)
3648                       == prop_fail_result)
3649                  MRRETURN(MATCH_NOMATCH);
3650                }
3651              break;
3652    
3653              case PT_PXSPACE:  /* POSIX space */
3654              for (i = 1; i <= min; i++)
3655                {
3656                if (eptr >= md->end_subject)
3657                  {
3658                  SCHECK_PARTIAL();
3659                  MRRETURN(MATCH_NOMATCH);
3660                  }
3661                GETCHARINCTEST(c, eptr);
3662                prop_category = UCD_CATEGORY(c);
3663                if ((prop_category == ucp_Z || c == CHAR_HT || c == CHAR_NL ||
3664                     c == CHAR_VT || c == CHAR_FF || c == CHAR_CR)
3665                       == prop_fail_result)
3666                  MRRETURN(MATCH_NOMATCH);
3667                }
3668              break;
3669    
3670              case PT_WORD:
3671              for (i = 1; i <= min; i++)
3672                {
3673                if (eptr >= md->end_subject)
3674                  {
3675                  SCHECK_PARTIAL();
3676                  MRRETURN(MATCH_NOMATCH);
3677                  }
3678                GETCHARINCTEST(c, eptr);
3679                prop_category = UCD_CATEGORY(c);
3680                if ((prop_category == ucp_L || prop_category == ucp_N ||
3681                     c == CHAR_UNDERSCORE)
3682                       == prop_fail_result)
3683                  MRRETURN(MATCH_NOMATCH);
3684                }
3685              break;
3686    
3687              /* This should not occur */
3688    
3689            default:            default:
3690            RRETURN(PCRE_ERROR_INTERNAL);            RRETURN(PCRE_ERROR_INTERNAL);
3691            }            }
# Line 4047  for (;;) Line 4246  for (;;)
4246                SCHECK_PARTIAL();                SCHECK_PARTIAL();
4247                MRRETURN(MATCH_NOMATCH);                MRRETURN(MATCH_NOMATCH);
4248                }                }
4249              GETCHARINC(c, eptr);              GETCHARINCTEST(c, eptr);
4250              if (prop_fail_result) MRRETURN(MATCH_NOMATCH);              if (prop_fail_result) MRRETURN(MATCH_NOMATCH);
4251              }              }
4252            /* Control never gets here */            /* Control never gets here */
# Line 4063  for (;;) Line 4262  for (;;)
4262                SCHECK_PARTIAL();                SCHECK_PARTIAL();
4263                MRRETURN(MATCH_NOMATCH);                MRRETURN(MATCH_NOMATCH);
4264                }                }
4265              GETCHARINC(c, eptr);              GETCHARINCTEST(c, eptr);
4266              prop_chartype = UCD_CHARTYPE(c);              prop_chartype = UCD_CHARTYPE(c);
4267              if ((prop_chartype == ucp_Lu ||              if ((prop_chartype == ucp_Lu ||
4268                   prop_chartype == ucp_Ll ||                   prop_chartype == ucp_Ll ||
# Line 4083  for (;;) Line 4282  for (;;)
4282                SCHECK_PARTIAL();                SCHECK_PARTIAL();
4283                MRRETURN(MATCH_NOMATCH);                MRRETURN(MATCH_NOMATCH);
4284                }                }
4285              GETCHARINC(c, eptr);              GETCHARINCTEST(c, eptr);
4286              prop_category = UCD_CATEGORY(c);              prop_category = UCD_CATEGORY(c);
4287              if ((prop_category == prop_value) == prop_fail_result)              if ((prop_category == prop_value) == prop_fail_result)
4288                MRRETURN(MATCH_NOMATCH);                MRRETURN(MATCH_NOMATCH);
# Line 4101  for (;;) Line 4300  for (;;)
4300                SCHECK_PARTIAL();                SCHECK_PARTIAL();
4301                MRRETURN(MATCH_NOMATCH);                MRRETURN(MATCH_NOMATCH);
4302                }                }
4303              GETCHARINC(c, eptr);              GETCHARINCTEST(c, eptr);
4304              prop_chartype = UCD_CHARTYPE(c);              prop_chartype = UCD_CHARTYPE(c);
4305              if ((prop_chartype == prop_value) == prop_fail_result)              if ((prop_chartype == prop_value) == prop_fail_result)
4306                MRRETURN(MATCH_NOMATCH);                MRRETURN(MATCH_NOMATCH);
# Line 4119  for (;;) Line 4318  for (;;)
4318                SCHECK_PARTIAL();                SCHECK_PARTIAL();
4319                MRRETURN(MATCH_NOMATCH);                MRRETURN(MATCH_NOMATCH);
4320                }                }
4321              GETCHARINC(c, eptr);              GETCHARINCTEST(c, eptr);
4322              prop_script = UCD_SCRIPT(c);              prop_script = UCD_SCRIPT(c);
4323              if ((prop_script == prop_value) == prop_fail_result)              if ((prop_script == prop_value) == prop_fail_result)
4324                MRRETURN(MATCH_NOMATCH);                MRRETURN(MATCH_NOMATCH);
4325              }              }
4326            /* Control never gets here */            /* Control never gets here */
4327    
4328              case PT_ALNUM:
4329              for (fi = min;; fi++)
4330                {
4331                RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM59);
4332                if (rrc != MATCH_NOMATCH) RRETURN(rrc);
4333                if (fi >= max) MRRETURN(MATCH_NOMATCH);
4334                if (eptr >= md->end_subject)
4335                  {
4336                  SCHECK_PARTIAL();
4337                  MRRETURN(MATCH_NOMATCH);
4338                  }
4339                GETCHARINCTEST(c, eptr);
4340                prop_category = UCD_CATEGORY(c);
4341                if ((prop_category == ucp_L || prop_category == ucp_N)
4342                       == prop_fail_result)
4343                  MRRETURN(MATCH_NOMATCH);
4344                }
4345              /* Control never gets here */
4346    
4347              case PT_SPACE:    /* Perl space */
4348              for (fi = min;; fi++)
4349                {
4350                RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM60);
4351                if (rrc != MATCH_NOMATCH) RRETURN(rrc);
4352                if (fi >= max) MRRETURN(MATCH_NOMATCH);
4353                if (eptr >= md->end_subject)
4354                  {
4355                  SCHECK_PARTIAL();
4356                  MRRETURN(MATCH_NOMATCH);
4357                  }
4358                GETCHARINCTEST(c, eptr);
4359                prop_category = UCD_CATEGORY(c);
4360                if ((prop_category == ucp_Z || c == CHAR_HT || c == CHAR_NL ||
4361                     c == CHAR_FF || c == CHAR_CR)
4362                       == prop_fail_result)
4363                  MRRETURN(MATCH_NOMATCH);
4364                }
4365              /* Control never gets here */
4366    
4367              case PT_PXSPACE:  /* POSIX space */
4368              for (fi = min;; fi++)
4369                {
4370                RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM61);
4371                if (rrc != MATCH_NOMATCH) RRETURN(rrc);
4372                if (fi >= max) MRRETURN(MATCH_NOMATCH);
4373                if (eptr >= md->end_subject)
4374                  {
4375                  SCHECK_PARTIAL();
4376                  MRRETURN(MATCH_NOMATCH);
4377                  }
4378                GETCHARINCTEST(c, eptr);
4379                prop_category = UCD_CATEGORY(c);
4380                if ((prop_category == ucp_Z || c == CHAR_HT || c == CHAR_NL ||
4381                     c == CHAR_VT || c == CHAR_FF || c == CHAR_CR)
4382                       == prop_fail_result)
4383                  MRRETURN(MATCH_NOMATCH);
4384                }
4385              /* Control never gets here */
4386    
4387              case PT_WORD:
4388              for (fi = min;; fi++)
4389                {
4390                RMATCH(eptr, ecode, offset_top, md, ims, eptrb, 0, RM62);
4391                if (rrc != MATCH_NOMATCH) RRETURN(rrc);
4392                if (fi >= max) MRRETURN(MATCH_NOMATCH);
4393                if (eptr >= md->end_subject)
4394                  {
4395                  SCHECK_PARTIAL();
4396                  MRRETURN(MATCH_NOMATCH);
4397                  }
4398                GETCHARINCTEST(c, eptr);
4399                prop_category = UCD_CATEGORY(c);
4400                if ((prop_category == ucp_L ||
4401                     prop_category == ucp_N ||
4402                     c == CHAR_UNDERSCORE)
4403                       == prop_fail_result)
4404                  MRRETURN(MATCH_NOMATCH);
4405                }
4406              /* Control never gets here */
4407    
4408              /* This should never occur */
4409    
4410            default:            default:
4411            RRETURN(PCRE_ERROR_INTERNAL);            RRETURN(PCRE_ERROR_INTERNAL);
4412            }            }
# Line 4472  for (;;) Line 4753  for (;;)
4753                SCHECK_PARTIAL();                SCHECK_PARTIAL();
4754                break;                break;
4755                }                }
4756              GETCHARLEN(c, eptr, len);              GETCHARLENTEST(c, eptr, len);
4757              if (prop_fail_result) break;              if (prop_fail_result) break;
4758              eptr+= len;              eptr+= len;
4759              }              }
# Line 4487  for (;;) Line 4768  for (;;)
4768                SCHECK_PARTIAL();                SCHECK_PARTIAL();
4769                break;                break;
4770                }                }
4771              GETCHARLEN(c, eptr, len);              GETCHARLENTEST(c, eptr, len);
4772              prop_chartype = UCD_CHARTYPE(c);              prop_chartype = UCD_CHARTYPE(c);
4773              if ((prop_chartype == ucp_Lu ||              if ((prop_chartype == ucp_Lu ||
4774                   prop_chartype == ucp_Ll ||                   prop_chartype == ucp_Ll ||
# Line 4506  for (;;) Line 4787  for (;;)
4787                SCHECK_PARTIAL();                SCHECK_PARTIAL();
4788                break;                break;
4789                }                }
4790              GETCHARLEN(c, eptr, len);              GETCHARLENTEST(c, eptr, len);
4791              prop_category = UCD_CATEGORY(c);              prop_category = UCD_CATEGORY(c);
4792              if ((prop_category == prop_value) == prop_fail_result)              if ((prop_category == prop_value) == prop_fail_result)
4793                break;                break;
# Line 4523  for (;;) Line 4804  for (;;)
4804                SCHECK_PARTIAL();                SCHECK_PARTIAL();
4805                break;                break;
4806                }                }
4807              GETCHARLEN(c, eptr, len);              GETCHARLENTEST(c, eptr, len);
4808              prop_chartype = UCD_CHARTYPE(c);              prop_chartype = UCD_CHARTYPE(c);
4809              if ((prop_chartype == prop_value) == prop_fail_result)              if ((prop_chartype == prop_value) == prop_fail_result)
4810                break;                break;
# Line 4540  for (;;) Line 4821  for (;;)
4821                SCHECK_PARTIAL();                SCHECK_PARTIAL();
4822                break;                break;
4823                }                }
4824              GETCHARLEN(c, eptr, len);              GETCHARLENTEST(c, eptr, len);
4825              prop_script = UCD_SCRIPT(c);              prop_script = UCD_SCRIPT(c);
4826              if ((prop_script == prop_value) == prop_fail_result)              if ((prop_script == prop_value) == prop_fail_result)
4827                break;                break;
4828              eptr+= len;              eptr+= len;
4829              }              }
4830            break;            break;
4831    
4832              case PT_ALNUM:
4833              for (i = min; i < max; i++)
4834                {
4835                int len = 1;
4836                if (eptr >= md->end_subject)
4837                  {
4838                  SCHECK_PARTIAL();
4839                  break;
4840                  }
4841                GETCHARLENTEST(c, eptr, len);
4842                prop_category = UCD_CATEGORY(c);
4843                if ((prop_category == ucp_L || prop_category == ucp_N)
4844                     == prop_fail_result)
4845                  break;
4846                eptr+= len;
4847                }
4848              break;
4849    
4850              case PT_SPACE:    /* Perl space */
4851              for (i = min; i < max; i++)
4852                {
4853                int len = 1;
4854                if (eptr >= md->end_subject)
4855                  {
4856                  SCHECK_PARTIAL();
4857                  break;
4858                  }
4859                GETCHARLENTEST(c, eptr, len);
4860                prop_category = UCD_CATEGORY(c);
4861                if ((prop_category == ucp_Z || c == CHAR_HT || c == CHAR_NL ||
4862                     c == CHAR_FF || c == CHAR_CR)
4863                     == prop_fail_result)
4864                  break;
4865                eptr+= len;
4866                }
4867              break;
4868    
4869              case PT_PXSPACE:  /* POSIX space */
4870              for (i = min; i < max; i++)
4871                {
4872                int len = 1;
4873                if (eptr >= md->end_subject)
4874                  {
4875                  SCHECK_PARTIAL();
4876                  break;
4877                  }
4878                GETCHARLENTEST(c, eptr, len);
4879                prop_category = UCD_CATEGORY(c);
4880                if ((prop_category == ucp_Z || c == CHAR_HT || c == CHAR_NL ||
4881                     c == CHAR_VT || c == CHAR_FF || c == CHAR_CR)
4882                     == prop_fail_result)
4883                  break;
4884                eptr+= len;
4885                }
4886              break;
4887    
4888              case PT_WORD:
4889              for (i = min; i < max; i++)
4890                {
4891                int len = 1;
4892                if (eptr >= md->end_subject)
4893                  {
4894                  SCHECK_PARTIAL();
4895                  break;
4896                  }
4897                GETCHARLENTEST(c, eptr, len);
4898                prop_category = UCD_CATEGORY(c);
4899                if ((prop_category == ucp_L || prop_category == ucp_N ||
4900                     c == CHAR_UNDERSCORE) == prop_fail_result)
4901                  break;
4902                eptr+= len;
4903                }
4904              break;
4905    
4906              default:
4907              RRETURN(PCRE_ERROR_INTERNAL);
4908            }            }
4909    
4910          /* eptr is now past the end of the maximum run */          /* eptr is now past the end of the maximum run */
# Line 5132  switch (frame->Xwhere) Line 5490  switch (frame->Xwhere)
5490    LBL( 9) LBL(10) LBL(11) LBL(12) LBL(13) LBL(14) LBL(15) LBL(17)    LBL( 9) LBL(10) LBL(11) LBL(12) LBL(13) LBL(14) LBL(15) LBL(17)
5491    LBL(19) LBL(24) LBL(25) LBL(26) LBL(27) LBL(29) LBL(31) LBL(33)    LBL(19) LBL(24) LBL(25) LBL(26) LBL(27) LBL(29) LBL(31) LBL(33)
5492    LBL(35) LBL(43) LBL(47) LBL(48) LBL(49) LBL(50) LBL(51) LBL(52)    LBL(35) LBL(43) LBL(47) LBL(48) LBL(49) LBL(50) LBL(51) LBL(52)
5493    LBL(53) LBL(54)    LBL(53) LBL(54) LBL(55) LBL(56) LBL(57) LBL(58)
5494  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
5495    LBL(16) LBL(18) LBL(20) LBL(21) LBL(22) LBL(23) LBL(28) LBL(30)    LBL(16) LBL(18) LBL(20) LBL(21) LBL(22) LBL(23) LBL(28) LBL(30)
5496    LBL(32) LBL(34) LBL(42) LBL(46)    LBL(32) LBL(34) LBL(42) LBL(46)
5497  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
5498    LBL(36) LBL(37) LBL(38) LBL(39) LBL(40) LBL(41) LBL(44) LBL(45)    LBL(36) LBL(37) LBL(38) LBL(39) LBL(40) LBL(41) LBL(44) LBL(45)
5499      LBL(59) LBL(60) LBL(61) LBL(62)
5500  #endif  /* SUPPORT_UCP */  #endif  /* SUPPORT_UCP */
5501  #endif  /* SUPPORT_UTF8 */  #endif  /* SUPPORT_UTF8 */
5502    default:    default:
# Line 5341  end_subject = md->end_subject; Line 5700  end_subject = md->end_subject;
5700    
5701  md->endonly = (re->options & PCRE_DOLLAR_ENDONLY) != 0;  md->endonly = (re->options & PCRE_DOLLAR_ENDONLY) != 0;
5702  utf8 = md->utf8 = (re->options & PCRE_UTF8) != 0;  utf8 = md->utf8 = (re->options & PCRE_UTF8) != 0;
5703    md->use_ucp = (re->options & PCRE_UCP) != 0;
5704  md->jscript_compat = (re->options & PCRE_JAVASCRIPT_COMPAT) != 0;  md->jscript_compat = (re->options & PCRE_JAVASCRIPT_COMPAT) != 0;
5705    
5706  md->notbol = (options & PCRE_NOTBOL) != 0;  md->notbol = (options & PCRE_NOTBOL) != 0;
# Line 5629  for(;;) Line 5989  for(;;)
5989        while (start_match < end_subject)        while (start_match < end_subject)
5990          {          {
5991          register unsigned int c = *start_match;          register unsigned int c = *start_match;
5992          if ((start_bits[c/8] & (1 << (c&7))) == 0) start_match++;          if ((start_bits[c/8] & (1 << (c&7))) == 0)
5993            else break;            {
5994              start_match++;
5995    #ifdef SUPPORT_UTF8
5996              if (utf8)
5997                while(start_match < end_subject && (*start_match & 0xc0) == 0x80)
5998                  start_match++;
5999    #endif
6000              }
6001            else break;
6002          }          }
6003        }        }
6004      }   /* Starting optimizations */      }   /* Starting optimizations */
# Line 5721  for(;;) Line 6089  for(;;)
6089    
6090    /* OK, we can now run the match. If "hitend" is set afterwards, remember the    /* OK, we can now run the match. If "hitend" is set afterwards, remember the
6091    first starting point for which a partial match was found. */    first starting point for which a partial match was found. */
6092    
6093    md->start_match_ptr = start_match;    md->start_match_ptr = start_match;
6094    md->start_used_ptr = start_match;    md->start_used_ptr = start_match;
6095    md->match_call_count = 0;    md->match_call_count = 0;
# Line 5731  for(;;) Line 6099  for(;;)
6099    
6100    switch(rc)    switch(rc)
6101      {      {
6102      /* 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
6103      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. */
6104      We treat this as NOMATCH. THEN at this level acts exactly like PRUNE. */  
6105        case MATCH_SKIP:
6106        if (md->start_match_ptr != start_match)
6107          {
6108          new_start_match = md->start_match_ptr;
6109          break;
6110          }
6111        /* Fall through */
6112    
6113        /* If MATCH_SKIP_ARG reaches this level it means that a MARK that matched
6114        the SKIP's arg was not found. We also treat this as NOMATCH. */
6115    
6116        case MATCH_SKIP_ARG:
6117        /* Fall through */
6118    
6119        /* NOMATCH and PRUNE advance by one character. THEN at this level acts
6120        exactly like PRUNE. */
6121    
6122      case MATCH_NOMATCH:      case MATCH_NOMATCH:
6123      case MATCH_PRUNE:      case MATCH_PRUNE:
     case MATCH_SKIP_ARG:  
6124      case MATCH_THEN:      case MATCH_THEN:
6125      new_start_match = start_match + 1;      new_start_match = start_match + 1;
6126  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
# Line 5747  for(;;) Line 6130  for(;;)
6130  #endif  #endif
6131      break;      break;
6132    
     /* SKIP passes back the next starting point explicitly. */  
   
     case MATCH_SKIP:  
     new_start_match = md->start_match_ptr;  
     break;  
   
6133      /* COMMIT disables the bumpalong, but otherwise behaves as NOMATCH. */      /* COMMIT disables the bumpalong, but otherwise behaves as NOMATCH. */
6134    
6135      case MATCH_COMMIT:      case MATCH_COMMIT:
# Line 5823  capturing parentheses than vector slots. Line 6200  capturing parentheses than vector slots.
6200    
6201  ENDLOOP:  ENDLOOP:
6202    
6203  if (rc == MATCH_MATCH)  if (rc == MATCH_MATCH || rc == MATCH_ACCEPT)
6204    {    {
6205    if (using_temporary_offsets)    if (using_temporary_offsets)
6206      {      {
# Line 5849  if (rc == MATCH_MATCH) Line 6226  if (rc == MATCH_MATCH)
6226    
6227    if (offsetcount < 2) rc = 0; else    if (offsetcount < 2) rc = 0; else
6228      {      {
6229      offsets[0] = md->start_match_ptr - md->start_subject;      offsets[0] = (int)(md->start_match_ptr - md->start_subject);
6230      offsets[1] = md->end_match_ptr - md->start_subject;      offsets[1] = (int)(md->end_match_ptr - md->start_subject);
6231      }      }
6232    
6233    DPRINTF((">>>> returning %d\n", rc));    DPRINTF((">>>> returning %d\n", rc));
# Line 5865  if (using_temporary_offsets) Line 6242  if (using_temporary_offsets)
6242    DPRINTF(("Freeing temporary memory\n"));    DPRINTF(("Freeing temporary memory\n"));
6243    (pcre_free)(md->offset_vector);    (pcre_free)(md->offset_vector);
6244    }    }
6245    
6246  /* For anything other than nomatch or partial match, just return the code. */  /* For anything other than nomatch or partial match, just return the code. */
6247    
6248  if (rc != MATCH_NOMATCH && rc != PCRE_ERROR_PARTIAL)  if (rc != MATCH_NOMATCH && rc != PCRE_ERROR_PARTIAL)
6249    {    {
6250    DPRINTF((">>>> error: returning %d\n", rc));    DPRINTF((">>>> error: returning %d\n", rc));
6251    return rc;    return rc;
6252    }    }
6253    
6254  /* Handle partial matches - disable any mark data */  /* Handle partial matches - disable any mark data */
6255    
6256  if (start_partial != NULL)  if (start_partial != NULL)
6257    {    {
6258    DPRINTF((">>>> returning PCRE_ERROR_PARTIAL\n"));    DPRINTF((">>>> returning PCRE_ERROR_PARTIAL\n"));
6259    md->mark = NULL;    md->mark = NULL;
6260    if (offsetcount > 1)    if (offsetcount > 1)
6261      {      {
6262      offsets[0] = start_partial - (USPTR)subject;      offsets[0] = (int)(start_partial - (USPTR)subject);
6263      offsets[1] = end_subject - (USPTR)subject;      offsets[1] = (int)(end_subject - (USPTR)subject);
6264      }      }
6265    rc = PCRE_ERROR_PARTIAL;    rc = PCRE_ERROR_PARTIAL;
6266    }    }
6267    
6268  /* This is the classic nomatch case */  /* This is the classic nomatch case */
6269    
6270  else  else
6271    {    {
6272    DPRINTF((">>>> returning PCRE_ERROR_NOMATCH\n"));    DPRINTF((">>>> returning PCRE_ERROR_NOMATCH\n"));
6273    rc = PCRE_ERROR_NOMATCH;    rc = PCRE_ERROR_NOMATCH;
6274    }    }
6275    
6276  /* Return the MARK data if it has been requested. */  /* Return the MARK data if it has been requested. */
6277    
6278  RETURN_MARK:  RETURN_MARK:
6279    
6280  if (extra_data != NULL && (extra_data->flags & PCRE_EXTRA_MARK) != 0)  if (extra_data != NULL && (extra_data->flags & PCRE_EXTRA_MARK) != 0)
6281    *(extra_data->mark) = (unsigned char *)(md->mark);    *(extra_data->mark) = (unsigned char *)(md->mark);
6282  return rc;  return rc;
6283  }  }
6284    
6285  /* End of pcre_exec.c */  /* End of pcre_exec.c */

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

  ViewVC Help
Powered by ViewVC 1.1.5