+ case CURLYM:
+ {
+ I32 l = 0;
+ CHECKPOINT lastcp;
+
+ /* We suppose that the next guy does not need
+ backtracking: in particular, it is of constant length,
+ and has no parenths to influence future backrefs. */
+ ln = ARG1(scan); /* min to match */
+ n = ARG2(scan); /* max to match */
+ paren = scan->flags;
+ if (paren) {
+ if (paren > regsize)
+ regsize = paren;
+ if (paren > *reglastparen)
+ *reglastparen = paren;
+ }
+ scan = NEXTOPER(scan) + NODE_STEP_REGNODE;
+ if (paren)
+ scan += NEXT_OFF(scan); /* Skip former OPEN. */
+ reginput = locinput;
+ if (minmod) {
+ minmod = 0;
+ if (ln && regrepeat_hard(scan, ln, &l) < ln)
+ sayNO;
+ if (ln && l == 0 && n >= ln
+ /* In fact, this is tricky. If paren, then the
+ fact that we did/didnot match may influence
+ future execution. */
+ && !(paren && ln == 0))
+ ln = n;
+ locinput = reginput;
+ if (regkind[(U8)OP(next)] == EXACT) {
+ c1 = UCHARAT(OPERAND(next) + 1);
+ if (OP(next) == EXACTF)
+ c2 = fold[c1];
+ else if (OP(next) == EXACTFL)
+ c2 = fold_locale[c1];
+ else
+ c2 = c1;
+ } else
+ c1 = c2 = -1000;
+ REGCP_SET;
+ /* This may be improved if l == 0. */
+ while (n >= ln || (n == REG_INFTY && ln > 0 && l)) { /* ln overflow ? */
+ /* If it could work, try it. */
+ if (c1 == -1000 ||
+ UCHARAT(reginput) == c1 ||
+ UCHARAT(reginput) == c2)
+ {
+ if (paren) {
+ if (n) {
+ regstartp[paren] = reginput - l;
+ regendp[paren] = reginput;
+ } else
+ regendp[paren] = NULL;
+ }
+ if (regmatch(next))
+ sayYES;
+ REGCP_UNWIND;
+ }
+ /* Couldn't or didn't -- move forward. */
+ reginput = locinput;
+ if (regrepeat_hard(scan, 1, &l)) {
+ ln++;
+ locinput = reginput;
+ }
+ else
+ sayNO;
+ }
+ } else {
+ n = regrepeat_hard(scan, n, &l);
+ if (n != 0 && l == 0
+ /* In fact, this is tricky. If paren, then the
+ fact that we did/didnot match may influence
+ future execution. */
+ && !(paren && ln == 0))
+ ln = n;
+ locinput = reginput;
+ DEBUG_r(
+ PerlIO_printf(Perl_debug_log, "%*s matched %ld times, len=%ld...\n", REPORT_CODE_OFF+regindent*2, "", n, l)
+ );
+ if (n >= ln) {
+ if (regkind[(U8)OP(next)] == EXACT) {
+ c1 = UCHARAT(OPERAND(next) + 1);
+ if (OP(next) == EXACTF)
+ c2 = fold[c1];
+ else if (OP(next) == EXACTFL)
+ c2 = fold_locale[c1];
+ else
+ c2 = c1;
+ } else
+ c1 = c2 = -1000;
+ }
+ REGCP_SET;
+ while (n >= ln) {
+ /* If it could work, try it. */
+ if (c1 == -1000 ||
+ UCHARAT(reginput) == c1 ||
+ UCHARAT(reginput) == c2)
+ {
+ DEBUG_r(
+ PerlIO_printf(Perl_debug_log, "%*s trying tail with n=%ld...\n", REPORT_CODE_OFF+regindent*2, "", n)
+ );
+ if (paren) {
+ if (n) {
+ regstartp[paren] = reginput - l;
+ regendp[paren] = reginput;
+ } else
+ regendp[paren] = NULL;
+ }
+ if (regmatch(next))
+ sayYES;
+ REGCP_UNWIND;
+ }
+ /* Couldn't or didn't -- back up. */
+ n--;
+ locinput -= l;
+ reginput = locinput;
+ }
+ }
+ sayNO;
+ break;
+ }
+ case CURLYN:
+ paren = scan->flags; /* Which paren to set */
+ if (paren > regsize)
+ regsize = paren;
+ if (paren > *reglastparen)
+ *reglastparen = paren;
+ ln = ARG1(scan); /* min to match */
+ n = ARG2(scan); /* max to match */
+ scan = regnext(NEXTOPER(scan) + NODE_STEP_REGNODE);
+ goto repeat;