/[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 721 by ph10, Fri Oct 7 15:51:39 2011 UTC revision 723 by ph10, Sat Oct 8 15:55:23 2011 UTC
# Line 277  enum { RM1=1, RM2, RM3, RM4, RM5, RM Line 277  enum { RM1=1, RM2, RM3, RM4, RM5, RM
277         RM31,  RM32, RM33, RM34, RM35, RM36, RM37, RM38, RM39, RM40,         RM31,  RM32, RM33, RM34, RM35, RM36, RM37, RM38, RM39, RM40,
278         RM41,  RM42, RM43, RM44, RM45, RM46, RM47, RM48, RM49, RM50,         RM41,  RM42, RM43, RM44, RM45, RM46, RM47, RM48, RM49, RM50,
279         RM51,  RM52, RM53, RM54, RM55, RM56, RM57, RM58, RM59, RM60,         RM51,  RM52, RM53, RM54, RM55, RM56, RM57, RM58, RM59, RM60,
280         RM61,  RM62, RM63 };         RM61,  RM62, RM63, RM64, RM65, RM66 };
281    
282  /* 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
283  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 793  for (;;) Line 793  for (;;)
793      md->start_match_ptr = ecode;      md->start_match_ptr = ecode;
794      md->mark = ecode + 2;      md->mark = ecode + 2;
795      RRETURN(MATCH_THEN);      RRETURN(MATCH_THEN);
796    
797        /* Handle an atomic group that does not contain any capturing parentheses.
798        This can be handled like an assertion. Prior to 8.13, all atomic groups
799        were handled this way. In 8.13, the code was changed as below for ONCE, so
800        that backups pass through the group and thereby reset captured values.
801        However, this uses a lot more stack, so in 8.20, atomic groups that do not
802        contain any captures generate OP_ONCE_NC, which can be handled in the old,
803        less stack intensive way.
804    
805        Check the alternative branches in turn - the matching won't pass the KET
806        for this kind of subpattern. If any one branch matches, we carry on as at
807        the end of a normal bracket, leaving the subject pointer, but resetting
808        the start-of-match value in case it was changed by \K. */
809    
810        case OP_ONCE_NC:
811        prev = ecode;
812        saved_eptr = eptr;
813        do
814          {
815          RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, eptrb, RM64);
816          if (rrc == MATCH_MATCH)  /* Note: _not_ MATCH_ACCEPT */
817            {
818            mstart = md->start_match_ptr;
819            break;
820            }
821          if (rrc == MATCH_THEN)
822            {
823            next = ecode + GET(ecode,1);
824            if (md->start_match_ptr < next &&
825                (*ecode == OP_ALT || *next == OP_ALT))
826              rrc = MATCH_NOMATCH;
827            }
828    
829          if (rrc != MATCH_NOMATCH) RRETURN(rrc);
830          ecode += GET(ecode,1);
831          }
832        while (*ecode == OP_ALT);
833    
834        /* If hit the end of the group (which could be repeated), fail */
835    
836        if (*ecode != OP_ONCE_NC && *ecode != OP_ALT) RRETURN(MATCH_NOMATCH);
837    
838        /* Continue as from after the group, updating the offsets high water
839        mark, since extracts may have been taken. */
840    
841        do ecode += GET(ecode, 1); while (*ecode == OP_ALT);
842    
843        offset_top = md->end_offset_top;
844        eptr = md->end_match_ptr;
845    
846        /* For a non-repeating ket, just continue at this level. This also
847        happens for a repeating ket if no characters were matched in the group.
848        This is the forcible breaking of infinite loops as implemented in Perl
849        5.005. */
850    
851        if (*ecode == OP_KET || eptr == saved_eptr)
852          {
853          ecode += 1+LINK_SIZE;
854          break;
855          }
856    
857        /* The repeating kets try the rest of the pattern or restart from the
858        preceding bracket, in the appropriate order. The second "call" of match()
859        uses tail recursion, to avoid using another stack frame. */
860    
861        if (*ecode == OP_KETRMIN)
862          {
863          RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, eptrb, RM65);
864          if (rrc != MATCH_NOMATCH) RRETURN(rrc);
865          ecode = prev;
866          goto TAIL_RECURSE;
867          }
868        else  /* OP_KETRMAX */
869          {
870          md->match_function_type = MATCH_CBEGROUP;
871          RMATCH(eptr, prev, offset_top, md, eptrb, RM66);
872          if (rrc != MATCH_NOMATCH) RRETURN(rrc);
873          ecode += 1 + LINK_SIZE;
874          goto TAIL_RECURSE;
875          }
876        /* Control never gets here */
877    
878      /* Handle a capturing bracket, other than those that are possessive with an      /* Handle a capturing bracket, other than those that are possessive with an
879      unlimited repeat. If there is space in the offset vector, save the current      unlimited repeat. If there is space in the offset vector, save the current
# Line 888  for (;;) Line 969  for (;;)
969      /* VVVVVVVVVVVVVVVVVVVVVVVVV */      /* VVVVVVVVVVVVVVVVVVVVVVVVV */
970    
971      /* Non-capturing or atomic group, except for possessive with unlimited      /* Non-capturing or atomic group, except for possessive with unlimited
972      repeat. Loop for all the alternatives.      repeat and ONCE group with no captures. Loop for all the alternatives.
973    
974      When we get to the final alternative within the brackets, we used to return      When we get to the final alternative within the brackets, we used to return
975      the result of a recursive call to match() whatever happened so it was      the result of a recursive call to match() whatever happened so it was
# Line 1745  for (;;) Line 1826  for (;;)
1826        }        }
1827      else saved_eptr = NULL;      else saved_eptr = NULL;
1828    
1829      /* 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 a non-capturing atomic
1830      MATCH_MATCH, but record the current high water mark for use by positive      group, stop matching and return MATCH_MATCH, but record the current high
1831      assertions. We also need to record the match start in case it was changed      water mark for use by positive assertions. We also need to record the match
1832      by \K. */      start in case it was changed by \K. */
1833    
1834      if (*prev >= OP_ASSERT && *prev <= OP_ASSERTBACK_NOT)      if ((*prev >= OP_ASSERT && *prev <= OP_ASSERTBACK_NOT) ||
1835             *prev == OP_ONCE_NC)
1836        {        {
1837        md->end_match_ptr = eptr;      /* For ONCE */        md->end_match_ptr = eptr;      /* For ONCE_NC */
1838        md->end_offset_top = offset_top;        md->end_offset_top = offset_top;
1839        md->start_match_ptr = mstart;        md->start_match_ptr = mstart;
1840        MRRETURN(MATCH_MATCH);         /* Sets md->mark */        MRRETURN(MATCH_MATCH);         /* Sets md->mark */
# Line 1820  for (;;) Line 1902  for (;;)
1902      /* For an ordinary non-repeating ket, just continue at this level. This      /* For an ordinary non-repeating ket, just continue at this level. This
1903      also happens for a repeating ket if no characters were matched in the      also happens for a repeating ket if no characters were matched in the
1904      group. This is the forcible breaking of infinite loops as implemented in      group. This is the forcible breaking of infinite loops as implemented in
1905      Perl 5.005. For a non-repeating atomic group, establish a backup point by      Perl 5.005. For a non-repeating atomic group that includes captures,
1906      processing the rest of the pattern at a lower level. If this results in a      establish a backup point by processing the rest of the pattern at a lower
1907      NOMATCH return, pass MATCH_ONCE back to the original OP_ONCE level, thereby      level. If this results in a NOMATCH return, pass MATCH_ONCE back to the
1908      bypassing intermediate backup points, but resetting any captures that      original OP_ONCE level, thereby bypassing intermediate backup points, but
1909      happened along the way. */      resetting any captures that happened along the way. */
1910    
1911      if (*ecode == OP_KET || eptr == saved_eptr)      if (*ecode == OP_KET || eptr == saved_eptr)
1912        {        {
# Line 5745  switch (frame->Xwhere) Line 5827  switch (frame->Xwhere)
5827    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)
5828    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)
5829    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)
5830    LBL(53) LBL(54) LBL(55) LBL(56) LBL(57) LBL(58) LBL(63)    LBL(53) LBL(54) LBL(55) LBL(56) LBL(57) LBL(58) LBL(63) LBL(64)
5831      LBL(65) LBL(66)
5832  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
5833    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)
5834    LBL(32) LBL(34) LBL(42) LBL(46)    LBL(32) LBL(34) LBL(42) LBL(46)

Legend:
Removed from v.721  
changed lines
  Added in v.723

webmaster@exim.org
ViewVC Help
Powered by ViewVC 1.1.12