# Diff of /code/trunk/pcre_exec.c

revision 702 by ph10, Tue Sep 20 15:45:06 2011 UTC revision 713 by ph10, Tue Sep 27 11:03:15 2011 UTC
# Line 870  for (;;) Line 870  for (;;)
870      /* VVVVVVVVVVVVVVVVVVVVVVVVV */      /* VVVVVVVVVVVVVVVVVVVVVVVVV */
871
872      /* Non-capturing or atomic group, except for possessive with unlimited      /* Non-capturing or atomic group, except for possessive with unlimited
873      repeat. Loop for all the alternatives.      repeat. Loop for all the alternatives.
874
875      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
876      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
877      possible to reduce stack usage by turning this into a tail recursion,      possible to reduce stack usage by turning this into a tail recursion,
878      except in the case of a possibly empty group. However, now that there is      except in the case of a possibly empty group. However, now that there is
879      the possiblity of (*THEN) occurring in the final alternative, this      the possiblity of (*THEN) occurring in the final alternative, this
880      optimization is no longer always possible.      optimization is no longer always possible.
881
882      We can optimize if we know there are no (*THEN)s in the pattern; at present      We can optimize if we know there are no (*THEN)s in the pattern; at present
883      this is the best that can be done.      this is the best that can be done.
884
885      MATCH_ONCE is returned when the end of an atomic group is successfully      MATCH_ONCE is returned when the end of an atomic group is successfully
886      reached, but subsequent matching fails. It passes back up the tree (causing      reached, but subsequent matching fails. It passes back up the tree (causing
# Line 899  for (;;) Line 899  for (;;)
899        if (op >= OP_SBRA || op == OP_ONCE) md->match_function_type = MATCH_CBEGROUP;        if (op >= OP_SBRA || op == OP_ONCE) md->match_function_type = MATCH_CBEGROUP;
900
901        /* If this is not a possibly empty group, and there are no (*THEN)s in        /* If this is not a possibly empty group, and there are no (*THEN)s in
902        the pattern, and this is the final alternative, optimize as described        the pattern, and this is the final alternative, optimize as described
903        above. */        above. */
904
905        else if (!md->hasthen && ecode[GET(ecode, 1)] != OP_ALT)        else if (!md->hasthen && ecode[GET(ecode, 1)] != OP_ALT)
906          {          {
907          ecode += _pcre_OP_lengths[*ecode];          ecode += _pcre_OP_lengths[*ecode];
908          goto TAIL_RECURSE;          goto TAIL_RECURSE;
909          }          }
910
911        /* In all other cases, we have to make another call to match(). */        /* In all other cases, we have to make another call to match(). */
912
913        RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, eptrb,        RMATCH(eptr, ecode + _pcre_OP_lengths[*ecode], offset_top, md, eptrb,
914          RM2);          RM2);
915        if (rrc != MATCH_NOMATCH &&        if (rrc != MATCH_NOMATCH &&
916            (rrc != MATCH_THEN || md->start_match_ptr != ecode))            (rrc != MATCH_THEN || md->start_match_ptr != ecode))
# Line 1297  for (;;) Line 1297  for (;;)
1297          {          {
1299          goto TAIL_RECURSE;          goto TAIL_RECURSE;
1300          }          }
1301
1302        /* A call to match() is required. */        /* A call to match() is required. */
1303
1304        RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, eptrb, RM49);        RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, eptrb, RM49);
1305
1306        /* If the result is THEN from within the "true" branch of the condition,        /* If the result is THEN from within the "true" branch of the condition,
1307        md->start_match_ptr will point to the original OP_COND, not to the start        md->start_match_ptr will point to the original OP_COND, not to the start
1308        of the branch, so we have do work to see if it matches. If THEN comes        of the branch, so we have do work to see if it matches. If THEN comes
1309        from the "false" branch, md->start_match_ptr does point to OP_ALT. */        from the "false" branch, md->start_match_ptr does point to OP_ALT. */
1310
1311        if (rrc == MATCH_THEN)        if (rrc == MATCH_THEN)
1312          {          {
1313          if (*ecode != OP_ALT)          if (*ecode != OP_ALT)
1314            {            {
1315            do ecode += GET(ecode, 1); while (*ecode == OP_ALT);            do ecode += GET(ecode, 1); while (*ecode == OP_ALT);
1316            ecode -= GET(ecode, 1);            ecode -= GET(ecode, 1);
1317            }            }
1318          if (md->start_match_ptr == ecode) rrc = MATCH_NOMATCH;          if (md->start_match_ptr == ecode) rrc = MATCH_NOMATCH;
1319          }          }
1320        RRETURN(rrc);        RRETURN(rrc);
1321        }        }
1322
1323       /* Condition false & no alternative; continue after the group. */       /* Condition false & no alternative; continue after the group. */
1324
1325      else      else
1326        {        {